LocalCDN-Firefox-Chrome-Brave/resources/tensorflow/4.3.0/tf.min.jsm

19 lines
1.3 MiB
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 2023 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(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).tf=e.tf||{})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e,t){return e(t={exports:{}},t.exports),t.exports}var r=function(e){return e&&e.Math==Math&&e},a=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(e){return!0}},o=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),s={}.propertyIsEnumerable,u=Object.getOwnPropertyDescriptor,l=u&&!s.call({1:2},1)?function(e){var t=u(this,e);return!!t&&t.enumerable}:s,c={f:l},p=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},h={}.toString,d=function(e){return h.call(e).slice(8,-1)},f="".split,m=i((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==d(e)?f.call(e,""):Object(e)}:Object,v=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},g=function(e){return m(v(e))},y=function(e){return"object"==typeof e?null!==e:"function"==typeof e},b=function(e,t){if(!y(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!y(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!y(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!y(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},x={}.hasOwnProperty,w=function(e,t){return x.call(e,t)},k=a.document,N=y(k)&&y(k.createElement),I=function(e){return N?k.createElement(e):{}},S=!o&&!i((function(){return 7!=Object.defineProperty(I("div"),"a",{get:function(){return 7}}).a})),T=Object.getOwnPropertyDescriptor,C={f:o?T:function(e,t){if(e=g(e),t=b(t,!0),S)try{return T(e,t)}catch(e){}if(w(e,t))return p(!c.f.call(e,t),e[t])}},E=function(e){if(!y(e))throw TypeError(String(e)+" is not an object");return e},A=Object.defineProperty,R={f:o?A:function(e,t,n){if(E(e),t=b(t,!0),E(n),S)try{return A(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},_=o?function(e,t,n){return R.f(e,t,p(1,n))}:function(e,t,n){return e[t]=n,e},F=function(e,t){try{_(a,e,t)}catch(n){a[e]=t}return t},O="__core-js_shared__",D=a[O]||F(O,{}),M=Function.toString;"function"!=typeof D.inspectSource&&(D.inspectSource=function(e){return M.call(e)});var L,z,P,B=D.inspectSource,W=a.WeakMap,V="function"==typeof W&&/native code/.test(B(W)),U=n((function(e){(e.exports=function(e,t){return D[e]||(D[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.9.1",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),G=0,j=Math.random(),H=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++G+j).toString(36)},q=U("keys"),K=function(e){return q[e]||(q[e]=H(e))},X={},Y=a.WeakMap;if(V){var J=D.state||(D.state=new Y),Z=J.get,Q=J.has,$=J.set;L=function(e,t){return t.facade=e,$.call(J,e,t),t},z=function(e){return Z.call(J,e)||{}},P=function(e){return Q.call(J,e)}}else{var ee=K("state");X[ee]=!0,L=function(e,t){return t.facade=e,_(e,ee,t),t},z=function(e){return w(e,ee)?e[ee]:{}},P=function(e){return w(e,ee)}}var te,ne,re={set:L,get:z,has:P,enforce:function(e){return P(e)?z(e):L(e,{})},getterFor:function(e){return function(t){var n;if(!y(t)||(n=z(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},ae=n((function(e){var t=re.get,n=re.enforce,r=String(String).split("String");(e.exports=function(e,t,i,o){var s,u=!!o&&!!o.unsafe,l=!!o&&!!o.enumerable,c=!!o&&!!o.noTargetGet;"function"==typeof i&&("string"!=typeof t||w(i,"name")||_(i,"name",t),(s=n(i)).source||(s.source=r.join("string"==typeof t?t:""))),e!==a?(u?!c&&e[t]&&(l=!0):delete e[t],l?e[t]=i:_(e,t,i)):l?e[t]=i:F(t,i)})(Function.prototype,"toString",(function(){return"function"==typeof this&&t(this).source||B(this)}))})),ie=a,oe=function(e){return"function"==typeof e?e:void 0},se=function(e,t){return arguments.length<2?oe(ie[e])||oe(a[e]):ie[e]&&ie[e][t]||a[e]&&a[e][t]},ue=Math.ceil,le=Math.floor,ce=function(e){return isNaN(e=+e)?0:(e>0?le:ue)(e)},pe=Math.min,he=function(e){return e>0?pe(ce(e),9007199254740991):0},de=Math.max,fe=Math.min,me=function(e,t){var n=ce(e);return n<0?de(n+t,0):fe(n,t)},ve=function(e){return function(t,n,r){var a,i=g(t),o=he(i.length),s=me(r,o);if(e&&n!=n){for(;o>s;)if((a=i[s++])!=a)return!0}else for(;o>s;s++)if((e||s in i)&&i[s]===n)return e||s||0;return!e&&-1}},ge={includes:ve(!0),indexOf:ve(!1)},ye=ge.indexOf,be=function(e,t){var n,r=g(e),a=0,i=[];for(n in r)!w(X,n)&&w(r,n)&&i.push(n);for(;t.length>a;)w(r,n=t[a++])&&(~ye(i,n)||i.push(n));return i},xe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],we=xe.concat("length","prototype"),ke={f:Object.getOwnPropertyNames||function(e){return be(e,we)}},Ne={f:Object.getOwnPropertySymbols},Ie=se("Reflect","ownKeys")||function(e){var t=ke.f(E(e)),n=Ne.f;return n?t.concat(n(e)):t},Se=function(e,t){for(var n=Ie(t),r=R.f,a=C.f,i=0;i<n.length;i++){var o=n[i];w(e,o)||r(e,o,a(t,o))}},Te=/#|\.prototype\./,Ce=function(e,t){var n=Ae[Ee(e)];return n==_e||n!=Re&&("function"==typeof t?i(t):!!t)},Ee=Ce.normalize=function(e){return String(e).replace(Te,".").toLowerCase()},Ae=Ce.data={},Re=Ce.NATIVE="N",_e=Ce.POLYFILL="P",Fe=Ce,Oe=C.f,De=function(e,t){var n,r,i,o,s,u=e.target,l=e.global,c=e.stat;if(n=l?a:c?a[u]||F(u,{}):(a[u]||{}).prototype)for(r in t){if(o=t[r],i=e.noTargetGet?(s=Oe(n,r))&&s.value:n[r],!Fe(l?r:u+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;Se(o,i)}(e.sham||i&&i.sham)&&_(o,"sham",!0),ae(n,r,o,e)}},Me="process"==d(a.process),Le=se("navigator","userAgent")||"",ze=a.process,Pe=ze&&ze.versions,Be=Pe&&Pe.v8;Be?ne=(te=Be.split("."))[0]+te[1]:Le&&(!(te=Le.match(/Edge\/(\d+)/))||te[1]>=74)&&(te=Le.match(/Chrome\/(\d+)/))&&(ne=te[1]);var We,Ve=ne&&+ne,Ue=!!Object.getOwnPropertySymbols&&!i((function(){return!Symbol.sham&&(Me?38===Ve:Ve>37&&Ve<41)})),Ge=Ue&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,je=Array.isArray||function(e){return"Array"==d(e)},He=function(e){return Object(v(e))},qe=Object.keys||function(e){return be(e,xe)},Ke=o?Object.defineProperties:function(e,t){E(e);for(var n,r=qe(t),a=r.length,i=0;a>i;)R.f(e,n=r[i++],t[n]);return e},Xe=se("document","documentElement"),Ye=K("IE_PROTO"),Je=function(){},Ze=function(e){return"<script>"+e+"</"+"script>"},Qe=function(){try{We=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;Qe=We?function(e){e.write(Ze("")),e.close();var t=e.parentWindow.Object;return e=null,t}(We):((t=I("iframe")).style.display="none",Xe.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Ze("document.F=Object")),e.close(),e.F);for(var n=xe.length;n--;)delete Qe.prototype[xe[n]];return Qe()};X[Ye]=!0;var $e=Object.create||function(e,t){var n;return null!==e?(Je.prototype=E(e),n=new Je,Je.prototype=null,n[Ye]=e):n=Qe(),void 0===t?n:Ke(n,t)},et=ke.f,tt={}.toString,nt="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],rt={f:function(e){return nt&&"[object Window]"==tt.call(e)?function(e){try{return et(e)}catch(e){return nt.slice()}}(e):et(g(e))}},at=U("wks"),it=a.Symbol,ot=Ge?it:it&&it.withoutSetter||H,st=function(e){return w(at,e)&&(Ue||"string"==typeof at[e])||(Ue&&w(it,e)?at[e]=it[e]:at[e]=ot("Symbol."+e)),at[e]},ut={f:st},lt=R.f,ct=function(e){var t=ie.Symbol||(ie.Symbol={});w(t,e)||lt(t,e,{value:ut.f(e)})},pt=R.f,ht=st("toStringTag"),dt=function(e,t,n){e&&!w(e=n?e:e.prototype,ht)&&pt(e,ht,{configurable:!0,value:t})},ft=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},mt=function(e,t,n){if(ft(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,a){return e.call(t,n,r,a)}}return function(){return e.apply(t,arguments)}},vt=st("species"),gt=function(e,t){var n;return je(e)&&("function"!=typeof(n=e.constructor)||n!==Array&&!je(n.prototype)?y(n)&&null===(n=n[vt])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===t?0:t)},yt=[].push,bt=function(e){var t=1==e,n=2==e,r=3==e,a=4==e,i=6==e,o=7==e,s=5==e||i;return function(u,l,c,p){for(var h,d,f=He(u),v=m(f),g=mt(l,c,3),y=he(v.length),b=0,x=p||gt,w=t?x(u,y):n||o?x(u,0):void 0;y>b;b++)if((s||b in v)&&(d=g(h=v[b],b,f),e))if(t)w[b]=d;else if(d)switch(e){case 3:return!0;case 5:return h;case 6:return b;case 2:yt.call(w,h)}else switch(e){case 4:return!1;case 7:yt.call(w,h)}return i?-1:r||a?a:w}},xt={forEach:bt(0),map:bt(1),filter:bt(2),some:bt(3),every:bt(4),find:bt(5),findIndex:bt(6),filterOut:bt(7)},wt=xt.forEach,kt=K("hidden"),Nt="Symbol",It=st("toPrimitive"),St=re.set,Tt=re.getterFor(Nt),Ct=Object.prototype,Et=a.Symbol,At=se("JSON","stringify"),Rt=C.f,_t=R.f,Ft=rt.f,Ot=c.f,Dt=U("symbols"),Mt=U("op-symbols"),Lt=U("string-to-symbol-registry"),zt=U("symbol-to-string-registry"),Pt=U("wks"),Bt=a.QObject,Wt=!Bt||!Bt.prototype||!Bt.prototype.findChild,Vt=o&&i((function(){return 7!=$e(_t({},"a",{get:function(){return _t(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=Rt(Ct,t);r&&delete Ct[t],_t(e,t,n),r&&e!==Ct&&_t(Ct,t,r)}:_t,Ut=function(e,t){var n=Dt[e]=$e(Et.prototype);return St(n,{type:Nt,tag:e,description:t}),o||(n.description=t),n},Gt=Ge?function(e){return"symbol"==typeof e}:function(e){return Object(e)instanceof Et},jt=function(e,t,n){e===Ct&&jt(Mt,t,n),E(e);var r=b(t,!0);return E(n),w(Dt,r)?(n.enumerable?(w(e,kt)&&e[kt][r]&&(e[kt][r]=!1),n=$e(n,{enumerable:p(0,!1)})):(w(e,kt)||_t(e,kt,p(1,{})),e[kt][r]=!0),Vt(e,r,n)):_t(e,r,n)},Ht=function(e,t){E(e);var n=g(t),r=qe(n).concat(Yt(n));return wt(r,(function(t){o&&!qt.call(n,t)||jt(e,t,n[t])})),e},qt=function(e){var t=b(e,!0),n=Ot.call(this,t);return!(this===Ct&&w(Dt,t)&&!w(Mt,t))&&(!(n||!w(this,t)||!w(Dt,t)||w(this,kt)&&this[kt][t])||n)},Kt=function(e,t){var n=g(e),r=b(t,!0);if(n!==Ct||!w(Dt,r)||w(Mt,r)){var a=Rt(n,r);return!a||!w(Dt,r)||w(n,kt)&&n[kt][r]||(a.enumerable=!0),a}},Xt=function(e){var t=Ft(g(e)),n=[];return wt(t,(function(e){w(Dt,e)||w(X,e)||n.push(e)})),n},Yt=function(e){var t=e===Ct,n=Ft(t?Mt:g(e)),r=[];return wt(n,(function(e){!w(Dt,e)||t&&!w(Ct,e)||r.push(Dt[e])})),r};if(Ue||(Et=function(){if(this instanceof Et)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?String(arguments[0]):void 0,t=H(e),n=function e(n){this===Ct&&e.call(Mt,n),w(this,kt)&&w(this[kt],t)&&(this[kt][t]=!1),Vt(this,t,p(1,n))};return o&&Wt&&Vt(Ct,t,{configurable:!0,set:n}),Ut(t,e)},ae(Et.prototype,"toString",(function(){return Tt(this).tag})),ae(Et,"withoutSetter",(function(e){return Ut(H(e),e)})),c.f=qt,R.f=jt,C.f=Kt,ke.f=rt.f=Xt,Ne.f=Yt,ut.f=function(e){return Ut(st(e),e)},o&&(_t(Et.prototype,"description",{configurable:!0,get:function(){return Tt(this).description}}),ae(Ct,"propertyIsEnumerable",qt,{unsafe:!0}))),De({global:!0,wrap:!0,forced:!Ue,sham:!Ue},{Symbol:Et}),wt(qe(Pt),(function(e){ct(e)})),De({target:Nt,stat:!0,forced:!Ue},{for:function(e){var t=String(e);if(w(Lt,t))return Lt[t];var n=Et(t);return Lt[t]=n,zt[n]=t,n},keyFor:function(e){if(!Gt(e))throw TypeError(e+" is not a symbol");if(w(zt,e))return zt[e]},useSetter:function(){Wt=!0},useSimple:function(){Wt=!1}}),De({target:"Object",stat:!0,forced:!Ue,sham:!o},{create:function(e,t){return void 0===t?$e(e):Ht($e(e),t)},defineProperty:jt,defineProperties:Ht,getOwnPropertyDescriptor:Kt}),De({target:"Object",stat:!0,forced:!Ue},{getOwnPropertyNames:Xt,getOwnPropertySymbols:Yt}),De({target:"Object",stat:!0,forced:i((function(){Ne.f(1)}))},{getOwnPropertySymbols:function(e){return Ne.f(He(e))}}),At){var Jt=!Ue||i((function(){var e=Et();return"[null]"!=At([e])||"{}"!=At({a:e})||"{}"!=At(Object(e))}));De({target:"JSON",stat:!0,forced:Jt},{stringify:function(e,t,n){for(var r,a=[e],i=1;arguments.length>i;)a.push(arguments[i++]);if(r=t,(y(t)||void 0!==e)&&!Gt(e))return je(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!Gt(t))return t}),a[1]=t,At.apply(null,a)}})}Et.prototype[It]||_(Et.prototype,It,Et.prototype.valueOf),dt(Et,Nt),X[kt]=!0,ct("asyncIterator");var Zt=R.f,Qt=a.Symbol;if(o&&"function"==typeof Qt&&(!("description"in Qt.prototype)||void 0!==Qt().description)){var $t={},en=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof en?new Qt(e):void 0===e?Qt():Qt(e);return""===e&&($t[t]=!0),t};Se(en,Qt);var tn=en.prototype=Qt.prototype;tn.constructor=en;var nn=tn.toString,rn="Symbol(test)"==String(Qt("test")),an=/^Symbol\((.*)\)[^)]+$/;Zt(tn,"description",{configurable:!0,get:function(){var e=y(this)?this.valueOf():this,t=nn.call(e);if(w($t,e))return"";var n=rn?t.slice(7,-1):t.replace(an,"$1");return""===n?void 0:n}}),De({global:!0,forced:!0},{Symbol:en})}ct("hasInstance"),ct("isConcatSpreadable"),ct("iterator"),ct("match"),ct("matchAll"),ct("replace"),ct("search"),ct("species"),ct("split"),ct("toPrimitive"),ct("toStringTag"),ct("unscopables");var on=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),sn=K("IE_PROTO"),un=Object.prototype,ln=on?Object.getPrototypeOf:function(e){return e=He(e),w(e,sn)?e[sn]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?un:null},cn=function(e){if(!y(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e},pn=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return E(n),cn(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),hn={},dn=st("iterator"),fn=Array.prototype,mn=function(e){return void 0!==e&&(hn.Array===e||fn[dn]===e)},vn={};vn[st("toStringTag")]="z";var gn="[object z]"===String(vn),yn=st("toStringTag"),bn="Arguments"==d(function(){return arguments}()),xn=gn?d:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),yn))?n:bn?d(t):"Object"==(r=d(t))&&"function"==typeof t.callee?"Arguments":r},wn=st("iterator"),kn=function(e){if(null!=e)return e[wn]||e["@@iterator"]||hn[xn(e)]},Nn=function(e){var t=e.return;if(void 0!==t)return E(t.call(e)).value},In=function(e,t){this.stopped=e,this.result=t},Sn=function(e,t,n){var r,a,i,o,s,u,l,c=n&&n.that,p=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_ITERATOR),d=!(!n||!n.INTERRUPTED),f=mt(t,c,1+p+d),m=function(e){return r&&Nn(r),new In(!0,e)},v=function(e){return p?(E(e),d?f(e[0],e[1],m):f(e[0],e[1])):d?f(e,m):f(e)};if(h)r=e;else{if("function"!=typeof(a=kn(e)))throw TypeError("Target is not iterable");if(mn(a)){for(i=0,o=he(e.length);o>i;i++)if((s=v(e[i]))&&s instanceof In)return s;return new In(!1)}r=a.call(e)}for(u=r.next;!(l=u.call(r)).done;){try{s=v(l.value)}catch(e){throw Nn(r),e}if("object"==typeof s&&s&&s instanceof In)return s}return new In(!1)},Tn=function(e,t){var n=this;if(!(n instanceof Tn))return new Tn(e,t);pn&&(n=pn(new Error(void 0),ln(n))),void 0!==t&&_(n,"message",String(t));var r=[];return Sn(e,r.push,{that:r}),_(n,"errors",r),n};Tn.prototype=$e(Error.prototype,{constructor:p(5,Tn),message:p(5,""),name:p(5,"AggregateError")}),De({global:!0},{AggregateError:Tn});var Cn=function(e,t,n,r){try{return r?t(E(n)[0],n[1]):t(n)}catch(t){throw Nn(e),t}},En=function(e,t,n){var r=b(t);r in e?R.f(e,r,p(0,n)):e[r]=n},An=function(e){var t,n,r,a,i,o,s=He(e),u="function"==typeof this?this:Array,l=arguments.length,c=l>1?arguments[1]:void 0,p=void 0!==c,h=kn(s),d=0;if(p&&(c=mt(c,l>2?arguments[2]:void 0,2)),null==h||u==Array&&mn(h))for(n=new u(t=he(s.length));t>d;d++)o=p?c(s[d],d):s[d],En(n,d,o);else for(i=(a=h.call(s)).next,n=new u;!(r=i.call(a)).done;d++)o=p?Cn(a,c,[r.value,d],!0):r.value,En(n,d,o);return n.length=d,n},Rn=st("iterator"),_n=!1;try{var Fn=0,On={next:function(){return{done:!!Fn++}},return:function(){_n=!0}};On[Rn]=function(){return this},Array.from(On,(function(){throw 2}))}catch(e){}var Dn=function(e,t){if(!t&&!_n)return!1;var n=!1;try{var r={};r[Rn]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},Mn=!Dn((function(e){Array.from(e)}));De({target:"Array",stat:!0,forced:Mn},{from:An}),De({target:"Array",stat:!0},{isArray:je});var Ln=i((function(){function e(){}return!(Array.of.call(e)instanceof e)}));De({target:"Array",stat:!0,forced:Ln},{of:function(){for(var e=0,t=arguments.length,n=new("function"==typeof this?this:Array)(t);t>e;)En(n,e,arguments[e++]);return n.length=t,n}});var zn=st("species"),Pn=function(e){return Ve>=51||!i((function(){var t=[];return(t.constructor={})[zn]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Bn=st("isConcatSpreadable"),Wn=9007199254740991,Vn="Maximum allowed index exceeded",Un=Ve>=51||!i((function(){var e=[];return e[Bn]=!1,e.concat()[0]!==e})),Gn=Pn("concat"),jn=function(e){if(!y(e))return!1;var t=e[Bn];return void 0!==t?!!t:je(e)};De({target:"Array",proto:!0,forced:!Un||!Gn},{concat:function(e){var t,n,r,a,i,o=He(this),s=gt(o,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(jn(i=-1===t?o:arguments[t])){if(u+(a=he(i.length))>Wn)throw TypeError(Vn);for(n=0;n<a;n++,u++)n in i&&En(s,u,i[n])}else{if(u>=Wn)throw TypeError(Vn);En(s,u++,i)}return s.length=u,s}});var Hn=Math.min,qn=[].copyWithin||function(e,t){var n=He(this),r=he(n.length),a=me(e,r),i=me(t,r),o=arguments.length>2?arguments[2]:void 0,s=Hn((void 0===o?r:me(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},Kn=st("unscopables"),Xn=Array.prototype;null==Xn[Kn]&&R.f(Xn,Kn,{configurable:!0,value:$e(null)});var Yn=function(e){Xn[Kn][e]=!0};De({target:"Array",proto:!0},{copyWithin:qn}),Yn("copyWithin");var Jn=function(e,t){var n=[][e];return!!n&&i((function(){n.call(null,t||function(){throw 1},1)}))},Zn=xt.every,Qn=Jn("every");De({target:"Array",proto:!0,forced:!Qn},{every:function(e){return Zn(this,e,arguments.length>1?arguments[1]:void 0)}});var $n=function(e){for(var t=He(this),n=he(t.length),r=arguments.length,a=me(r>1?arguments[1]:void 0,n),i=r>2?arguments[2]:void 0,o=void 0===i?n:me(i,n);o>a;)t[a++]=e;return t};De({target:"Array",proto:!0},{fill:$n}),Yn("fill");var er=xt.filter,tr=Pn("filter");De({target:"Array",proto:!0,forced:!tr},{filter:function(e){return er(this,e,arguments.length>1?arguments[1]:void 0)}});var nr=xt.find,rr="find",ar=!0;rr in[]&&Array(1).find((function(){ar=!1})),De({target:"Array",proto:!0,forced:ar},{find:function(e){return nr(this,e,arguments.length>1?arguments[1]:void 0)}}),Yn(rr);var ir=xt.findIndex,or="findIndex",sr=!0;or in[]&&Array(1).findIndex((function(){sr=!1})),De({target:"Array",proto:!0,forced:sr},{findIndex:function(e){return ir(this,e,arguments.length>1?arguments[1]:void 0)}}),Yn(or);var ur=function e(t,n,r,a,i,o,s,u){for(var l,c=i,p=0,h=!!s&&mt(s,u,3);p<a;){if(p in r){if(l=h?h(r[p],p,n):r[p],o>0&&je(l))c=e(t,n,l,he(l.length),c,o-1)-1;else{if(c>=9007199254740991)throw TypeError("Exceed the acceptable array length");t[c]=l}c++}p++}return c};De({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=He(this),n=he(t.length),r=gt(t,0);return r.length=ur(r,t,t,n,0,void 0===e?1:ce(e)),r}}),De({target:"Array",proto:!0},{flatMap:function(e){var t,n=He(this),r=he(n.length);return ft(e),(t=gt(n,0)).length=ur(t,n,n,r,0,1,e,arguments.length>1?arguments[1]:void 0),t}});var lr=xt.forEach,cr=Jn("forEach")?[].forEach:function(e){return lr(this,e,arguments.length>1?arguments[1]:void 0)};De({target:"Array",proto:!0,forced:[].forEach!=cr},{forEach:cr});var pr=ge.includes;De({target:"Array",proto:!0},{includes:function(e){return pr(this,e,arguments.length>1?arguments[1]:void 0)}}),Yn("includes");var hr=ge.indexOf,dr=[].indexOf,fr=!!dr&&1/[1].indexOf(1,-0)<0,mr=Jn("indexOf");De({target:"Array",proto:!0,forced:fr||!mr},{indexOf:function(e){return fr?dr.apply(this,arguments)||0:hr(this,e,arguments.length>1?arguments[1]:void 0)}});var vr=[].join,gr=m!=Object,yr=Jn("join",",");De({target:"Array",proto:!0,forced:gr||!yr},{join:function(e){return vr.call(g(this),void 0===e?",":e)}});var br=Math.min,xr=[].lastIndexOf,wr=!!xr&&1/[1].lastIndexOf(1,-0)<0,kr=Jn("lastIndexOf"),Nr=wr||!kr?function(e){if(wr)return xr.apply(this,arguments)||0;var t=g(this),n=he(t.length),r=n-1;for(arguments.length>1&&(r=br(r,ce(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:xr;De({target:"Array",proto:!0,forced:Nr!==[].lastIndexOf},{lastIndexOf:Nr});var Ir=xt.map,Sr=Pn("map");De({target:"Array",proto:!0,forced:!Sr},{map:function(e){return Ir(this,e,arguments.length>1?arguments[1]:void 0)}});var Tr=function(e){return function(t,n,r,a){ft(n);var i=He(t),o=m(i),s=he(i.length),u=e?s-1:0,l=e?-1:1;if(r<2)for(;;){if(u in o){a=o[u],u+=l;break}if(u+=l,e?u<0:s<=u)throw TypeError("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=l)u in o&&(a=n(a,o[u],u,i));return a}},Cr={left:Tr(!1),right:Tr(!0)},Er=Cr.left,Ar=Jn("reduce");De({target:"Array",proto:!0,forced:!Ar||!Me&&Ve>79&&Ve<83},{reduce:function(e){return Er(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Rr=Cr.right,_r=Jn("reduceRight");De({target:"Array",proto:!0,forced:!_r||!Me&&Ve>79&&Ve<83},{reduceRight:function(e){return Rr(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Fr=[].reverse,Or=[1,2];De({target:"Array",proto:!0,forced:String(Or)===String(Or.reverse())},{reverse:function(){return je(this)&&(this.length=this.length),Fr.call(this)}});var Dr=Pn("slice"),Mr=st("species"),Lr=[].slice,zr=Math.max;De({target:"Array",proto:!0,forced:!Dr},{slice:function(e,t){var n,r,a,i=g(this),o=he(i.length),s=me(e,o),u=me(void 0===t?o:t,o);if(je(i)&&("function"!=typeof(n=i.constructor)||n!==Array&&!je(n.prototype)?y(n)&&null===(n=n[Mr])&&(n=void 0):n=void 0,n===Array||void 0===n))return Lr.call(i,s,u);for(r=new(void 0===n?Array:n)(zr(u-s,0)),a=0;s<u;s++,a++)s in i&&En(r,a,i[s]);return r.length=a,r}});var Pr=xt.some,Br=Jn("some");De({target:"Array",proto:!0,forced:!Br},{some:function(e){return Pr(this,e,arguments.length>1?arguments[1]:void 0)}});var Wr=[],Vr=Wr.sort,Ur=i((function(){Wr.sort(void 0)})),Gr=i((function(){Wr.sort(null)})),jr=Jn("sort");De({target:"Array",proto:!0,forced:Ur||!Gr||!jr},{sort:function(e){return void 0===e?Vr.call(He(this)):Vr.call(He(this),ft(e))}});var Hr=Pn("splice"),qr=Math.max,Kr=Math.min,Xr=9007199254740991,Yr="Maximum allowed length exceeded";De({target:"Array",proto:!0,forced:!Hr},{splice:function(e,t){var n,r,a,i,o,s,u=He(this),l=he(u.length),c=me(e,l),p=arguments.length;if(0===p?n=r=0:1===p?(n=0,r=l-c):(n=p-2,r=Kr(qr(ce(t),0),l-c)),l+n-r>Xr)throw TypeError(Yr);for(a=gt(u,r),i=0;i<r;i++)(o=c+i)in u&&En(a,i,u[o]);if(a.length=r,n<r){for(i=c;i<l-r;i++)s=i+n,(o=i+r)in u?u[s]=u[o]:delete u[s];for(i=l;i>l-r+n;i--)delete u[i-1]}else if(n>r)for(i=l-r;i>c;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+c]=arguments[i+2];return u.length=l-r+n,a}});var Jr=st("species"),Zr=function(e){var t=se(e),n=R.f;o&&t&&!t[Jr]&&n(t,Jr,{configurable:!0,get:function(){return this}})};Zr("Array"),Yn("flat"),Yn("flatMap");var Qr,$r,ea,ta=st("iterator"),na=!1;[].keys&&("next"in(ea=[].keys())?($r=ln(ln(ea)))!==Object.prototype&&(Qr=$r):na=!0);var ra=null==Qr||i((function(){var e={};return Qr[ta].call(e)!==e}));ra&&(Qr={}),w(Qr,ta)||_(Qr,ta,(function(){return this}));var aa={IteratorPrototype:Qr,BUGGY_SAFARI_ITERATORS:na},ia=aa.IteratorPrototype,oa=function(){return this},sa=function(e,t,n){var r=t+" Iterator";return e.prototype=$e(ia,{next:p(1,n)}),dt(e,r,!1),hn[r]=oa,e},ua=aa.IteratorPrototype,la=aa.BUGGY_SAFARI_ITERATORS,ca=st("iterator"),pa="keys",ha="values",da="entries",fa=function(){return this},ma=function(e,t,n,r,a,i,o){sa(n,t,r);var s,u,l,c=function(e){if(e===a&&m)return m;if(!la&&e in d)return d[e];switch(e){case pa:case ha:case da:return function(){return new n(this,e)}}return function(){return new n(this)}},p=t+" Iterator",h=!1,d=e.prototype,f=d[ca]||d["@@iterator"]||a&&d[a],m=!la&&f||c(a),v="Array"==t&&d.entries||f;if(v&&(s=ln(v.call(new e)),ua!==Object.prototype&&s.next&&(ln(s)!==ua&&(pn?pn(s,ua):"function"!=typeof s[ca]&&_(s,ca,fa)),dt(s,p,!0))),a==ha&&f&&f.name!==ha&&(h=!0,m=function(){return f.call(this)}),d[ca]!==m&&_(d,ca,m),hn[t]=m,a)if(u={values:c(ha),keys:i?m:c(pa),entries:c(da)},o)for(l in u)(la||h||!(l in d))&&ae(d,l,u[l]);else De({target:t,proto:!0,forced:la||h},u);return u},va="Array Iterator",ga=re.set,ya=re.getterFor(va),ba=ma(Array,"Array",(function(e,t){ga(this,{type:va,target:g(e),index:0,kind:t})}),(function(){var e=ya(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values");hn.Arguments=hn.Array,Yn("keys"),Yn("values"),Yn("entries");var xa=[].slice,wa={},ka=function(e,t,n){if(!(t in wa)){for(var r=[],a=0;a<t;a++)r[a]="a["+a+"]";wa[t]=Function("C,a","return new C("+r.join(",")+")")}return wa[t](e,n)},Na=Function.bind||function(e){var t=ft(this),n=xa.call(arguments,1),r=function(){var a=n.concat(xa.call(arguments));return this instanceof r?ka(t,a.length,a):t.apply(e,a)};return y(t.prototype)&&(r.prototype=t.prototype),r};De({target:"Function",proto:!0},{bind:Na});var Ia=R.f,Sa=Function.prototype,Ta=Sa.toString,Ca=/^\s*function ([^ (]*)/,Ea="name";o&&!(Ea in Sa)&&Ia(Sa,Ea,{configurable:!0,get:function(){try{return Ta.call(this).match(Ca)[1]}catch(e){return""}}});var Aa=st("hasInstance"),Ra=Function.prototype;Aa in Ra||R.f(Ra,Aa,{value:function(e){if("function"!=typeof this||!y(e))return!1;if(!y(this.prototype))return e instanceof this;for(;e=ln(e);)if(this.prototype===e)return!0;return!1}}),De({global:!0},{globalThis:a});var _a=Object.assign,Fa=Object.defineProperty,Oa=!_a||i((function(){if(o&&1!==_a({b:1},_a(Fa({},"a",{enumerable:!0,get:function(){Fa(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!=_a({},e)[n]||qe(_a({},t)).join("")!=r}))?function(e,t){for(var n=He(e),r=arguments.length,a=1,i=Ne.f,s=c.f;r>a;)for(var u,l=m(arguments[a++]),p=i?qe(l).concat(i(l)):qe(l),h=p.length,d=0;h>d;)u=p[d++],o&&!s.call(l,u)||(n[u]=l[u]);return n}:_a;De({target:"Object",stat:!0,forced:Object.assign!==Oa},{assign:Oa}),De({target:"Object",stat:!0,sham:!o},{create:$e}),De({target:"Object",stat:!0,forced:!o,sham:!o},{defineProperty:R.f}),De({target:"Object",stat:!0,forced:!o,sham:!o},{defineProperties:Ke});var Da=c.f,Ma=function(e){return function(t){for(var n,r=g(t),a=qe(r),i=a.length,s=0,u=[];i>s;)n=a[s++],o&&!Da.call(r,n)||u.push(e?[n,r[n]]:r[n]);return u}},La={entries:Ma(!0),values:Ma(!1)},za=La.entries;De({target:"Object",stat:!0},{entries:function(e){return za(e)}});var Pa=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),Ba=n((function(e){var t=R.f,n=H("meta"),r=0,a=Object.isExtensible||function(){return!0},i=function(e){t(e,n,{value:{objectID:"O"+ ++r,weakData:{}}})},o=e.exports={REQUIRED:!1,fastKey:function(e,t){if(!y(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!w(e,n)){if(!a(e))return"F";if(!t)return"E";i(e)}return e[n].objectID},getWeakData:function(e,t){if(!w(e,n)){if(!a(e))return!0;if(!t)return!1;i(e)}return e[n].weakData},onFreeze:function(e){return Pa&&o.REQUIRED&&a(e)&&!w(e,n)&&i(e),e}};X[n]=!0})),Wa=(Ba.REQUIRED,Ba.fastKey,Ba.getWeakData,Ba.onFreeze,Ba.onFreeze),Va=Object.freeze,Ua=i((function(){Va(1)}));De({target:"Object",stat:!0,forced:Ua,sham:!Pa},{freeze:function(e){return Va&&y(e)?Va(Wa(e)):e}}),De({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Sn(e,(function(e,n){En(t,e,n)}),{AS_ENTRIES:!0}),t}});var Ga=C.f,ja=i((function(){Ga(1)}));De({target:"Object",stat:!0,forced:!o||ja,sham:!o},{getOwnPropertyDescriptor:function(e,t){return Ga(g(e),t)}}),De({target:"Object",stat:!0,sham:!o},{getOwnPropertyDescriptors:function(e){for(var t,n,r=g(e),a=C.f,i=Ie(r),o={},s=0;i.length>s;)void 0!==(n=a(r,t=i[s++]))&&En(o,t,n);return o}});var Ha=rt.f,qa=i((function(){return!Object.getOwnPropertyNames(1)}));De({target:"Object",stat:!0,forced:qa},{getOwnPropertyNames:Ha});var Ka=i((function(){ln(1)}));De({target:"Object",stat:!0,forced:Ka,sham:!on},{getPrototypeOf:function(e){return ln(He(e))}});var Xa=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t};De({target:"Object",stat:!0},{is:Xa});var Ya=Object.isExtensible,Ja=i((function(){Ya(1)}));De({target:"Object",stat:!0,forced:Ja},{isExtensible:function(e){return!!y(e)&&(!Ya||Ya(e))}});var Za=Object.isFrozen,Qa=i((function(){Za(1)}));De({target:"Object",stat:!0,forced:Qa},{isFrozen:function(e){return!y(e)||!!Za&&Za(e)}});var $a=Object.isSealed,ei=i((function(){$a(1)}));De({target:"Object",stat:!0,forced:ei},{isSealed:function(e){return!y(e)||!!$a&&$a(e)}});var ti=i((function(){qe(1)}));De({target:"Object",stat:!0,forced:ti},{keys:function(e){return qe(He(e))}});var ni=Ba.onFreeze,ri=Object.preventExtensions,ai=i((function(){ri(1)}));De({target:"Object",stat:!0,forced:ai,sham:!Pa},{preventExtensions:function(e){return ri&&y(e)?ri(ni(e)):e}});var ii=Ba.onFreeze,oi=Object.seal,si=i((function(){oi(1)}));De({target:"Object",stat:!0,forced:si,sham:!Pa},{seal:function(e){return oi&&y(e)?oi(ii(e)):e}}),De({target:"Object",stat:!0},{setPrototypeOf:pn});var ui=La.values;De({target:"Object",stat:!0},{values:function(e){return ui(e)}});var li=gn?{}.toString:function(){return"[object "+xn(this)+"]"};gn||ae(Object.prototype,"toString",li,{unsafe:!0});var ci=!i((function(){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete a[e]}));o&&De({target:"Object",proto:!0,forced:ci},{__defineGetter__:function(e,t){R.f(He(this),e,{get:ft(t),enumerable:!0,configurable:!0})}}),o&&De({target:"Object",proto:!0,forced:ci},{__defineSetter__:function(e,t){R.f(He(this),e,{set:ft(t),enumerable:!0,configurable:!0})}});var pi=C.f;o&&De({target:"Object",proto:!0,forced:ci},{__lookupGetter__:function(e){var t,n=He(this),r=b(e,!0);do{if(t=pi(n,r))return t.get}while(n=ln(n))}});var hi=C.f;o&&De({target:"Object",proto:!0,forced:ci},{__lookupSetter__:function(e){var t,n=He(this),r=b(e,!0);do{if(t=hi(n,r))return t.set}while(n=ln(n))}});var di=String.fromCharCode,fi=String.fromCodePoint,mi=!!fi&&1!=fi.length;De({target:"String",stat:!0,forced:mi},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,a=0;r>a;){if(t=+arguments[a++],me(t,1114111)!==t)throw RangeError(t+" is not a valid code point");n.push(t<65536?di(t):di(55296+((t-=65536)>>10),t%1024+56320))}return n.join("")}}),De({target:"String",stat:!0},{raw:function(e){for(var t=g(e.raw),n=he(t.length),r=arguments.length,a=[],i=0;n>i;)a.push(String(t[i++])),i<r&&a.push(String(arguments[i]));return a.join("")}});var vi=function(e){return function(t,n){var r,a,i=String(v(t)),o=ce(n),s=i.length;return o<0||o>=s?e?"":void 0:(r=i.charCodeAt(o))<55296||r>56319||o+1===s||(a=i.charCodeAt(o+1))<56320||a>57343?e?i.charAt(o):r:e?i.slice(o,o+2):a-56320+(r-55296<<10)+65536}},gi={codeAt:vi(!1),charAt:vi(!0)},yi=gi.codeAt;De({target:"String",proto:!0},{codePointAt:function(e){return yi(this,e)}});var bi,xi=st("match"),wi=function(e){var t;return y(e)&&(void 0!==(t=e[xi])?!!t:"RegExp"==d(e))},ki=function(e){if(wi(e))throw TypeError("The method doesn't accept regular expressions");return e},Ni=st("match"),Ii=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[Ni]=!1,"/./"[e](t)}catch(e){}}return!1},Si=C.f,Ti="".endsWith,Ci=Math.min,Ei=Ii("endsWith"),Ai=!(Ei||(bi=Si(String.prototype,"endsWith"),!bi||bi.writable));De({target:"String",proto:!0,forced:!Ai&&!Ei},{endsWith:function(e){var t=String(v(this));ki(e);var n=arguments.length>1?arguments[1]:void 0,r=he(t.length),a=void 0===n?r:Ci(he(n),r),i=String(e);return Ti?Ti.call(t,i,a):t.slice(a-i.length,a)===i}}),De({target:"String",proto:!0,forced:!Ii("includes")},{includes:function(e){return!!~String(v(this)).indexOf(ki(e),arguments.length>1?arguments[1]:void 0)}});var Ri=function(){var e=E(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t};function _i(e,t){return RegExp(e,t)}var Fi=i((function(){var e=_i("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),Oi=i((function(){var e=_i("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),Di={UNSUPPORTED_Y:Fi,BROKEN_CARET:Oi},Mi=RegExp.prototype.exec,Li=String.prototype.replace,zi=Mi,Pi=function(){var e=/a/,t=/b*/g;return Mi.call(e,"a"),Mi.call(t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),Bi=Di.UNSUPPORTED_Y||Di.BROKEN_CARET,Wi=void 0!==/()??/.exec("")[1];(Pi||Wi||Bi)&&(zi=function(e){var t,n,r,a,i=this,o=Bi&&i.sticky,s=Ri.call(i),u=i.source,l=0,c=e;return o&&(-1===(s=s.replace("y","")).indexOf("g")&&(s+="g"),c=String(e).slice(i.lastIndex),i.lastIndex>0&&(!i.multiline||i.multiline&&"\n"!==e[i.lastIndex-1])&&(u="(?: "+u+")",c=" "+c,l++),n=new RegExp("^(?:"+u+")",s)),Wi&&(n=new RegExp("^"+u+"$(?!\\s)",s)),Pi&&(t=i.lastIndex),r=Mi.call(o?n:i,c),o?r?(r.input=r.input.slice(l),r[0]=r[0].slice(l),r.index=i.lastIndex,i.lastIndex+=r[0].length):i.lastIndex=0:Pi&&r&&(i.lastIndex=i.global?r.index+r[0].length:t),Wi&&r&&r.length>1&&Li.call(r[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(r[a]=void 0)})),r});var Vi=zi;De({target:"RegExp",proto:!0,forced:/./.exec!==Vi},{exec:Vi});var Ui=st("species"),Gi=!i((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")})),ji="$0"==="a".replace(/./,"$0"),Hi=st("replace"),qi=!!/./[Hi]&&""===/./[Hi]("a","$0"),Ki=!i((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),Xi=function(e,t,n,r){var a=st(e),o=!i((function(){var t={};return t[a]=function(){return 7},7!=""[e](t)})),s=o&&!i((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Ui]=function(){return n},n.flags="",n[a]=/./[a]),n.exec=function(){return t=!0,null},n[a](""),!t}));if(!o||!s||"replace"===e&&(!Gi||!ji||qi)||"split"===e&&!Ki){var u=/./[a],l=n(a,""[e],(function(e,t,n,r,a){return t.exec===Vi?o&&!a?{done:!0,value:u.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}),{REPLACE_KEEPS_$0:ji,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:qi}),c=l[0],p=l[1];ae(String.prototype,e,c),ae(RegExp.prototype,a,2==t?function(e,t){return p.call(e,this,t)}:function(e){return p.call(e,this)})}r&&_(RegExp.prototype[a],"sham",!0)},Yi=gi.charAt,Ji=function(e,t,n){return t+(n?Yi(e,t).length:1)},Zi=function(e,t){var n=e.exec;if("function"==typeof n){var r=n.call(e,t);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==d(e))throw TypeError("RegExp#exec called on incompatible receiver");return Vi.call(e,t)};Xi("match",1,(function(e,t,n){return[function(t){var n=v(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](String(n))},function(e){var r=n(t,e,this);if(r.done)return r.value;var a=E(e),i=String(this);if(!a.global)return Zi(a,i);var o=a.unicode;a.lastIndex=0;for(var s,u=[],l=0;null!==(s=Zi(a,i));){var c=String(s[0]);u[l]=c,""===c&&(a.lastIndex=Ji(i,he(a.lastIndex),o)),l++}return 0===l?null:u}]}));var Qi=st("species"),$i=function(e,t){var n,r=E(e).constructor;return void 0===r||null==(n=E(r)[Qi])?t:ft(n)},eo=st("matchAll"),to="RegExp String",no="RegExp String Iterator",ro=re.set,ao=re.getterFor(no),io=RegExp.prototype,oo=io.exec,so="".matchAll,uo=!!so&&!i((function(){"a".matchAll(/./)})),lo=sa((function(e,t,n,r){ro(this,{type:no,regexp:e,string:t,global:n,unicode:r,done:!1})}),to,(function(){var e=ao(this);if(e.done)return{value:void 0,done:!0};var t=e.regexp,n=e.string,r=function(e,t){var n,r=e.exec;if("function"==typeof r){if("object"!=typeof(n=r.call(e,t)))throw TypeError("Incorrect exec result");return n}return oo.call(e,t)}(t,n);return null===r?{value:void 0,done:e.done=!0}:e.global?(""==String(r[0])&&(t.lastIndex=Ji(n,he(t.lastIndex),e.unicode)),{value:r,done:!1}):(e.done=!0,{value:r,done:!1})})),co=function(e){var t,n,r,a,i,o,s=E(this),u=String(e);return t=$i(s,RegExp),void 0===(n=s.flags)&&s instanceof RegExp&&!("flags"in io)&&(n=Ri.call(s)),r=void 0===n?"":String(n),a=new t(t===RegExp?s.source:s,r),i=!!~r.indexOf("g"),o=!!~r.indexOf("u"),a.lastIndex=he(s.lastIndex),new lo(a,u,i,o)};De({target:"String",proto:!0,forced:uo},{matchAll:function(e){var t,n,r=v(this);if(null!=e){if(wi(e)&&!~String(v("flags"in io?e.flags:Ri.call(e))).indexOf("g"))throw TypeError("`.matchAll` does not allow non-global regexes");if(uo)return so.apply(r,arguments);if(null!=(n=e[eo]))return ft(n).call(e,r)}else if(uo)return so.apply(r,arguments);return t=String(r),new RegExp(e,"g")[eo](t)}}),eo in io||_(io,eo,co);var po="".repeat||function(e){var t=String(v(this)),n="",r=ce(e);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},ho=Math.ceil,fo=function(e){return function(t,n,r){var a,i,o=String(v(t)),s=o.length,u=void 0===r?" ":String(r),l=he(n);return l<=s||""==u?o:(a=l-s,(i=po.call(u,ho(a/u.length))).length>a&&(i=i.slice(0,a)),e?o+i:i+o)}},mo={start:fo(!1),end:fo(!0)},vo=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(Le),go=mo.end;De({target:"String",proto:!0,forced:vo},{padEnd:function(e){return go(this,e,arguments.length>1?arguments[1]:void 0)}});var yo=mo.start;De({target:"String",proto:!0,forced:vo},{padStart:function(e){return yo(this,e,arguments.length>1?arguments[1]:void 0)}}),De({target:"String",proto:!0},{repeat:po});var bo=Math.floor,xo="".replace,wo=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,ko=/\$([$&'`]|\d{1,2})/g,No=function(e,t,n,r,a,i){var o=n+e.length,s=r.length,u=ko;return void 0!==a&&(a=He(a),u=wo),xo.call(i,u,(function(i,u){var l;switch(u.charAt(0)){case"$":return"$";case"&":return e;case"`":return t.slice(0,n);case"'":return t.slice(o);case"<":l=a[u.slice(1,-1)];break;default:var c=+u;if(0===c)return i;if(c>s){var p=bo(c/10);return 0===p?i:p<=s?void 0===r[p-1]?u.charAt(1):r[p-1]+u.charAt(1):i}l=r[c-1]}return void 0===l?"":l}))},Io=Math.max,So=Math.min;Xi("replace",2,(function(e,t,n,r){var a=r.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,i=r.REPLACE_KEEPS_$0,o=a?"$":"$0";return[function(n,r){var a=v(this),i=null==n?void 0:n[e];return void 0!==i?i.call(n,a,r):t.call(String(a),n,r)},function(e,r){if(!a&&i||"string"==typeof r&&-1===r.indexOf(o)){var s=n(t,e,this,r);if(s.done)return s.value}var u=E(e),l=String(this),c="function"==typeof r;c||(r=String(r));var p=u.global;if(p){var h=u.unicode;u.lastIndex=0}for(var d=[];;){var f=Zi(u,l);if(null===f)break;if(d.push(f),!p)break;""===String(f[0])&&(u.lastIndex=Ji(l,he(u.lastIndex),h))}for(var m,v="",g=0,y=0;y<d.length;y++){f=d[y];for(var b=String(f[0]),x=Io(So(ce(f.index),l.length),0),w=[],k=1;k<f.length;k++)w.push(void 0===(m=f[k])?m:String(m));var N=f.groups;if(c){var I=[b].concat(w,x,l);void 0!==N&&I.push(N);var S=String(r.apply(void 0,I))}else S=No(b,l,x,w,N,r);x>=g&&(v+=l.slice(g,x)+S,g=x+b.length)}return v+l.slice(g)}]})),Xi("search",1,(function(e,t,n){return[function(t){var n=v(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](String(n))},function(e){var r=n(t,e,this);if(r.done)return r.value;var a=E(e),i=String(this),o=a.lastIndex;Xa(o,0)||(a.lastIndex=0);var s=Zi(a,i);return Xa(a.lastIndex,o)||(a.lastIndex=o),null===s?-1:s.index}]}));var To=[].push,Co=Math.min,Eo=4294967295,Ao=!i((function(){return!RegExp(Eo,"y")}));Xi("split",2,(function(e,t,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(e,n){var r=String(v(this)),a=void 0===n?Eo:n>>>0;if(0===a)return[];if(void 0===e)return[r];if(!wi(e))return t.call(r,e,a);for(var i,o,s,u=[],l=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),c=0,p=new RegExp(e.source,l+"g");(i=Vi.call(p,r))&&!((o=p.lastIndex)>c&&(u.push(r.slice(c,i.index)),i.length>1&&i.index<r.length&&To.apply(u,i.slice(1)),s=i[0].length,c=o,u.length>=a));)p.lastIndex===i.index&&p.lastIndex++;return c===r.length?!s&&p.test("")||u.push(""):u.push(r.slice(c)),u.length>a?u.slice(0,a):u}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t.call(this,e,n)}:t,[function(t,n){var a=v(this),i=null==t?void 0:t[e];return void 0!==i?i.call(t,a,n):r.call(String(a),t,n)},function(e,a){var i=n(r,e,this,a,r!==t);if(i.done)return i.value;var o=E(e),s=String(this),u=$i(o,RegExp),l=o.unicode,c=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(Ao?"y":"g"),p=new u(Ao?o:"^(?:"+o.source+")",c),h=void 0===a?Eo:a>>>0;if(0===h)return[];if(0===s.length)return null===Zi(p,s)?[s]:[];for(var d=0,f=0,m=[];f<s.length;){p.lastIndex=Ao?f:0;var v,g=Zi(p,Ao?s:s.slice(f));if(null===g||(v=Co(he(p.lastIndex+(Ao?0:f)),s.length))===d)f=Ji(s,f,l);else{if(m.push(s.slice(d,f)),m.length===h)return m;for(var y=1;y<=g.length-1;y++)if(m.push(g[y]),m.length===h)return m;f=d=v}}return m.push(s.slice(d)),m}]}),!Ao);var Ro=C.f,_o="".startsWith,Fo=Math.min,Oo=Ii("startsWith"),Do=!Oo&&!!function(){var e=Ro(String.prototype,"startsWith");return e&&!e.writable}();De({target:"String",proto:!0,forced:!Do&&!Oo},{startsWith:function(e){var t=String(v(this));ki(e);var n=he(Fo(arguments.length>1?arguments[1]:void 0,t.length)),r=String(e);return _o?_o.call(t,r,n):t.slice(n,n+r.length)===r}});var Mo="\t\n\v\f\r    \u2028\u2029\ufeff",Lo="["+Mo+"]",zo=RegExp("^"+Lo+Lo+"*"),Po=RegExp(Lo+Lo+"*$"),Bo=function(e){return function(t){var n=String(v(t));return 1&e&&(n=n.replace(zo,"")),2&e&&(n=n.replace(Po,"")),n}},Wo={start:Bo(1),end:Bo(2),trim:Bo(3)},Vo=function(e){return i((function(){return!!Mo[e]()||"…"!="…"[e]()||Mo[e].name!==e}))},Uo=Wo.trim;De({target:"String",proto:!0,forced:Vo("trim")},{trim:function(){return Uo(this)}});var Go=Wo.start,jo=Vo("trimStart"),Ho=jo?function(){return Go(this)}:"".trimStart;De({target:"String",proto:!0,forced:jo},{trimStart:Ho,trimLeft:Ho});var qo=Wo.end,Ko=Vo("trimEnd"),Xo=Ko?function(){return qo(this)}:"".trimEnd;De({target:"String",proto:!0,forced:Ko},{trimEnd:Xo,trimRight:Xo});var Yo=gi.charAt,Jo="String Iterator",Zo=re.set,Qo=re.getterFor(Jo);ma(String,"String",(function(e){Zo(this,{type:Jo,string:String(e),index:0})}),(function(){var e,t=Qo(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=Yo(n,r),t.index+=e.length,{value:e,done:!1})}));var $o=/"/g,es=function(e,t,n,r){var a=String(v(e)),i="<"+t;return""!==n&&(i+=" "+n+'="'+String(r).replace($o,"&quot;")+'"'),i+">"+a+"</"+t+">"},ts=function(e){return i((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))};De({target:"String",proto:!0,forced:ts("anchor")},{anchor:function(e){return es(this,"a","name",e)}}),De({target:"String",proto:!0,forced:ts("big")},{big:function(){return es(this,"big","","")}}),De({target:"String",proto:!0,forced:ts("blink")},{blink:function(){return es(this,"blink","","")}}),De({target:"String",proto:!0,forced:ts("bold")},{bold:function(){return es(this,"b","","")}}),De({target:"String",proto:!0,forced:ts("fixed")},{fixed:function(){return es(this,"tt","","")}}),De({target:"String",proto:!0,forced:ts("fontcolor")},{fontcolor:function(e){return es(this,"font","color",e)}}),De({target:"String",proto:!0,forced:ts("fontsize")},{fontsize:function(e){return es(this,"font","size",e)}}),De({target:"String",proto:!0,forced:ts("italics")},{italics:function(){return es(this,"i","","")}}),De({target:"String",proto:!0,forced:ts("link")},{link:function(e){return es(this,"a","href",e)}}),De({target:"String",proto:!0,forced:ts("small")},{small:function(){return es(this,"small","","")}}),De({target:"String",proto:!0,forced:ts("strike")},{strike:function(){return es(this,"strike","","")}}),De({target:"String",proto:!0,forced:ts("sub")},{sub:function(){return es(this,"sub","","")}}),De({target:"String",proto:!0,forced:ts("sup")},{sup:function(){return es(this,"sup","","")}});var ns=st("replace"),rs=RegExp.prototype,as=Math.max,is=function(e,t,n){return n>e.length?-1:""===t?n:e.indexOf(t,n)};De({target:"String",proto:!0},{replaceAll:function(e,t){var n,r,a,i,o,s,u,l=v(this),c=0,p=0,h="";if(null!=e){if(wi(e)&&!~String(v("flags"in rs?e.flags:Ri.call(e))).indexOf("g"))throw TypeError("`.replaceAll` does not allow non-global regexes");if(void 0!==(n=e[ns]))return n.call(e,l,t)}for(r=String(l),a=String(e),(i="function"==typeof t)||(t=String(t)),o=a.length,s=as(1,o),c=is(r,a,0);-1!==c;)u=i?String(t(a,c,r)):No(a,r,c,[],void 0,t),h+=r.slice(p,c)+u,p=c+o,c=is(r,a,c+s);return p<r.length&&(h+=r.slice(p)),h}});var os=function(e,t,n){var r,a;return pn&&"function"==typeof(r=t.constructor)&&r!==n&&y(a=r.prototype)&&a!==n.prototype&&pn(e,a),e},ss=R.f,us=ke.f,ls=re.set,cs=st("match"),ps=a.RegExp,hs=ps.prototype,ds=/a/g,fs=/a/g,ms=new ps(ds)!==ds,vs=Di.UNSUPPORTED_Y;if(o&&Fe("RegExp",!ms||vs||i((function(){return fs[cs]=!1,ps(ds)!=ds||ps(fs)==fs||"/a/i"!=ps(ds,"i")})))){for(var gs=function(e,t){var n,r=this instanceof gs,a=wi(e),i=void 0===t;if(!r&&a&&e.constructor===gs&&i)return e;ms?a&&!i&&(e=e.source):e instanceof gs&&(i&&(t=Ri.call(e)),e=e.source),vs&&(n=!!t&&t.indexOf("y")>-1)&&(t=t.replace(/y/g,""));var o=os(ms?new ps(e,t):ps(e,t),r?this:hs,gs);return vs&&n&&ls(o,{sticky:n}),o},ys=function(e){e in gs||ss(gs,e,{configurable:!0,get:function(){return ps[e]},set:function(t){ps[e]=t}})},bs=us(ps),xs=0;bs.length>xs;)ys(bs[xs++]);hs.constructor=gs,gs.prototype=hs,ae(a,"RegExp",gs)}Zr("RegExp"),o&&("g"!=/./g.flags||Di.UNSUPPORTED_Y)&&R.f(RegExp.prototype,"flags",{configurable:!0,get:Ri});var ws=Di.UNSUPPORTED_Y,ks=R.f,Ns=re.get,Is=RegExp.prototype;o&&ws&&ks(RegExp.prototype,"sticky",{configurable:!0,get:function(){if(this!==Is){if(this instanceof RegExp)return!!Ns(this).sticky;throw TypeError("Incompatible receiver, RegExp required")}}});var Ss=function(){var e=!1,t=/[ac]/;return t.exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e}(),Ts=/./.test;De({target:"RegExp",proto:!0,forced:!Ss},{test:function(e){if("function"!=typeof this.exec)return Ts.call(this,e);var t=this.exec(e);if(null!==t&&!y(t))throw new Error("RegExp exec method returned something other than an Object or null");return!!t}});var Cs="toString",Es=RegExp.prototype,As=Es.toString,Rs=i((function(){return"/a/b"!=As.call({source:"a",flags:"b"})})),_s=As.name!=Cs;(Rs||_s)&&ae(RegExp.prototype,Cs,(function(){var e=E(this),t=String(e.source),n=e.flags;return"/"+t+"/"+String(void 0===n&&e instanceof RegExp&&!("flags"in Es)?Ri.call(e):n)}),{unsafe:!0});var Fs=Wo.trim,Os=a.parseInt,Ds=/^[+-]?0[Xx]/,Ms=8!==Os(Mo+"08")||22!==Os(Mo+"0x16")?function(e,t){var n=Fs(String(e));return Os(n,t>>>0||(Ds.test(n)?16:10))}:Os;De({global:!0,forced:parseInt!=Ms},{parseInt:Ms});var Ls=Wo.trim,zs=a.parseFloat,Ps=1/zs(Mo+"-0")!=-1/0?function(e){var t=Ls(String(e)),n=zs(t);return 0===n&&"-"==t.charAt(0)?-0:n}:zs;De({global:!0,forced:parseFloat!=Ps},{parseFloat:Ps});var Bs=ke.f,Ws=C.f,Vs=R.f,Us=Wo.trim,Gs="Number",js=a.Number,Hs=js.prototype,qs=d($e(Hs))==Gs,Ks=function(e){var t,n,r,a,i,o,s,u,l=b(e,!1);if("string"==typeof l&&l.length>2)if(43===(t=(l=Us(l)).charCodeAt(0))||45===t){if(88===(n=l.charCodeAt(2))||120===n)return NaN}else if(48===t){switch(l.charCodeAt(1)){case 66:case 98:r=2,a=49;break;case 79:case 111:r=8,a=55;break;default:return+l}for(o=(i=l.slice(2)).length,s=0;s<o;s++)if((u=i.charCodeAt(s))<48||u>a)return NaN;return parseInt(i,r)}return+l};if(Fe(Gs,!js(" 0o1")||!js("0b1")||js("+0x1"))){for(var Xs,Ys=function(e){var t=arguments.length<1?0:e,n=this;return n instanceof Ys&&(qs?i((function(){Hs.valueOf.call(n)})):d(n)!=Gs)?os(new js(Ks(t)),n,Ys):Ks(t)},Js=o?Bs(js):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,fromString,range".split(","),Zs=0;Js.length>Zs;Zs++)w(js,Xs=Js[Zs])&&!w(Ys,Xs)&&Vs(Ys,Xs,Ws(js,Xs));Ys.prototype=Hs,Hs.constructor=Ys,ae(a,Gs,Ys)}De({target:"Number",stat:!0},{EPSILON:Math.pow(2,-52)});var Qs=a.isFinite,$s=Number.isFinite||function(e){return"number"==typeof e&&Qs(e)};De({target:"Number",stat:!0},{isFinite:$s});var eu=Math.floor,tu=function(e){return!y(e)&&isFinite(e)&&eu(e)===e};De({target:"Number",stat:!0},{isInteger:tu}),De({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var nu=Math.abs;De({target:"Number",stat:!0},{isSafeInteger:function(e){return tu(e)&&nu(e)<=9007199254740991}}),De({target:"Number",stat:!0},{MAX_SAFE_INTEGER:9007199254740991}),De({target:"Number",stat:!0},{MIN_SAFE_INTEGER:-9007199254740991}),De({target:"Number",stat:!0,forced:Number.parseFloat!=Ps},{parseFloat:Ps}),De({target:"Number",stat:!0,forced:Number.parseInt!=Ms},{parseInt:Ms});var ru=function(e){if("number"!=typeof e&&"Number"!=d(e))throw TypeError("Incorrect invocation");return+e},au=1..toFixed,iu=Math.floor,ou=function e(t,n,r){return 0===n?r:n%2==1?e(t,n-1,r*t):e(t*t,n/2,r)},su=function(e,t,n){for(var r=-1,a=n;++r<6;)a+=t*e[r],e[r]=a%1e7,a=iu(a/1e7)},uu=function(e,t){for(var n=6,r=0;--n>=0;)r+=e[n],e[n]=iu(r/t),r=r%t*1e7},lu=function(e){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==e[t]){var r=String(e[t]);n=""===n?r:n+po.call("0",7-r.length)+r}return n},cu=au&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!i((function(){au.call({})}));De({target:"Number",proto:!0,forced:cu},{toFixed:function(e){var t,n,r,a,i=ru(this),o=ce(e),s=[0,0,0,0,0,0],u="",l="0";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=(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(i*ou(2,69,1))-69)<0?i*ou(2,-t,1):i/ou(2,t,1),n*=4503599627370496,(t=52-t)>0){for(su(s,0,n),r=o;r>=7;)su(s,1e7,0),r-=7;for(su(s,ou(10,r,1),0),r=t-1;r>=23;)uu(s,1<<23),r-=23;uu(s,1<<r),su(s,1,1),uu(s,2),l=lu(s)}else su(s,0,n),su(s,1<<-t,0),l=lu(s)+po.call("0",o);return l=o>0?u+((a=l.length)<=o?"0."+po.call("0",o-a)+l:l.slice(0,a-o)+"."+l.slice(a-o)):u+l}});var pu=1..toPrecision,hu=i((function(){return"1"!==pu.call(1,void 0)}))||!i((function(){pu.call({})}));De({target:"Number",proto:!0,forced:hu},{toPrecision:function(e){return void 0===e?pu.call(ru(this)):pu.call(ru(this),e)}});var du=Math.log,fu=Math.log1p||function(e){return(e=+e)>-1e-8&&e<1e-8?e-e*e/2:du(1+e)},mu=Math.acosh,vu=Math.log,gu=Math.sqrt,yu=Math.LN2,bu=!mu||710!=Math.floor(mu(Number.MAX_VALUE))||mu(1/0)!=1/0;De({target:"Math",stat:!0,forced:bu},{acosh:function(e){return(e=+e)<1?NaN:e>94906265.62425156?vu(e)+yu:fu(e-1+gu(e-1)*gu(e+1))}});var xu=Math.asinh,wu=Math.log,ku=Math.sqrt;De({target:"Math",stat:!0,forced:!(xu&&1/xu(0)>0)},{asinh:function e(t){return isFinite(t=+t)&&0!=t?t<0?-e(-t):wu(t+ku(t*t+1)):t}});var Nu=Math.atanh,Iu=Math.log;De({target:"Math",stat:!0,forced:!(Nu&&1/Nu(-0)<0)},{atanh:function(e){return 0==(e=+e)?e:Iu((1+e)/(1-e))/2}});var Su=Math.sign||function(e){return 0==(e=+e)||e!=e?e:e<0?-1:1},Tu=Math.abs,Cu=Math.pow;De({target:"Math",stat:!0},{cbrt:function(e){return Su(e=+e)*Cu(Tu(e),1/3)}});var Eu=Math.floor,Au=Math.log,Ru=Math.LOG2E;De({target:"Math",stat:!0},{clz32:function(e){return(e>>>=0)?31-Eu(Au(e+.5)*Ru):32}});var _u=Math.expm1,Fu=Math.exp,Ou=!_u||_u(10)>22025.465794806718||_u(10)<22025.465794806718||-2e-17!=_u(-2e-17)?function(e){return 0==(e=+e)?e:e>-1e-6&&e<1e-6?e+e*e/2:Fu(e)-1}:_u,Du=Math.cosh,Mu=Math.abs,Lu=Math.E;De({target:"Math",stat:!0,forced:!Du||Du(710)===1/0},{cosh:function(e){var t=Ou(Mu(e)-1)+1;return(t+1/(t*Lu*Lu))*(Lu/2)}}),De({target:"Math",stat:!0,forced:Ou!=Math.expm1},{expm1:Ou});var zu=Math.abs,Pu=Math.pow,Bu=Pu(2,-52),Wu=Pu(2,-23),Vu=Pu(2,127)*(2-Wu),Uu=Pu(2,-126),Gu=Math.fround||function(e){var t,n,r=zu(e),a=Su(e);return r<Uu?a*(r/Uu/Wu+1/Bu-1/Bu)*Uu*Wu:(n=(t=(1+Wu/Bu)*r)-(t-r))>Vu||n!=n?a*(1/0):a*n};De({target:"Math",stat:!0},{fround:Gu});var ju=Math.hypot,Hu=Math.abs,qu=Math.sqrt,Ku=!!ju&&ju(1/0,NaN)!==1/0;De({target:"Math",stat:!0,forced:Ku},{hypot:function(e,t){for(var n,r,a=0,i=0,o=arguments.length,s=0;i<o;)s<(n=Hu(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*qu(a)}});var Xu=Math.imul,Yu=i((function(){return-5!=Xu(4294967295,5)||2!=Xu.length}));De({target:"Math",stat:!0,forced:Yu},{imul:function(e,t){var n=65535,r=+e,a=+t,i=n&r,o=n&a;return 0|i*o+((n&r>>>16)*o+i*(n&a>>>16)<<16>>>0)}});var Ju=Math.log,Zu=Math.LOG10E;De({target:"Math",stat:!0},{log10:function(e){return Ju(e)*Zu}}),De({target:"Math",stat:!0},{log1p:fu});var Qu=Math.log,$u=Math.LN2;De({target:"Math",stat:!0},{log2:function(e){return Qu(e)/$u}}),De({target:"Math",stat:!0},{sign:Su});var el=Math.abs,tl=Math.exp,nl=Math.E,rl=i((function(){return-2e-17!=Math.sinh(-2e-17)}));De({target:"Math",stat:!0,forced:rl},{sinh:function(e){return el(e=+e)<1?(Ou(e)-Ou(-e))/2:(tl(e-1)-tl(-e-1))*(nl/2)}});var al=Math.exp;De({target:"Math",stat:!0},{tanh:function(e){var t=Ou(e=+e),n=Ou(-e);return t==1/0?1:n==1/0?-1:(t-n)/(al(e)+al(-e))}}),dt(Math,"Math",!0);var il=Math.ceil,ol=Math.floor;De({target:"Math",stat:!0},{trunc:function(e){return(e>0?ol:il)(e)}}),De({target:"Date",stat:!0},{now:function(){return(new Date).getTime()}});var sl=i((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}));De({target:"Date",proto:!0,forced:sl},{toJSON:function(e){var t=He(this),n=b(t);return"number"!=typeof n||isFinite(n)?t.toISOString():null}});var ul=mo.start,ll=Math.abs,cl=Date.prototype,pl=cl.getTime,hl=cl.toISOString,dl=i((function(){return"0385-07-25T07:06:39.999Z"!=hl.call(new Date(-50000000000001))}))||!i((function(){hl.call(new Date(NaN))}))?function(){if(!isFinite(pl.call(this)))throw RangeError("Invalid time value");var e=this,t=e.getUTCFullYear(),n=e.getUTCMilliseconds(),r=t<0?"-":t>9999?"+":"";return r+ul(ll(t),r?6:4,0)+"-"+ul(e.getUTCMonth()+1,2,0)+"-"+ul(e.getUTCDate(),2,0)+"T"+ul(e.getUTCHours(),2,0)+":"+ul(e.getUTCMinutes(),2,0)+":"+ul(e.getUTCSeconds(),2,0)+"."+ul(n,3,0)+"Z"}:hl;De({target:"Date",proto:!0,forced:Date.prototype.toISOString!==dl},{toISOString:dl});var fl=Date.prototype,ml="Invalid Date",vl="toString",gl=fl.toString,yl=fl.getTime;new Date(NaN)+""!=ml&&ae(fl,vl,(function(){var e=yl.call(this);return e==e?gl.call(this):ml}));var bl=st("toPrimitive"),xl=Date.prototype;bl in xl||_(xl,bl,(function(e){if("string"!==e&&"number"!==e&&"default"!==e)throw TypeError("Incorrect hint");return b(E(this),"number"!==e)}));var wl=se("JSON","stringify"),kl=/[\uD800-\uDFFF]/g,Nl=/^[\uD800-\uDBFF]$/,Il=/^[\uDC00-\uDFFF]$/,Sl=function(e,t,n){var r=n.charAt(t-1),a=n.charAt(t+1);return Nl.test(e)&&!Il.test(a)||Il.test(e)&&!Nl.test(r)?"\\u"+e.charCodeAt(0).toString(16):e},Tl=i((function(){return'"\\udf06\\ud834"'!==wl("\udf06\ud834")||'"\\udead"'!==wl("\udead")}));wl&&De({target:"JSON",stat:!0,forced:Tl},{stringify:function(e,t,n){var r=wl.apply(null,arguments);return"string"==typeof r?r.replace(kl,Sl):r}}),dt(a.JSON,"JSON",!0);var Cl,El,Al,Rl=a.Promise,_l=function(e,t,n){for(var r in t)ae(e,r,t[r],n);return e},Fl=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},Ol=/(iphone|ipod|ipad).*applewebkit/i.test(Le),Dl=a.location,Ml=a.setImmediate,Ll=a.clearImmediate,zl=a.process,Pl=a.MessageChannel,Bl=a.Dispatch,Wl=0,Vl={},Ul="onreadystatechange",Gl=function(e){if(Vl.hasOwnProperty(e)){var t=Vl[e];delete Vl[e],t()}},jl=function(e){return function(){Gl(e)}},Hl=function(e){Gl(e.data)},ql=function(e){a.postMessage(e+"",Dl.protocol+"//"+Dl.host)};Ml&&Ll||(Ml=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return Vl[++Wl]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},Cl(Wl),Wl},Ll=function(e){delete Vl[e]},Me?Cl=function(e){zl.nextTick(jl(e))}:Bl&&Bl.now?Cl=function(e){Bl.now(jl(e))}:Pl&&!Ol?(Al=(El=new Pl).port2,El.port1.onmessage=Hl,Cl=mt(Al.postMessage,Al,1)):a.addEventListener&&"function"==typeof postMessage&&!a.importScripts&&Dl&&"file:"!==Dl.protocol&&!i(ql)?(Cl=ql,a.addEventListener("message",Hl,!1)):Cl=Ul in I("script")?function(e){Xe.appendChild(I("script")).onreadystatechange=function(){Xe.removeChild(this),Gl(e)}}:function(e){setTimeout(jl(e),0)});var Kl,Xl,Yl,Jl,Zl,Ql,$l,ec,tc={set:Ml,clear:Ll},nc=/web0s(?!.*chrome)/i.test(Le),rc=C.f,ac=tc.set,ic=a.MutationObserver||a.WebKitMutationObserver,oc=a.document,sc=a.process,uc=a.Promise,lc=rc(a,"queueMicrotask"),cc=lc&&lc.value;cc||(Kl=function(){var e,t;for(Me&&(e=sc.domain)&&e.exit();Xl;){t=Xl.fn,Xl=Xl.next;try{t()}catch(e){throw Xl?Jl():Yl=void 0,e}}Yl=void 0,e&&e.enter()},Ol||Me||nc||!ic||!oc?uc&&uc.resolve?($l=uc.resolve(void 0),ec=$l.then,Jl=function(){ec.call($l,Kl)}):Jl=Me?function(){sc.nextTick(Kl)}:function(){ac.call(a,Kl)}:(Zl=!0,Ql=oc.createTextNode(""),new ic(Kl).observe(Ql,{characterData:!0}),Jl=function(){Ql.data=Zl=!Zl}));var pc,hc,dc,fc,mc=cc||function(e){var t={fn:e,next:void 0};Yl&&(Yl.next=t),Xl||(Xl=t,Jl()),Yl=t},vc=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=ft(t),this.reject=ft(n)},gc={f:function(e){return new vc(e)}},yc=function(e,t){if(E(e),y(t)&&t.constructor===e)return t;var n=gc.f(e);return(0,n.resolve)(t),n.promise},bc=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},xc=tc.set,wc=st("species"),kc="Promise",Nc=re.get,Ic=re.set,Sc=re.getterFor(kc),Tc=Rl,Cc=a.TypeError,Ec=a.document,Ac=a.process,Rc=se("fetch"),_c=gc.f,Fc=_c,Oc=!!(Ec&&Ec.createEvent&&a.dispatchEvent),Dc="function"==typeof PromiseRejectionEvent,Mc="unhandledrejection",Lc=Fe(kc,(function(){if(!(B(Tc)!==String(Tc))){if(66===Ve)return!0;if(!Me&&!Dc)return!0}if(Ve>=51&&/native code/.test(Tc))return!1;var e=Tc.resolve(1),t=function(e){e((function(){}),(function(){}))};return(e.constructor={})[wc]=t,!(e.then((function(){}))instanceof t)})),zc=Lc||!Dn((function(e){Tc.all(e).catch((function(){}))})),Pc=function(e){var t;return!(!y(e)||"function"!=typeof(t=e.then))&&t},Bc=function(e,t){if(!e.notified){e.notified=!0;var n=e.reactions;mc((function(){for(var r=e.value,a=1==e.state,i=0;n.length>i;){var o,s,u,l=n[i++],c=a?l.ok:l.fail,p=l.resolve,h=l.reject,d=l.domain;try{c?(a||(2===e.rejection&&Gc(e),e.rejection=1),!0===c?o=r:(d&&d.enter(),o=c(r),d&&(d.exit(),u=!0)),o===l.promise?h(Cc("Promise-chain cycle")):(s=Pc(o))?s.call(o,p,h):p(o)):h(r)}catch(e){d&&!u&&d.exit(),h(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&Vc(e)}))}},Wc=function(e,t,n){var r,i;Oc?((r=Ec.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),a.dispatchEvent(r)):r={promise:t,reason:n},!Dc&&(i=a["on"+e])?i(r):e===Mc&&function(e,t){var n=a.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))}("Unhandled promise rejection",n)},Vc=function(e){xc.call(a,(function(){var t,n=e.facade,r=e.value;if(Uc(e)&&(t=bc((function(){Me?Ac.emit("unhandledRejection",r,n):Wc(Mc,n,r)})),e.rejection=Me||Uc(e)?2:1,t.error))throw t.value}))},Uc=function(e){return 1!==e.rejection&&!e.parent},Gc=function(e){xc.call(a,(function(){var t=e.facade;Me?Ac.emit("rejectionHandled",t):Wc("rejectionhandled",t,e.value)}))},jc=function(e,t,n){return function(r){e(t,r,n)}},Hc=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,Bc(e,!0))},qc=function e(t,n,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===n)throw Cc("Promise can't be resolved itself");var a=Pc(n);a?mc((function(){var r={done:!1};try{a.call(n,jc(e,r,t),jc(Hc,r,t))}catch(e){Hc(r,e,t)}})):(t.value=n,t.state=1,Bc(t,!1))}catch(e){Hc({done:!1},e,t)}}};Lc&&(Tc=function(e){Fl(this,Tc,kc),ft(e),pc.call(this);var t=Nc(this);try{e(jc(qc,t),jc(Hc,t))}catch(e){Hc(t,e)}},(pc=function(e){Ic(this,{type:kc,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=_l(Tc.prototype,{then:function(e,t){var n=Sc(this),r=_c($i(this,Tc));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=Me?Ac.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&Bc(n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),hc=function(){var e=new pc,t=Nc(e);this.promise=e,this.resolve=jc(qc,t),this.reject=jc(Hc,t)},gc.f=_c=function(e){return e===Tc||e===dc?new hc(e):Fc(e)},"function"==typeof Rl&&(fc=Rl.prototype.then,ae(Rl.prototype,"then",(function(e,t){var n=this;return new Tc((function(e,t){fc.call(n,e,t)})).then(e,t)}),{unsafe:!0}),"function"==typeof Rc&&De({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return yc(Tc,Rc.apply(a,arguments))}}))),De({global:!0,wrap:!0,forced:Lc},{Promise:Tc}),dt(Tc,kc,!1),Zr(kc),dc=se(kc),De({target:kc,stat:!0,forced:Lc},{reject:function(e){var t=_c(this);return t.reject.call(void 0,e),t.promise}}),De({target:kc,stat:!0,forced:Lc},{resolve:function(e){return yc(this,e)}}),De({target:kc,stat:!0,forced:zc},{all:function(e){var t=this,n=_c(t),r=n.resolve,a=n.reject,i=bc((function(){var n=ft(t.resolve),i=[],o=0,s=1;Sn(e,(function(e){var u=o++,l=!1;i.push(void 0),s++,n.call(t,e).then((function(e){l||(l=!0,i[u]=e,--s||r(i))}),a)})),--s||r(i)}));return i.error&&a(i.value),n.promise},race:function(e){var t=this,n=_c(t),r=n.reject,a=bc((function(){var a=ft(t.resolve);Sn(e,(function(e){a.call(t,e).then(n.resolve,r)}))}));return a.error&&r(a.value),n.promise}}),De({target:"Promise",stat:!0},{allSettled:function(e){var t=this,n=gc.f(t),r=n.resolve,a=n.reject,i=bc((function(){var n=ft(t.resolve),a=[],i=0,o=1;Sn(e,(function(e){var s=i++,u=!1;a.push(void 0),o++,n.call(t,e).then((function(e){u||(u=!0,a[s]={status:"fulfilled",value:e},--o||r(a))}),(function(e){u||(u=!0,a[s]={status:"rejected",reason:e},--o||r(a))}))})),--o||r(a)}));return i.error&&a(i.value),n.promise}});var Kc="No one promise resolved";De({target:"Promise",stat:!0},{any:function(e){var t=this,n=gc.f(t),r=n.resolve,a=n.reject,i=bc((function(){var n=ft(t.resolve),i=[],o=0,s=1,u=!1;Sn(e,(function(e){var l=o++,c=!1;i.push(void 0),s++,n.call(t,e).then((function(e){c||u||(u=!0,r(e))}),(function(e){c||u||(c=!0,i[l]=e,--s||a(new(se("AggregateError"))(i,Kc)))}))})),--s||a(new(se("AggregateError"))(i,Kc))}));return i.error&&a(i.value),n.promise}});var Xc=!!Rl&&i((function(){Rl.prototype.finally.call({then:function(){}},(function(){}))}));De({target:"Promise",proto:!0,real:!0,forced:Xc},{finally:function(e){var t=$i(this,se("Promise")),n="function"==typeof e;return this.then(n?function(n){return yc(t,e()).then((function(){return n}))}:e,n?function(n){return yc(t,e()).then((function(){throw n}))}:e)}}),"function"!=typeof Rl||Rl.prototype.finally||ae(Rl.prototype,"finally",se("Promise").prototype.finally);var Yc=function(e,t,n){var r=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),s=r?"set":"add",u=a[e],l=u&&u.prototype,c=u,p={},h=function(e){var t=l[e];ae(l,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(o&&!y(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return o&&!y(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(o&&!y(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(Fe(e,"function"!=typeof u||!(o||l.forEach&&!i((function(){(new u).entries().next()})))))c=n.getConstructor(t,e,r,s),Ba.REQUIRED=!0;else if(Fe(e,!0)){var d=new c,f=d[s](o?{}:-0,1)!=d,m=i((function(){d.has(1)})),v=Dn((function(e){new u(e)})),g=!o&&i((function(){for(var e=new u,t=5;t--;)e[s](t,t);return!e.has(-0)}));v||((c=t((function(t,n){Fl(t,c,e);var a=os(new u,t,c);return null!=n&&Sn(n,a[s],{that:a,AS_ENTRIES:r}),a}))).prototype=l,l.constructor=c),(m||g)&&(h("delete"),h("has"),r&&h("get")),(g||f)&&h(s),o&&l.clear&&delete l.clear}return p[e]=c,De({global:!0,forced:c!=u},p),dt(c,e),o||n.setStrong(c,e,r),c},Jc=R.f,Zc=Ba.fastKey,Qc=re.set,$c=re.getterFor,ep={getConstructor:function(e,t,n,r){var a=e((function(e,i){Fl(e,a,t),Qc(e,{type:t,index:$e(null),first:void 0,last:void 0,size:0}),o||(e.size=0),null!=i&&Sn(i,e[r],{that:e,AS_ENTRIES:n})})),i=$c(t),s=function(e,t,n){var r,a,s=i(e),l=u(e,t);return l?l.value=n:(s.last=l={index:a=Zc(t,!0),key:t,value:n,previous:r=s.last,next:void 0,removed:!1},s.first||(s.first=l),r&&(r.next=l),o?s.size++:e.size++,"F"!==a&&(s.index[a]=l)),e},u=function(e,t){var n,r=i(e),a=Zc(t);if("F"!==a)return r.index[a];for(n=r.first;n;n=n.next)if(n.key==t)return n};return _l(a.prototype,{clear:function(){for(var e=i(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,o?e.size=0:this.size=0},delete:function(e){var t=this,n=i(t),r=u(t,e);if(r){var a=r.next,s=r.previous;delete n.index[r.index],r.removed=!0,s&&(s.next=a),a&&(a.previous=s),n.first==r&&(n.first=a),n.last==r&&(n.last=s),o?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=i(this),r=mt(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!u(this,e)}}),_l(a.prototype,n?{get:function(e){var t=u(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),o&&Jc(a.prototype,"size",{get:function(){return i(this).size}}),a},setStrong:function(e,t,n){var r=t+" Iterator",a=$c(t),i=$c(r);ma(e,t,(function(e,t){Qc(this,{type:r,target:e,state:a(e),kind:t,last:void 0})}),(function(){for(var e=i(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),Zr(t)}},tp=(Yc("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),ep),Yc("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),ep),Ba.getWeakData),np=re.set,rp=re.getterFor,ap=xt.find,ip=xt.findIndex,op=0,sp=function(e){return e.frozen||(e.frozen=new up)},up=function(){this.entries=[]},lp=function(e,t){return ap(e.entries,(function(e){return e[0]===t}))};up.prototype={get:function(e){var t=lp(this,e);if(t)return t[1]},has:function(e){return!!lp(this,e)},set:function(e,t){var n=lp(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=ip(this.entries,(function(t){return t[0]===e}));return~t&&this.entries.splice(t,1),!!~t}};var cp={getConstructor:function(e,t,n,r){var a=e((function(e,i){Fl(e,a,t),np(e,{type:t,id:op++,frozen:void 0}),null!=i&&Sn(i,e[r],{that:e,AS_ENTRIES:n})})),i=rp(t),o=function(e,t,n){var r=i(e),a=tp(E(t),!0);return!0===a?sp(r).set(t,n):a[r.id]=n,e};return _l(a.prototype,{delete:function(e){var t=i(this);if(!y(e))return!1;var n=tp(e);return!0===n?sp(t).delete(e):n&&w(n,t.id)&&delete n[t.id]},has:function(e){var t=i(this);if(!y(e))return!1;var n=tp(e);return!0===n?sp(t).has(e):n&&w(n,t.id)}}),_l(a.prototype,n?{get:function(e){var t=i(this);if(y(e)){var n=tp(e);return!0===n?sp(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return o(this,e,t)}}:{add:function(e){return o(this,e,!0)}}),a}};n((function(e){var t,n=re.enforce,r=!a.ActiveXObject&&"ActiveXObject"in a,i=Object.isExtensible,o=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},s=e.exports=Yc("WeakMap",o,cp);if(V&&r){t=cp.getConstructor(o,"WeakMap",!0),Ba.REQUIRED=!0;var u=s.prototype,l=u.delete,c=u.has,p=u.get,h=u.set;_l(u,{delete:function(e){if(y(e)&&!i(e)){var r=n(this);return r.frozen||(r.frozen=new t),l.call(this,e)||r.frozen.delete(e)}return l.call(this,e)},has:function(e){if(y(e)&&!i(e)){var r=n(this);return r.frozen||(r.frozen=new t),c.call(this,e)||r.frozen.has(e)}return c.call(this,e)},get:function(e){if(y(e)&&!i(e)){var r=n(this);return r.frozen||(r.frozen=new t),c.call(this,e)?p.call(this,e):r.frozen.get(e)}return p.call(this,e)},set:function(e,r){if(y(e)&&!i(e)){var a=n(this);a.frozen||(a.frozen=new t),c.call(this,e)?h.call(this,e,r):a.frozen.set(e,r)}else h.call(this,e,r);return this}})}}));Yc("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),cp);var pp="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,hp=function(e){if(void 0===e)return 0;var t=ce(e),n=he(t);if(t!==n)throw RangeError("Wrong length or index");return n},dp=Math.abs,fp=Math.pow,mp=Math.floor,vp=Math.log,gp=Math.LN2,yp=function(e,t,n){var r,a,i,o=new Array(n),s=8*n-t-1,u=(1<<s)-1,l=u>>1,c=23===t?fp(2,-24)-fp(2,-77):0,p=e<0||0===e&&1/e<0?1:0,h=0;for((e=dp(e))!=e||e===1/0?(a=e!=e?1:0,r=u):(r=mp(vp(e)/gp),e*(i=fp(2,-r))<1&&(r--,i*=2),(e+=r+l>=1?c/i:c*fp(2,1-l))*i>=2&&(r++,i/=2),r+l>=u?(a=0,r=u):r+l>=1?(a=(e*i-1)*fp(2,t),r+=l):(a=e*fp(2,l-1)*fp(2,t),r=0));t>=8;o[h++]=255&a,a/=256,t-=8);for(r=r<<t|a,s+=t;s>0;o[h++]=255&r,r/=256,s-=8);return o[--h]|=128*p,o},bp=function(e,t){var n,r=e.length,a=8*r-t-1,i=(1<<a)-1,o=i>>1,s=a-7,u=r-1,l=e[u--],c=127&l;for(l>>=7;s>0;c=256*c+e[u],u--,s-=8);for(n=c&(1<<-s)-1,c>>=-s,s+=t;s>0;n=256*n+e[u],u--,s-=8);if(0===c)c=1-o;else{if(c===i)return n?NaN:l?-1/0:1/0;n+=fp(2,t),c-=o}return(l?-1:1)*n*fp(2,c-t)},xp=ke.f,wp=R.f,kp=re.get,Np=re.set,Ip="ArrayBuffer",Sp="DataView",Tp="Wrong index",Cp=a.ArrayBuffer,Ep=Cp,Ap=a.DataView,Rp=Ap&&Ap.prototype,_p=Object.prototype,Fp=a.RangeError,Op=yp,Dp=bp,Mp=function(e){return[255&e]},Lp=function(e){return[255&e,e>>8&255]},zp=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Pp=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Bp=function(e){return Op(e,23,4)},Wp=function(e){return Op(e,52,8)},Vp=function(e,t){wp(e.prototype,t,{get:function(){return kp(this)[t]}})},Up=function(e,t,n,r){var a=hp(n),i=kp(e);if(a+t>i.byteLength)throw Fp(Tp);var o=kp(i.buffer).bytes,s=a+i.byteOffset,u=o.slice(s,s+t);return r?u:u.reverse()},Gp=function(e,t,n,r,a,i){var o=hp(n),s=kp(e);if(o+t>s.byteLength)throw Fp(Tp);for(var u=kp(s.buffer).bytes,l=o+s.byteOffset,c=r(+a),p=0;p<t;p++)u[l+p]=c[i?p:t-p-1]};if(pp){if(!i((function(){Cp(1)}))||!i((function(){new Cp(-1)}))||i((function(){return new Cp,new Cp(1.5),new Cp(NaN),Cp.name!=Ip}))){for(var jp,Hp=(Ep=function(e){return Fl(this,Ep),new Cp(hp(e))}).prototype=Cp.prototype,qp=xp(Cp),Kp=0;qp.length>Kp;)(jp=qp[Kp++])in Ep||_(Ep,jp,Cp[jp]);Hp.constructor=Ep}pn&&ln(Rp)!==_p&&pn(Rp,_p);var Xp=new Ap(new Ep(2)),Yp=Rp.setInt8;Xp.setInt8(0,2147483648),Xp.setInt8(1,2147483649),!Xp.getInt8(0)&&Xp.getInt8(1)||_l(Rp,{setInt8:function(e,t){Yp.call(this,e,t<<24>>24)},setUint8:function(e,t){Yp.call(this,e,t<<24>>24)}},{unsafe:!0})}else Ep=function(e){Fl(this,Ep,Ip);var t=hp(e);Np(this,{bytes:$n.call(new Array(t),0),byteLength:t}),o||(this.byteLength=t)},Ap=function(e,t,n){Fl(this,Ap,Sp),Fl(e,Ep,Sp);var r=kp(e).byteLength,a=ce(t);if(a<0||a>r)throw Fp("Wrong offset");if(a+(n=void 0===n?r-a:he(n))>r)throw Fp("Wrong length");Np(this,{buffer:e,byteLength:n,byteOffset:a}),o||(this.buffer=e,this.byteLength=n,this.byteOffset=a)},o&&(Vp(Ep,"byteLength"),Vp(Ap,"buffer"),Vp(Ap,"byteLength"),Vp(Ap,"byteOffset")),_l(Ap.prototype,{getInt8:function(e){return Up(this,1,e)[0]<<24>>24},getUint8:function(e){return Up(this,1,e)[0]},getInt16:function(e){var t=Up(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Up(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Pp(Up(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Pp(Up(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return Dp(Up(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return Dp(Up(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Gp(this,1,e,Mp,t)},setUint8:function(e,t){Gp(this,1,e,Mp,t)},setInt16:function(e,t){Gp(this,2,e,Lp,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Gp(this,2,e,Lp,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Gp(this,4,e,zp,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Gp(this,4,e,zp,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Gp(this,4,e,Bp,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Gp(this,8,e,Wp,t,arguments.length>2?arguments[2]:void 0)}});dt(Ep,Ip),dt(Ap,Sp);var Jp={ArrayBuffer:Ep,DataView:Ap},Zp="ArrayBuffer",Qp=Jp.ArrayBuffer,$p=a.ArrayBuffer;De({global:!0,forced:$p!==Qp},{ArrayBuffer:Qp}),Zr(Zp);var eh,th=R.f,nh=a.Int8Array,rh=nh&&nh.prototype,ah=a.Uint8ClampedArray,ih=ah&&ah.prototype,oh=nh&&ln(nh),sh=rh&&ln(rh),uh=Object.prototype,lh=uh.isPrototypeOf,ch=st("toStringTag"),ph=H("TYPED_ARRAY_TAG"),hh=pp&&!!pn&&"Opera"!==xn(a.opera),dh=!1,fh={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},mh={BigInt64Array:8,BigUint64Array:8},vh=function(e){if(!y(e))return!1;var t=xn(e);return w(fh,t)||w(mh,t)};for(eh in fh)a[eh]||(hh=!1);if((!hh||"function"!=typeof oh||oh===Function.prototype)&&(oh=function(){throw TypeError("Incorrect invocation")},hh))for(eh in fh)a[eh]&&pn(a[eh],oh);if((!hh||!sh||sh===uh)&&(sh=oh.prototype,hh))for(eh in fh)a[eh]&&pn(a[eh].prototype,sh);if(hh&&ln(ih)!==sh&&pn(ih,sh),o&&!w(sh,ch))for(eh in dh=!0,th(sh,ch,{get:function(){return y(this)?this[ph]:void 0}}),fh)a[eh]&&_(a[eh],ph,eh);var gh={NATIVE_ARRAY_BUFFER_VIEWS:hh,TYPED_ARRAY_TAG:dh&&ph,aTypedArray:function(e){if(vh(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(pn){if(lh.call(oh,e))return e}else for(var t in fh)if(w(fh,eh)){var n=a[t];if(n&&(e===n||lh.call(n,e)))return e}throw TypeError("Target is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n){if(o){if(n)for(var r in fh){var i=a[r];i&&w(i.prototype,e)&&delete i.prototype[e]}sh[e]&&!n||ae(sh,e,n?t:hh&&rh[e]||t)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(o){if(pn){if(n)for(r in fh)(i=a[r])&&w(i,e)&&delete i[e];if(oh[e]&&!n)return;try{return ae(oh,e,n?t:hh&&nh[e]||t)}catch(e){}}for(r in fh)!(i=a[r])||i[e]&&!n||ae(i,e,t)}},isView:function(e){if(!y(e))return!1;var t=xn(e);return"DataView"===t||w(fh,t)||w(mh,t)},isTypedArray:vh,TypedArray:oh,TypedArrayPrototype:sh};De({target:"ArrayBuffer",stat:!0,forced:!gh.NATIVE_ARRAY_BUFFER_VIEWS},{isView:gh.isView});var yh=Jp.ArrayBuffer,bh=Jp.DataView,xh=yh.prototype.slice,wh=i((function(){return!new yh(2).slice(1,void 0).byteLength}));De({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:wh},{slice:function(e,t){if(void 0!==xh&&void 0===t)return xh.call(E(this),e);for(var n=E(this).byteLength,r=me(e,n),a=me(void 0===t?n:t,n),i=new($i(this,yh))(he(a-r)),o=new bh(this),s=new bh(i),u=0;r<a;)s.setUint8(u++,o.getUint8(r++));return i}}),De({global:!0,forced:!pp},{DataView:Jp.DataView});var kh=gh.NATIVE_ARRAY_BUFFER_VIEWS,Nh=a.ArrayBuffer,Ih=a.Int8Array,Sh=!kh||!i((function(){Ih(1)}))||!i((function(){new Ih(-1)}))||!Dn((function(e){new Ih,new Ih(null),new Ih(1.5),new Ih(e)}),!0)||i((function(){return 1!==new Ih(new Nh(2),1,void 0).length})),Th=function(e,t){var n=function(e){var t=ce(e);if(t<0)throw RangeError("The argument can't be less than 0");return t}(e);if(n%t)throw RangeError("Wrong offset");return n},Ch=gh.aTypedArrayConstructor,Eh=function(e){var t,n,r,a,i,o,s=He(e),u=arguments.length,l=u>1?arguments[1]:void 0,c=void 0!==l,p=kn(s);if(null!=p&&!mn(p))for(o=(i=p.call(s)).next,s=[];!(a=o.call(i)).done;)s.push(a.value);for(c&&u>2&&(l=mt(l,arguments[2],2)),n=he(s.length),r=new(Ch(this))(n),t=0;n>t;t++)r[t]=c?l(s[t],t):s[t];return r},Ah=n((function(e){var t=ke.f,n=xt.forEach,r=re.get,i=re.set,s=R.f,u=C.f,l=Math.round,c=a.RangeError,h=Jp.ArrayBuffer,d=Jp.DataView,f=gh.NATIVE_ARRAY_BUFFER_VIEWS,m=gh.TYPED_ARRAY_TAG,v=gh.TypedArray,g=gh.TypedArrayPrototype,x=gh.aTypedArrayConstructor,k=gh.isTypedArray,N="BYTES_PER_ELEMENT",I="Wrong length",S=function(e,t){for(var n=0,r=t.length,a=new(x(e))(r);r>n;)a[n]=t[n++];return a},T=function(e,t){s(e,t,{get:function(){return r(this)[t]}})},E=function(e){var t;return e instanceof h||"ArrayBuffer"==(t=xn(e))||"SharedArrayBuffer"==t},A=function(e,t){return k(e)&&"symbol"!=typeof t&&t in e&&String(+t)==String(t)},F=function(e,t){return A(e,t=b(t,!0))?p(2,e[t]):u(e,t)},O=function(e,t,n){return!(A(e,t=b(t,!0))&&y(n)&&w(n,"value"))||w(n,"get")||w(n,"set")||n.configurable||w(n,"writable")&&!n.writable||w(n,"enumerable")&&!n.enumerable?s(e,t,n):(e[t]=n.value,e)};o?(f||(C.f=F,R.f=O,T(g,"buffer"),T(g,"byteOffset"),T(g,"byteLength"),T(g,"length")),De({target:"Object",stat:!0,forced:!f},{getOwnPropertyDescriptor:F,defineProperty:O}),e.exports=function(e,o,u){var p=e.match(/\d+$/)[0]/8,b=e+(u?"Clamped":"")+"Array",x="get"+e,w="set"+e,T=a[b],C=T,A=C&&C.prototype,R={},F=function(e,t){s(e,t,{get:function(){return function(e,t){var n=r(e);return n.view[x](t*p+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var a=r(e);u&&(n=(n=l(n))<0?0:n>255?255:255&n),a.view[w](t*p+a.byteOffset,n,!0)}(this,t,e)},enumerable:!0})};f?Sh&&(C=o((function(e,t,n,r){return Fl(e,C,b),os(y(t)?E(t)?void 0!==r?new T(t,Th(n,p),r):void 0!==n?new T(t,Th(n,p)):new T(t):k(t)?S(C,t):Eh.call(C,t):new T(hp(t)),e,C)})),pn&&pn(C,v),n(t(T),(function(e){e in C||_(C,e,T[e])})),C.prototype=A):(C=o((function(e,t,n,r){Fl(e,C,b);var a,o,s,u=0,l=0;if(y(t)){if(!E(t))return k(t)?S(C,t):Eh.call(C,t);a=t,l=Th(n,p);var f=t.byteLength;if(void 0===r){if(f%p)throw c(I);if((o=f-l)<0)throw c(I)}else if((o=he(r)*p)+l>f)throw c(I);s=o/p}else s=hp(t),a=new h(o=s*p);for(i(e,{buffer:a,byteOffset:l,byteLength:o,length:s,view:new d(a)});u<s;)F(e,u++)})),pn&&pn(C,v),A=C.prototype=$e(g)),A.constructor!==C&&_(A,"constructor",C),m&&_(A,m,b),R[b]=C,De({global:!0,forced:C!=T,sham:!f},R),N in C||_(C,N,p),N in A||_(A,N,p),Zr(b)}):e.exports=function(){}}));Ah("Int8",(function(e){return function(t,n,r){return e(this,t,n,r)}})),Ah("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}})),Ah("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}),!0),Ah("Int16",(function(e){return function(t,n,r){return e(this,t,n,r)}})),Ah("Uint16",(function(e){return function(t,n,r){return e(this,t,n,r)}})),Ah("Int32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),Ah("Uint32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),Ah("Float32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),Ah("Float64",(function(e){return function(t,n,r){return e(this,t,n,r)}})),(0,gh.exportTypedArrayStaticMethod)("from",Eh,Sh);var Rh=gh.aTypedArrayConstructor;(0,gh.exportTypedArrayStaticMethod)("of",(function(){for(var e=0,t=arguments.length,n=new(Rh(this))(t);t>e;)n[e]=arguments[e++];return n}),Sh);var _h=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("copyWithin",(function(e,t){return qn.call(_h(this),e,t,arguments.length>2?arguments[2]:void 0)}));var Fh=xt.every,Oh=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("every",(function(e){return Fh(Oh(this),e,arguments.length>1?arguments[1]:void 0)}));var Dh=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("fill",(function(e){return $n.apply(Dh(this),arguments)}));var Mh=gh.aTypedArrayConstructor,Lh=function(e,t){for(var n=$i(e,e.constructor),r=0,a=t.length,i=new(Mh(n))(a);a>r;)i[r]=t[r++];return i},zh=xt.filter,Ph=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("filter",(function(e){var t=zh(Ph(this),e,arguments.length>1?arguments[1]:void 0);return Lh(this,t)}));var Bh=xt.find,Wh=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("find",(function(e){return Bh(Wh(this),e,arguments.length>1?arguments[1]:void 0)}));var Vh=xt.findIndex,Uh=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("findIndex",(function(e){return Vh(Uh(this),e,arguments.length>1?arguments[1]:void 0)}));var Gh=xt.forEach,jh=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("forEach",(function(e){Gh(jh(this),e,arguments.length>1?arguments[1]:void 0)}));var Hh=ge.includes,qh=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("includes",(function(e){return Hh(qh(this),e,arguments.length>1?arguments[1]:void 0)}));var Kh=ge.indexOf,Xh=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("indexOf",(function(e){return Kh(Xh(this),e,arguments.length>1?arguments[1]:void 0)}));var Yh=st("iterator"),Jh=a.Uint8Array,Zh=ba.values,Qh=ba.keys,$h=ba.entries,ed=gh.aTypedArray,td=gh.exportTypedArrayMethod,nd=Jh&&Jh.prototype[Yh],rd=!!nd&&("values"==nd.name||null==nd.name),ad=function(){return Zh.call(ed(this))};td("entries",(function(){return $h.call(ed(this))})),td("keys",(function(){return Qh.call(ed(this))})),td("values",ad,!rd),td(Yh,ad,!rd);var id=gh.aTypedArray,od=[].join;(0,gh.exportTypedArrayMethod)("join",(function(e){return od.apply(id(this),arguments)}));var sd=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("lastIndexOf",(function(e){return Nr.apply(sd(this),arguments)}));var ud=xt.map,ld=gh.aTypedArray,cd=gh.aTypedArrayConstructor;(0,gh.exportTypedArrayMethod)("map",(function(e){return ud(ld(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(cd($i(e,e.constructor)))(t)}))}));var pd=Cr.left,hd=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("reduce",(function(e){return pd(hd(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var dd=Cr.right,fd=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("reduceRight",(function(e){return dd(fd(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var md=gh.aTypedArray,vd=gh.exportTypedArrayMethod,gd=Math.floor;vd("reverse",(function(){for(var e,t=this,n=md(t).length,r=gd(n/2),a=0;a<r;)e=t[a],t[a++]=t[--n],t[n]=e;return t}));var yd=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("set",(function(e){yd(this);var t=Th(arguments.length>1?arguments[1]:void 0,1),n=this.length,r=He(e),a=he(r.length),i=0;if(a+t>n)throw RangeError("Wrong length");for(;i<a;)this[t+i]=r[i++]}),i((function(){new Int8Array(1).set({})})));var bd=gh.aTypedArray,xd=gh.aTypedArrayConstructor,wd=[].slice;(0,gh.exportTypedArrayMethod)("slice",(function(e,t){for(var n=wd.call(bd(this),e,t),r=$i(this,this.constructor),a=0,i=n.length,o=new(xd(r))(i);i>a;)o[a]=n[a++];return o}),i((function(){new Int8Array(1).slice()})));var kd=xt.some,Nd=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("some",(function(e){return kd(Nd(this),e,arguments.length>1?arguments[1]:void 0)}));var Id=gh.aTypedArray,Sd=[].sort;(0,gh.exportTypedArrayMethod)("sort",(function(e){return Sd.call(Id(this),e)}));var Td=gh.aTypedArray;(0,gh.exportTypedArrayMethod)("subarray",(function(e,t){var n=Td(this),r=n.length,a=me(e,r);return new($i(n,n.constructor))(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,he((void 0===t?r:me(t,r))-a))}));var Cd=a.Int8Array,Ed=gh.aTypedArray,Ad=gh.exportTypedArrayMethod,Rd=[].toLocaleString,_d=[].slice,Fd=!!Cd&&i((function(){Rd.call(new Cd(1))}));Ad("toLocaleString",(function(){return Rd.apply(Fd?_d.call(Ed(this)):Ed(this),arguments)}),i((function(){return[1,2].toLocaleString()!=new Cd([1,2]).toLocaleString()}))||!i((function(){Cd.prototype.toLocaleString.call([1,2])})));var Od=gh.exportTypedArrayMethod,Dd=a.Uint8Array,Md=Dd&&Dd.prototype||{},Ld=[].toString,zd=[].join;i((function(){Ld.call({})}))&&(Ld=function(){return zd.call(this)});var Pd=Md.toString!=Ld;Od("toString",Ld,Pd);var Bd=se("Reflect","apply"),Wd=Function.apply,Vd=!i((function(){Bd((function(){}))}));De({target:"Reflect",stat:!0,forced:Vd},{apply:function(e,t,n){return ft(e),E(n),Bd?Bd(e,t,n):Wd.call(e,t,n)}});var Ud=se("Reflect","construct"),Gd=i((function(){function e(){}return!(Ud((function(){}),[],e)instanceof e)})),jd=!i((function(){Ud((function(){}))})),Hd=Gd||jd;De({target:"Reflect",stat:!0,forced:Hd,sham:Hd},{construct:function(e,t){ft(e),E(t);var n=arguments.length<3?e:ft(arguments[2]);if(jd&&!Gd)return Ud(e,t,n);if(e==n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return r.push.apply(r,t),new(Na.apply(e,r))}var a=n.prototype,i=$e(y(a)?a:Object.prototype),o=Function.apply.call(e,i,t);return y(o)?o:i}});var qd=i((function(){Reflect.defineProperty(R.f({},1,{value:1}),1,{value:2})}));De({target:"Reflect",stat:!0,forced:qd,sham:!o},{defineProperty:function(e,t,n){E(e);var r=b(t,!0);E(n);try{return R.f(e,r,n),!0}catch(e){return!1}}});var Kd=C.f;De({target:"Reflect",stat:!0},{deleteProperty:function(e,t){var n=Kd(E(e),t);return!(n&&!n.configurable)&&delete e[t]}}),De({target:"Reflect",stat:!0},{get:function e(t,n){var r,a,i=arguments.length<3?t:arguments[2];return E(t)===i?t[n]:(r=C.f(t,n))?w(r,"value")?r.value:void 0===r.get?void 0:r.get.call(i):y(a=ln(t))?e(a,n,i):void 0}}),De({target:"Reflect",stat:!0,sham:!o},{getOwnPropertyDescriptor:function(e,t){return C.f(E(e),t)}}),De({target:"Reflect",stat:!0,sham:!on},{getPrototypeOf:function(e){return ln(E(e))}}),De({target:"Reflect",stat:!0},{has:function(e,t){return t in e}});var Xd=Object.isExtensible;De({target:"Reflect",stat:!0},{isExtensible:function(e){return E(e),!Xd||Xd(e)}}),De({target:"Reflect",stat:!0},{ownKeys:Ie}),De({target:"Reflect",stat:!0,sham:!Pa},{preventExtensions:function(e){E(e);try{var t=se("Object","preventExtensions");return t&&t(e),!0}catch(e){return!1}}});var Yd=i((function(){var e=function(){},t=R.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}));De({target:"Reflect",stat:!0,forced:Yd},{set:function e(t,n,r){var a,i,o=arguments.length<4?t:arguments[3],s=C.f(E(t),n);if(!s){if(y(i=ln(t)))return e(i,n,r,o);s=p(0)}if(w(s,"value")){if(!1===s.writable||!y(o))return!1;if(a=C.f(o,n)){if(a.get||a.set||!1===a.writable)return!1;a.value=r,R.f(o,n,a)}else R.f(o,n,p(0,r));return!0}return void 0!==s.set&&(s.set.call(o,r),!0)}}),pn&&De({target:"Reflect",stat:!0},{setPrototypeOf:function(e,t){E(e),cn(t);try{return pn(e,t),!0}catch(e){return!1}}}),De({global:!0},{Reflect:{}}),dt(a.Reflect,"Reflect",!0);var Jd={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 Zd in Jd){var Qd=a[Zd],$d=Qd&&Qd.prototype;if($d&&$d.forEach!==cr)try{_($d,"forEach",cr)}catch(e){$d.forEach=cr}}var ef=st("iterator"),tf=st("toStringTag"),nf=ba.values;for(var rf in Jd){var af=a[rf],of=af&&af.prototype;if(of){if(of[ef]!==nf)try{_(of,ef,nf)}catch(e){of[ef]=nf}if(of[tf]||_(of,tf,rf),Jd[rf])for(var sf in ba)if(of[sf]!==ba[sf])try{_(of,sf,ba[sf])}catch(e){of[sf]=ba[sf]}}}var uf=!a.setImmediate||!a.clearImmediate;De({global:!0,bind:!0,enumerable:!0,forced:uf},{setImmediate:tc.set,clearImmediate:tc.clear});var lf=a.process;De({global:!0,enumerable:!0,noTargetGet:!0},{queueMicrotask:function(e){var t=Me&&lf.domain;mc(t?t.bind(e):e)}});var cf=[].slice,pf=/MSIE .\./.test(Le),hf=function(e){return function(t,n){var r=arguments.length>2,a=r?cf.call(arguments,2):void 0;return e(r?function(){("function"==typeof t?t:Function(t)).apply(this,a)}:t,n)}};De({global:!0,bind:!0,forced:pf},{setTimeout:hf(a.setTimeout),setInterval:hf(a.setInterval)});var df=st("iterator"),ff=!i((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[df]||"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})),mf=2147483647,vf=/[^\0-\u007E]/,gf=/[.\u3002\uFF0E\uFF61]/g,yf="Overflow: input needs wider integers to process",bf=Math.floor,xf=String.fromCharCode,wf=function(e){return e+22+75*(e<26)},kf=function(e,t,n){var r=0;for(e=n?bf(e/700):e>>1,e+=bf(e/t);e>455;r+=36)e=bf(e/35);return bf(r+36*e/(e+38))},Nf=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var a=e.charCodeAt(n++);if(a>=55296&&a<=56319&&n<r){var i=e.charCodeAt(n++);56320==(64512&i)?t.push(((1023&a)<<10)+(1023&i)+65536):(t.push(a),n--)}else t.push(a)}return t}(e);var n,r,a=e.length,i=128,o=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&t.push(xf(r));var u=t.length,l=u;for(u&&t.push("-");l<a;){var c=mf;for(n=0;n<e.length;n++)(r=e[n])>=i&&r<c&&(c=r);var p=l+1;if(c-i>bf((mf-o)/p))throw RangeError(yf);for(o+=(c-i)*p,i=c,n=0;n<e.length;n++){if((r=e[n])<i&&++o>mf)throw RangeError(yf);if(r==i){for(var h=o,d=36;;d+=36){var f=d<=s?1:d>=s+26?26:d-s;if(h<f)break;var m=h-f,v=36-f;t.push(xf(wf(f+m%v))),h=bf(m/v)}t.push(xf(wf(h))),s=kf(o,p,l==u),o=0,++l}}++o,++i}return t.join("")},If=function(e){var t=kn(e);if("function"!=typeof t)throw TypeError(String(e)+" is not iterable");return E(t.call(e))},Sf=se("fetch"),Tf=se("Headers"),Cf=st("iterator"),Ef="URLSearchParams",Af="URLSearchParamsIterator",Rf=re.set,_f=re.getterFor(Ef),Ff=re.getterFor(Af),Of=/\+/g,Df=Array(4),Mf=function(e){return Df[e-1]||(Df[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},Lf=function(e){try{return decodeURIComponent(e)}catch(t){return e}},zf=function(e){var t=e.replace(Of," "),n=4;try{return decodeURIComponent(t)}catch(e){for(;n;)t=t.replace(Mf(n--),Lf);return t}},Pf=/[!'()~]|%20/g,Bf={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Wf=function(e){return Bf[e]},Vf=function(e){return encodeURIComponent(e).replace(Pf,Wf)},Uf=function(e,t){if(t)for(var n,r,a=t.split("&"),i=0;i<a.length;)(n=a[i++]).length&&(r=n.split("="),e.push({key:zf(r.shift()),value:zf(r.join("="))}))},Gf=function(e){this.entries.length=0,Uf(this.entries,e)},jf=function(e,t){if(e<t)throw TypeError("Not enough arguments")},Hf=sa((function(e,t){Rf(this,{type:Af,iterator:If(_f(e).entries),kind:t})}),"Iterator",(function(){var e=Ff(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),n})),qf=function(){Fl(this,qf,Ef);var e,t,n,r,a,i,o,s,u,l=arguments.length>0?arguments[0]:void 0,c=this,p=[];if(Rf(c,{type:Ef,entries:p,updateURL:function(){},updateSearchParams:Gf}),void 0!==l)if(y(l))if("function"==typeof(e=kn(l)))for(n=(t=e.call(l)).next;!(r=n.call(t)).done;){if((o=(i=(a=If(E(r.value))).next).call(a)).done||(s=i.call(a)).done||!i.call(a).done)throw TypeError("Expected sequence with length 2");p.push({key:o.value+"",value:s.value+""})}else for(u in l)w(l,u)&&p.push({key:u,value:l[u]+""});else Uf(p,"string"==typeof l?"?"===l.charAt(0)?l.slice(1):l:l+"")},Kf=qf.prototype;_l(Kf,{append:function(e,t){jf(arguments.length,2);var n=_f(this);n.entries.push({key:e+"",value:t+""}),n.updateURL()},delete:function(e){jf(arguments.length,1);for(var t=_f(this),n=t.entries,r=e+"",a=0;a<n.length;)n[a].key===r?n.splice(a,1):a++;t.updateURL()},get:function(e){jf(arguments.length,1);for(var t=_f(this).entries,n=e+"",r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){jf(arguments.length,1);for(var t=_f(this).entries,n=e+"",r=[],a=0;a<t.length;a++)t[a].key===n&&r.push(t[a].value);return r},has:function(e){jf(arguments.length,1);for(var t=_f(this).entries,n=e+"",r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){jf(arguments.length,1);for(var n,r=_f(this),a=r.entries,i=!1,o=e+"",s=t+"",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 e,t,n,r=_f(this),a=r.entries,i=a.slice();for(a.length=0,n=0;n<i.length;n++){for(e=i[n],t=0;t<n;t++)if(a[t].key>e.key){a.splice(t,0,e);break}t===n&&a.push(e)}r.updateURL()},forEach:function(e){for(var t,n=_f(this).entries,r=mt(e,arguments.length>1?arguments[1]:void 0,3),a=0;a<n.length;)r((t=n[a++]).value,t.key,this)},keys:function(){return new Hf(this,"keys")},values:function(){return new Hf(this,"values")},entries:function(){return new Hf(this,"entries")}},{enumerable:!0}),ae(Kf,Cf,Kf.entries),ae(Kf,"toString",(function(){for(var e,t=_f(this).entries,n=[],r=0;r<t.length;)e=t[r++],n.push(Vf(e.key)+"="+Vf(e.value));return n.join("&")}),{enumerable:!0}),dt(qf,Ef),De({global:!0,forced:!ff},{URLSearchParams:qf}),ff||"function"!=typeof Sf||"function"!=typeof Tf||De({global:!0,enumerable:!0,forced:!0},{fetch:function(e){var t,n,r,a=[e];return arguments.length>1&&(y(t=arguments[1])&&(n=t.body,xn(n)===Ef&&((r=t.headers?new Tf(t.headers):new Tf).has("content-type")||r.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),t=$e(t,{body:p(0,String(n)),headers:p(0,r)}))),a.push(t)),Sf.apply(this,a)}});var Xf,Yf={URLSearchParams:qf,getState:_f},Jf=gi.codeAt,Zf=a.URL,Qf=Yf.URLSearchParams,$f=Yf.getState,em=re.set,tm=re.getterFor("URL"),nm=Math.floor,rm=Math.pow,am="Invalid scheme",im="Invalid host",om="Invalid port",sm=/[A-Za-z]/,um=/[\d+-.A-Za-z]/,lm=/\d/,cm=/^(0x|0X)/,pm=/^[0-7]+$/,hm=/^\d+$/,dm=/^[\dA-Fa-f]+$/,fm=/[\u0000\t\u000A\u000D #%/:?@[\\]]/,mm=/[\u0000\t\u000A\u000D #/:?@[\\]]/,vm=/^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g,gm=/[\t\u000A\u000D]/g,ym=function(e,t){var n,r,a;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return im;if(!(n=xm(t.slice(1,-1))))return im;e.host=n}else if(Em(e)){if(t=function(e){var t,n,r=[],a=e.toLowerCase().replace(gf,".").split(".");for(t=0;t<a.length;t++)n=a[t],r.push(vf.test(n)?"xn--"+Nf(n):n);return r.join(".")}(t),fm.test(t))return im;if(null===(n=bm(t)))return im;e.host=n}else{if(mm.test(t))return im;for(n="",r=An(t),a=0;a<r.length;a++)n+=Tm(r[a],km);e.host=n}},bm=function(e){var t,n,r,a,i,o,s,u=e.split(".");if(u.length&&""==u[u.length-1]&&u.pop(),(t=u.length)>4)return e;for(n=[],r=0;r<t;r++){if(""==(a=u[r]))return e;if(i=10,a.length>1&&"0"==a.charAt(0)&&(i=cm.test(a)?16:8,a=a.slice(8==i?1:2)),""===a)o=0;else{if(!(10==i?hm:8==i?pm:dm).test(a))return e;o=parseInt(a,i)}n.push(o)}for(r=0;r<t;r++)if(o=n[r],r==t-1){if(o>=rm(256,5-t))return null}else if(o>255)return null;for(s=n.pop(),r=0;r<n.length;r++)s+=n[r]*rm(256,3-r);return s},xm=function(e){var t,n,r,a,i,o,s,u=[0,0,0,0,0,0,0,0],l=0,c=null,p=0,h=function(){return e.charAt(p)};if(":"==h()){if(":"!=e.charAt(1))return;p+=2,c=++l}for(;h();){if(8==l)return;if(":"!=h()){for(t=n=0;n<4&&dm.test(h());)t=16*t+parseInt(h(),16),p++,n++;if("."==h()){if(0==n)return;if(p-=n,l>6)return;for(r=0;h();){if(a=null,r>0){if(!("."==h()&&r<4))return;p++}if(!lm.test(h()))return;for(;lm.test(h());){if(i=parseInt(h(),10),null===a)a=i;else{if(0==a)return;a=10*a+i}if(a>255)return;p++}u[l]=256*u[l]+a,2!=++r&&4!=r||l++}if(4!=r)return;break}if(":"==h()){if(p++,!h())return}else if(h())return;u[l++]=t}else{if(null!==c)return;p++,c=++l}}if(null!==c)for(o=l-c,l=7;0!=l&&o>0;)s=u[l],u[l--]=u[c+o-1],u[c+--o]=s;else if(8!=l)return;return u},wm=function(e){var t,n,r,a;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=nm(e/256);return t.join(".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,a=0,i=0;i<8;i++)0!==e[i]?(a>n&&(t=r,n=a),r=null,a=0):(null===r&&(r=i),++a);return a>n&&(t=r,n=a),t}(e),n=0;n<8;n++)a&&0===e[n]||(a&&(a=!1),r===n?(t+=n?":":"::",a=!0):(t+=e[n].toString(16),n<7&&(t+=":")));return"["+t+"]"}return e},km={},Nm=Oa({},km,{" ":1,'"':1,"<":1,">":1,"`":1}),Im=Oa({},Nm,{"#":1,"?":1,"{":1,"}":1}),Sm=Oa({},Im,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Tm=function(e,t){var n=Jf(e,0);return n>32&&n<127&&!w(t,e)?e:encodeURIComponent(e)},Cm={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Em=function(e){return w(Cm,e.scheme)},Am=function(e){return""!=e.username||""!=e.password},Rm=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},_m=function(e,t){var n;return 2==e.length&&sm.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)},Fm=function(e){var t;return e.length>1&&_m(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},Om=function(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&_m(t[0],!0)||t.pop()},Dm=function(e){return"."===e||"%2e"===e.toLowerCase()},Mm={},Lm={},zm={},Pm={},Bm={},Wm={},Vm={},Um={},Gm={},jm={},Hm={},qm={},Km={},Xm={},Ym={},Jm={},Zm={},Qm={},$m={},ev={},tv={},nv=function(e,t,n,r){var a,i,o,s,u,l=n||Mm,c=0,p="",h=!1,d=!1,f=!1;for(n||(e.scheme="",e.username="",e.password="",e.host=null,e.port=null,e.path=[],e.query=null,e.fragment=null,e.cannotBeABaseURL=!1,t=t.replace(vm,"")),t=t.replace(gm,""),a=An(t);c<=a.length;){switch(i=a[c],l){case Mm:if(!i||!sm.test(i)){if(n)return am;l=zm;continue}p+=i.toLowerCase(),l=Lm;break;case Lm:if(i&&(um.test(i)||"+"==i||"-"==i||"."==i))p+=i.toLowerCase();else{if(":"!=i){if(n)return am;p="",l=zm,c=0;continue}if(n&&(Em(e)!=w(Cm,p)||"file"==p&&(Am(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=p,n)return void(Em(e)&&Cm[e.scheme]==e.port&&(e.port=null));p="","file"==e.scheme?l=Xm:Em(e)&&r&&r.scheme==e.scheme?l=Pm:Em(e)?l=Um:"/"==a[c+1]?(l=Bm,c++):(e.cannotBeABaseURL=!0,e.path.push(""),l=$m)}break;case zm:if(!r||r.cannotBeABaseURL&&"#"!=i)return am;if(r.cannotBeABaseURL&&"#"==i){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,l=tv;break}l="file"==r.scheme?Xm:Wm;continue;case Pm:if("/"!=i||"/"!=a[c+1]){l=Wm;continue}l=Gm,c++;break;case Bm:if("/"==i){l=jm;break}l=Qm;continue;case Wm:if(e.scheme=r.scheme,i==Xf)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query;else if("/"==i||"\\"==i&&Em(e))l=Vm;else if("?"==i)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query="",l=ev;else{if("#"!=i){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.path.pop(),l=Qm;continue}e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query,e.fragment="",l=tv}break;case Vm:if(!Em(e)||"/"!=i&&"\\"!=i){if("/"!=i){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,l=Qm;continue}l=jm}else l=Gm;break;case Um:if(l=Gm,"/"!=i||"/"!=p.charAt(c+1))continue;c++;break;case Gm:if("/"!=i&&"\\"!=i){l=jm;continue}break;case jm:if("@"==i){h&&(p="%40"+p),h=!0,o=An(p);for(var m=0;m<o.length;m++){var v=o[m];if(":"!=v||f){var g=Tm(v,Sm);f?e.password+=g:e.username+=g}else f=!0}p=""}else if(i==Xf||"/"==i||"?"==i||"#"==i||"\\"==i&&Em(e)){if(h&&""==p)return"Invalid authority";c-=An(p).length+1,p="",l=Hm}else p+=i;break;case Hm:case qm:if(n&&"file"==e.scheme){l=Jm;continue}if(":"!=i||d){if(i==Xf||"/"==i||"?"==i||"#"==i||"\\"==i&&Em(e)){if(Em(e)&&""==p)return im;if(n&&""==p&&(Am(e)||null!==e.port))return;if(s=ym(e,p))return s;if(p="",l=Zm,n)return;continue}"["==i?d=!0:"]"==i&&(d=!1),p+=i}else{if(""==p)return im;if(s=ym(e,p))return s;if(p="",l=Km,n==qm)return}break;case Km:if(!lm.test(i)){if(i==Xf||"/"==i||"?"==i||"#"==i||"\\"==i&&Em(e)||n){if(""!=p){var y=parseInt(p,10);if(y>65535)return om;e.port=Em(e)&&y===Cm[e.scheme]?null:y,p=""}if(n)return;l=Zm;continue}return om}p+=i;break;case Xm:if(e.scheme="file","/"==i||"\\"==i)l=Ym;else{if(!r||"file"!=r.scheme){l=Qm;continue}if(i==Xf)e.host=r.host,e.path=r.path.slice(),e.query=r.query;else if("?"==i)e.host=r.host,e.path=r.path.slice(),e.query="",l=ev;else{if("#"!=i){Fm(a.slice(c).join(""))||(e.host=r.host,e.path=r.path.slice(),Om(e)),l=Qm;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",l=tv}}break;case Ym:if("/"==i||"\\"==i){l=Jm;break}r&&"file"==r.scheme&&!Fm(a.slice(c).join(""))&&(_m(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),l=Qm;continue;case Jm:if(i==Xf||"/"==i||"\\"==i||"?"==i||"#"==i){if(!n&&_m(p))l=Qm;else if(""==p){if(e.host="",n)return;l=Zm}else{if(s=ym(e,p))return s;if("localhost"==e.host&&(e.host=""),n)return;p="",l=Zm}continue}p+=i;break;case Zm:if(Em(e)){if(l=Qm,"/"!=i&&"\\"!=i)continue}else if(n||"?"!=i)if(n||"#"!=i){if(i!=Xf&&(l=Qm,"/"!=i))continue}else e.fragment="",l=tv;else e.query="",l=ev;break;case Qm:if(i==Xf||"/"==i||"\\"==i&&Em(e)||!n&&("?"==i||"#"==i)){if(".."===(u=(u=p).toLowerCase())||"%2e."===u||".%2e"===u||"%2e%2e"===u?(Om(e),"/"==i||"\\"==i&&Em(e)||e.path.push("")):Dm(p)?"/"==i||"\\"==i&&Em(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&_m(p)&&(e.host&&(e.host=""),p=p.charAt(0)+":"),e.path.push(p)),p="","file"==e.scheme&&(i==Xf||"?"==i||"#"==i))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==i?(e.query="",l=ev):"#"==i&&(e.fragment="",l=tv)}else p+=Tm(i,Im);break;case $m:"?"==i?(e.query="",l=ev):"#"==i?(e.fragment="",l=tv):i!=Xf&&(e.path[0]+=Tm(i,km));break;case ev:n||"#"!=i?i!=Xf&&("'"==i&&Em(e)?e.query+="%27":e.query+="#"==i?"%23":Tm(i,km)):(e.fragment="",l=tv);break;case tv:i!=Xf&&(e.fragment+=Tm(i,Nm))}c++}},rv=function(e){var t,n,r=Fl(this,rv,"URL"),a=arguments.length>1?arguments[1]:void 0,i=String(e),s=em(r,{type:"URL"});if(void 0!==a)if(a instanceof rv)t=tm(a);else if(n=nv(t={},String(a)))throw TypeError(n);if(n=nv(s,i,null,t))throw TypeError(n);var u=s.searchParams=new Qf,l=$f(u);l.updateSearchParams(s.query),l.updateURL=function(){s.query=String(u)||null},o||(r.href=iv.call(r),r.origin=ov.call(r),r.protocol=sv.call(r),r.username=uv.call(r),r.password=lv.call(r),r.host=cv.call(r),r.hostname=pv.call(r),r.port=hv.call(r),r.pathname=dv.call(r),r.search=fv.call(r),r.searchParams=mv.call(r),r.hash=vv.call(r))},av=rv.prototype,iv=function(){var e=tm(this),t=e.scheme,n=e.username,r=e.password,a=e.host,i=e.port,o=e.path,s=e.query,u=e.fragment,l=t+":";return null!==a?(l+="//",Am(e)&&(l+=n+(r?":"+r:"")+"@"),l+=wm(a),null!==i&&(l+=":"+i)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?o[0]:o.length?"/"+o.join("/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},ov=function(){var e=tm(this),t=e.scheme,n=e.port;if("blob"==t)try{return new URL(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&Em(e)?t+"://"+wm(e.host)+(null!==n?":"+n:""):"null"},sv=function(){return tm(this).scheme+":"},uv=function(){return tm(this).username},lv=function(){return tm(this).password},cv=function(){var e=tm(this),t=e.host,n=e.port;return null===t?"":null===n?wm(t):wm(t)+":"+n},pv=function(){var e=tm(this).host;return null===e?"":wm(e)},hv=function(){var e=tm(this).port;return null===e?"":String(e)},dv=function(){var e=tm(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},fv=function(){var e=tm(this).query;return e?"?"+e:""},mv=function(){return tm(this).searchParams},vv=function(){var e=tm(this).fragment;return e?"#"+e:""},gv=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(o&&Ke(av,{href:gv(iv,(function(e){var t=tm(this),n=String(e),r=nv(t,n);if(r)throw TypeError(r);$f(t.searchParams).updateSearchParams(t.query)})),origin:gv(ov),protocol:gv(sv,(function(e){var t=tm(this);nv(t,String(e)+":",Mm)})),username:gv(uv,(function(e){var t=tm(this),n=An(String(e));if(!Rm(t)){t.username="";for(var r=0;r<n.length;r++)t.username+=Tm(n[r],Sm)}})),password:gv(lv,(function(e){var t=tm(this),n=An(String(e));if(!Rm(t)){t.password="";for(var r=0;r<n.length;r++)t.password+=Tm(n[r],Sm)}})),host:gv(cv,(function(e){var t=tm(this);t.cannotBeABaseURL||nv(t,String(e),Hm)})),hostname:gv(pv,(function(e){var t=tm(this);t.cannotBeABaseURL||nv(t,String(e),qm)})),port:gv(hv,(function(e){var t=tm(this);Rm(t)||(""==(e=String(e))?t.port=null:nv(t,e,Km))})),pathname:gv(dv,(function(e){var t=tm(this);t.cannotBeABaseURL||(t.path=[],nv(t,e+"",Zm))})),search:gv(fv,(function(e){var t=tm(this);""==(e=String(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",nv(t,e,ev)),$f(t.searchParams).updateSearchParams(t.query)})),searchParams:gv(mv),hash:gv(vv,(function(e){var t=tm(this);""!=(e=String(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",nv(t,e,tv)):t.fragment=null}))}),ae(av,"toJSON",(function(){return iv.call(this)}),{enumerable:!0}),ae(av,"toString",(function(){return iv.call(this)}),{enumerable:!0}),Zf){var yv=Zf.createObjectURL,bv=Zf.revokeObjectURL;yv&&ae(rv,"createObjectURL",(function(e){return yv.apply(Zf,arguments)})),bv&&ae(rv,"revokeObjectURL",(function(e){return bv.apply(Zf,arguments)}))}dt(rv,"URL"),De({global:!0,forced:!ff,sham:!o},{URL:rv}),De({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return URL.prototype.toString.call(this)}});n((function(e){var t=function(e){var t,n=Object.prototype,r=n.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=t&&t.prototype instanceof v?t:v,i=Object.create(a.prototype),o=new E(r||[]);return i._invoke=function(e,t,n){var r=p;return function(a,i){if(r===d)throw new Error("Generator is already running");if(r===f){if("throw"===a)throw i;return R()}for(n.method=a,n.arg=i;;){var o=n.delegate;if(o){var s=S(o,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===p)throw r=f,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=d;var u=c(e,t,n);if("normal"===u.type){if(r=n.done?f:h,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=f,n.method="throw",n.arg=u.arg)}}}(e,n,o),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var p="suspendedStart",h="suspendedYield",d="executing",f="completed",m={};function v(){}function g(){}function y(){}var b={};b[i]=function(){return this};var x=Object.getPrototypeOf,w=x&&x(x(A([])));w&&w!==n&&r.call(w,i)&&(b=w);var k=y.prototype=v.prototype=Object.create(b);function N(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(a,i,o,s){var u=c(e[a],e,i);if("throw"!==u.type){var l=u.arg,p=l.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,o,s)}),(function(e){n("throw",e,o,s)})):t.resolve(p).then((function(e){l.value=e,o(l)}),(function(e){return n("throw",e,o,s)}))}s(u.arg)}var a;this._invoke=function(e,r){function i(){return new t((function(t,a){n(e,r,t,a)}))}return a=a?a.then(i,i):i()}}function S(e,n){var r=e.iterator[n.method];if(r===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,S(e,n),"throw"===n.method))return m;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var a=c(r,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,m;var i=a.arg;return i?i.done?(n[e.resultName]=i.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function A(e){if(e){var n=e[i];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function n(){for(;++a<e.length;)if(r.call(e,a))return n.value=e[a],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}return{next:R}}function R(){return{value:t,done:!0}}return g.prototype=k.constructor=y,y.constructor=g,g.displayName=u(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,u(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e},e.awrap=function(e){return{__await:e}},N(I.prototype),I.prototype[o]=function(){return this},e.AsyncIterator=I,e.async=function(t,n,r,a,i){void 0===i&&(i=Promise);var o=new I(l(t,n,r,a),i);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},N(k),u(k,s,"Generator"),k[i]=function(){return this},k.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=A,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function a(r,a){return s.type="throw",s.arg=e,n.next=r,a&&(n.method="next",n.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),l=r.call(o,"finallyLoc");if(u&&l){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;C(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:A(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function xv(e){var t,n;function r(t,n){try{var i=e[t](n),o=i.value,s=o instanceof wv;Promise.resolve(s?o.v:o).then((function(n){if(s){var u="return"===t?"return":"next";if(!o.k||n.done)return r(u,n);n=e[u](n).value}a(i.done?"return":"normal",n)}),(function(e){r("throw",e)}))}catch(e){a("throw",e)}}function a(e,a){switch(e){case"return":t.resolve({value:a,done:!0});break;case"throw":t.reject(a);break;default:t.resolve({value:a,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,a){return new Promise((function(i,o){var s={key:e,arg:a,resolve:i,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,a))}))},"function"!=typeof e.return&&(this.return=void 0)}function wv(e,t){this.v=e,this.k=t}function kv(){kv=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a=t&&t.prototype instanceof p?t:p,i=Object.create(a.prototype),o=new N(r||[]);return i._invoke=function(e,t,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 S()}for(n.method=a,n.arg=i;;){var o=n.delegate;if(o){var s=x(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 u=l(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(e,n,o),i}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function p(){}function h(){}function d(){}var f={};s(f,a,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(I([])));v&&v!==t&&n.call(v,a)&&(f=v);var g=d.prototype=p.prototype=Object.create(f);function y(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function r(a,i,o,s){var u=l(e[a],e,i);if("throw"!==u.type){var c=u.arg,p=c.value;return p&&"object"==typeof p&&n.call(p,"__await")?t.resolve(p.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(p).then((function(e){c.value=e,o(c)}),(function(e){return r("throw",e,o,s)}))}s(u.arg)}var a;this._invoke=function(e,n){function i(){return new t((function(t,a){r(e,n,t,a)}))}return a=a?a.then(i,i):i()}}function x(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=l(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function I(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=d,s(g,"constructor",d),s(d,"constructor",h),h.displayName=s(d,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,o,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(b.prototype),s(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,i){void 0===i&&(i=Promise);var o=new b(u(t,n,r,a),i);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},y(g),s(g,o,"Generator"),s(g,a,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=I,N.prototype={constructor:N,reset:function(e){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(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.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(e,t){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"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:I(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}function Nv(e,t,n,r,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,a)}function Iv(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var i=e.apply(t,n);function o(e){Nv(i,r,a,o,s,"next",e)}function s(e){Nv(i,r,a,o,s,"throw",e)}o(void 0)}))}}function Sv(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Tv(e,t,n){return t&&Sv(e.prototype,t),n&&Sv(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Cv(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Av(e,t)}function Ev(e){return Ev=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ev(e)}function Av(e,t){return Av=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Av(e,t)}function Rv(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _v(e,t,n){return _v=Rv()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&Av(a,n.prototype),a},_v.apply(null,arguments)}function Fv(e){var t="function"==typeof Map?new Map:void 0;return Fv=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _v(e,arguments,Ev(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Av(r,e)},Fv(e)}function Ov(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Dv(e,t){if(e){if("string"==typeof e)return Mv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mv(e,t):void 0}}function Mv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Lv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=Dv(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}xv.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},xv.prototype.next=function(e){return this._invoke("next",e)},xv.prototype.throw=function(e){return this._invoke("throw",e)},xv.prototype.return=function(e){return this._invoke("return",e)};var zv=function(){function e(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}var t=e.prototype;return t.get=function(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)},t.set=function(e,t){this.dataIdsCount++,this.data.set(e,t)},t.has=function(e){return this.data.has(e)},t.delete=function(e){return this.dataIdsCount--,this.data.delete(e)},t.numDataIds=function(){return this.dataIdsCount},e}(),Pv=function(){function e(){}var t=e.prototype;return t.refCount=function(e){return Bv("refCount")},t.incRef=function(e){return Bv("incRef")},t.timerAvailable=function(){return!0},t.time=function(e){return Bv("time")},t.read=function(e){return Bv("read")},t.readSync=function(e){return Bv("readSync")},t.readToGPU=function(e,t){return Bv("readToGPU")},t.numDataIds=function(){return Bv("numDataIds")},t.disposeData=function(e,t){return Bv("disposeData")},t.write=function(e,t,n){return Bv("write")},t.move=function(e,t,n,r,a){return Bv("move")},t.createTensorFromGPUData=function(e,t,n){return Bv("createTensorFromGPUData")},t.memory=function(){return Bv("memory")},t.floatPrecision=function(){return Bv("floatPrecision")},t.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},t.dispose=function(){return Bv("dispose")},e}();function Bv(e){throw new Error("'"+e+"' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen")}function Wv(e){for(var t=e.length,n=0;t>0;)n=Math.random()*t|0,Gv(e,--t,n)}function Vv(e,t,n){return Math.max(e,Math.min(t,n))}function Uv(e){return e%2==0?e:e+1}function Gv(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function jv(e){for(var t=0,n=0;n<e.length;n++)t+=e[n];return t}function Hv(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function qv(e,t,n){void 0===n&&(n=""),Hv(Yv(e,t),(function(){return n+" Shapes "+e+" and "+t+" must match"}))}function Kv(e){Hv(null!=e,(function(){return"The input to the tensor constructor must be a non-null value."}))}function Xv(e){if(0===e.length)return 1;for(var t=e[0],n=1;n<e.length;n++)t*=e[n];return t}function Yv(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Jv(e){return e%1==0}function Zv(e){var t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function Qv(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function $v(e,t,n,r){return void 0===t&&(t=function(e){return 0}),new Promise((function(a,i){var o=0;!function s(){if(e())a();else{o++;var u=t(o);null!=n&&o>=n?i():null!=r?r(s,u):setTimeout(s,u)}}()}))}function eg(e,t){for(var n=1,r=-1,a=0;a<e.length;++a)if(e[a]>=0)n*=e[a];else if(-1===e[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(e[a]<0)throw Error("Shapes can not be < 0. Found "+e[a]+" at dim "+a);if(-1===r){if(t>0&&t!==n)throw Error("Size("+t+") must match the product of shape "+e);return e}if(0===n)throw Error("Cannot infer the missing size in ["+e+"] when there are 0 elements");if(t%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+t+" / "+n);var i=e.slice();return i[r]=t/n,i}function tg(e,t){var n=t.length;return Hv((e=null==e?t.map((function(e,t){return t})):[].concat(e)).every((function(e){return e>=-n&&e<n})),(function(){return"All values in axis param must be in range [-"+n+", "+n+") but got axis "+e})),Hv(e.every((function(e){return Jv(e)})),(function(){return"All values in axis param must be integers but got axis "+e})),e.map((function(e){return e<0?n+e:e}))}function ng(e,t){for(var n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||a?null:tg(t,e).sort(),o=0,s=0;s<e.length;++s){if(null!=i){if(i[o]===s&&1!==e[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+e[s]+"' is not 1");(null==i[o]||i[o]>s)&&1===e[s]&&(n.push(e[s]),r.push(s)),i[o]<=s&&o++}1!==e[s]&&(n.push(e[s]),r.push(s))}return{newShape:n,keptDims:r}}function rg(e,t){return ag(e,t)}function ag(e,t){var n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error("Unknown data type "+e);n=new Array(t)}return n}function ig(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+t+" being uploaded contains "+r+".")}}function og(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function sg(e,t){return"complex64"!==t&&(("float32"!==t||"complex64"===e)&&(("int32"!==t||"float32"===e||"complex64"===e)&&("bool"!==t||"bool"!==e)))}function ug(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error("Unknown dtype "+e)}function lg(e){if(null==e)return 0;var t=0;return e.forEach((function(e){return t+=e.length})),t}function cg(e){return"string"==typeof e||e instanceof String}function pg(e){return"boolean"==typeof e}function hg(e){return"number"==typeof e}function dg(e){return Array.isArray(e)?dg(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":hg(e)?"float32":cg(e)?"string":pg(e)?"bool":"float32"}function fg(e){return!!(e&&e.constructor&&e.call&&e.apply)}function mg(e,t){for(var n=t;n<e;++n)if(e%n==0)return n;return e}function vg(e){var t=e.length;if(t<2)return[];var n=new Array(t-1);n[t-2]=e[t-1];for(var r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function gg(e,t,n,r){void 0===r&&(r=!1);var a=new Array;if(1===t.length)for(var i=t[0]*(r?2:1),o=0;o<i;o++)a[o]=n[e+o];else for(var s=t[0],u=t.slice(1),l=u.reduce((function(e,t){return e*t}))*(r?2:1),c=0;c<s;c++)a[c]=gg(e+c*l,u,n,r);return a}function yg(e,t,n){if(void 0===n&&(n=!1),0===e.length)return t[0];var r=e.reduce((function(e,t){return e*t}))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error("["+e+"] does not match the input size "+t.length+(n?" for a complex tensor":"")+".");return gg(0,e,t,n)}function bg(e,t){if(Array.isArray(e))return e;if("float32"===t)return e instanceof Float32Array?e:new Float32Array(e);if("int32"===t)return e instanceof Int32Array?e:new Int32Array(e);if("bool"===t||"string"===t)return Uint8Array.from(new Int32Array(e));throw new Error("Unknown dtype "+t)}function xg(e,t){for(var n=wg(e,t),r=0;r<n.length;r++)n[r]=1;return n}function wg(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error("Unknown data type "+t)}function kg(e,t){var n=e.reduce((function(e,t){return e*t}),1);if(null==t||"float32"===t)return yg(e,new Float32Array(n));if("int32"===t)return yg(e,new Int32Array(n));if("bool"===t)return yg(e,new Uint8Array(n));throw new Error("Unknown data type "+t)}function Ng(e){e.forEach((function(t){Hv(Number.isInteger(t)&&t>=0,(function(){return"Tensor must have a shape comprised of positive integers but got shape ["+e+"]."}))}))}function Ig(e,t,n){if(0===t)return 0;if(1===t)return e[0];for(var r=e[e.length-1],a=0;a<e.length-1;++a)r+=n[a]*e[a];return r}function Sg(e,t,n){if(0===t)return[];if(1===t)return[e];for(var r=new Array(t),a=0;a<r.length-1;++a)r[a]=Math.floor(e/n[a]),e-=r[a]*n[a];return r[r.length-1]=e,r}function Tg(e){return e&&e.then&&"function"==typeof e.then}var Cg,Eg="tfjsflags",Ag=function(){function e(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Rg,this.populateURLFlags()}var t=e.prototype;return t.setPlatform=function(e,t){null!=this.platform&&(Fg().getBool("IS_TEST")||Fg().getBool("PROD")||console.warn("Platform "+this.platformName+" has already been set. Overwriting the platform with "+e+".")),this.platformName=e,this.platform=t},t.registerFlag=function(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){var r=this.urlFlags[e];Fg().getBool("IS_TEST")||Fg().getBool("PROD")||console.warn("Setting feature override from URL "+e+": "+r+"."),this.set(e,r)}},t.getAsync=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t in this.flags)){e.next=2;break}return e.abrupt("return",this.flags[t]);case 2:return e.next=4,this.evaluateFlag(t);case 4:return this.flags[t]=e.sent,e.abrupt("return",this.flags[t]);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.get=function(e){if(e in this.flags)return this.flags[e];var t=this.evaluateFlag(e);if(Tg(t))throw new Error("Flag "+e+" cannot be synchronously evaluated. Please use getAsync() instead.");return this.flags[e]=t,this.flags[e]},t.getNumber=function(e){return this.get(e)},t.getBool=function(e){return this.get(e)},t.getFlags=function(){return this.flags},t.set=function(e,t){if(null==this.flagRegistry[e])throw new Error("Cannot set flag "+e+" as it has not been registered.");this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)},t.evaluateFlag=function(e){if(null==this.flagRegistry[e])throw new Error("Cannot evaluate flag '"+e+"': no evaluation function found.");return this.flagRegistry[e].evaluationFn()},t.setFlags=function(e){this.flags=Object.assign({},e)},t.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags()},t.populateURLFlags=function(){var e=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var t=this.getQueryParams(this.global.location.search);if(Eg in t)t.tfjsflags.split(",").forEach((function(t){var n=t.split(":"),r=n[0],a=n[1];e.urlFlags[r]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error("Could not parse value flag value "+t+" for flag "+e+".")}(r,a)}))}},Tv(e,[{key:"features",get:function(){return this.flags}}]),e}();function Rg(e){var t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return _g(t,r[0],r[1]),r.join("=")})),t}function _g(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function Fg(){return e.ENV}function Og(){if(null==Cg){var e;if("undefined"!=typeof window)e=window;else if("undefined"!=typeof global)e=global;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}Cg=e}return Cg}function Dg(e,t){var n,r=(null==(n=Og())._tfGlobals&&(n._tfGlobals=new Map),n._tfGlobals);if(r.has(e))return r.get(e);var a=t();return r.set(e,a),r.get(e)}e.ENV=null;var Mg="Abs",Lg="Acos",zg="Acosh",Pg="Add",Bg="AddN",Wg="All",Vg="Any",Ug="ArgMax",Gg="ArgMin",jg="Asin",Hg="Asinh",qg="Atan",Kg="Atanh",Xg="Atan2",Yg="AvgPool",Jg="AvgPoolGrad",Zg="AvgPool3D",Qg="AvgPool3DGrad",$g="BatchMatMul",ey="BatchToSpaceND",ty="Bincount",ny="BroadcastTo",ry="BroadcastArgs",ay="Cast",iy="Ceil",oy="ClipByValue",sy="Complex",uy="ComplexAbs",ly="Concat",cy="Conv2D",py="Conv2DBackpropFilter",hy="Conv2DBackpropInput",dy="Conv3D",fy="Conv3DBackpropFilterV2",my="Conv3DBackpropInputV2",vy="Cos",gy="Cosh",yy="Cumprod",by="Cumsum",xy="CropAndResize",wy="DenseBincount",ky="DepthToSpace",Ny="DepthwiseConv2dNative",Iy="DepthwiseConv2dNativeBackpropFilter",Sy="DepthwiseConv2dNativeBackpropInput",Ty="Diag",Cy="Dilation2D",Ey="Dilation2DBackpropInput",Ay="Dilation2DBackpropFilter",Ry="RealDiv",_y="Einsum",Fy="Elu",Oy="EluGrad",Dy="Erf",My="Equal",Ly="Exp",zy="ExpandDims",Py="Expm1",By="FFT",Wy="Fill",Vy="FlipLeftRight",Uy="Floor",Gy="FloorDiv",jy="FusedBatchNorm",Hy="GatherV2",qy="GatherNd",Ky="Greater",Xy="GreaterEqual",Yy="Identity",Jy="IFFT",Zy="Imag",Qy="IsFinite",$y="IsInf",eb="IsNan",tb="LeakyRelu",nb="Less",rb="LessEqual",ab="LinSpace",ib="Log",ob="Log1p",sb="LogicalAnd",ub="LogicalNot",lb="LogicalOr",cb="LogSoftmax",pb="LRN",hb="LRNGrad",db="Max",fb="Maximum",mb="MaxPool",vb="MaxPoolGrad",gb="MaxPool3D",yb="MaxPool3DGrad",bb="MaxPoolWithArgmax",xb="Mean",wb="Min",kb="Minimum",Nb="MirrorPad",Ib="Mod",Sb="Multinomial",Tb="Multiply",Cb="Neg",Eb="NotEqual",Ab="NonMaxSuppressionV3",Rb="NonMaxSuppressionV4",_b="NonMaxSuppressionV5",Fb="OnesLike",Ob="OneHot",Db="Pack",Mb="PadV2",Lb="Pow",zb="Prelu",Pb="Prod",Bb="RaggedGather",Wb="RaggedRange",Vb="RaggedTensorToTensor",Ub="Range",Gb="Real",jb="Reciprocal",Hb="Relu",qb="Reshape",Kb="ResizeNearestNeighbor",Xb="ResizeNearestNeighborGrad",Yb="ResizeBilinear",Jb="ResizeBilinearGrad",Zb="Relu6",Qb="Reverse",$b="Round",ex="Rsqrt",tx="ScatterNd",nx="TensorScatterUpdate",rx="SearchSorted",ax="Select",ix="Selu",ox="Slice",sx="Sin",ux="Sinh",lx="Sign",cx="Sigmoid",px="Softplus",hx="Sqrt",dx="Sum",fx="SpaceToBatchND",mx="SplitV",vx="Softmax",gx="SparseFillEmptyRows",yx="SparseReshape",bx="SparseSegmentMean",xx="SparseSegmentSum",wx="SparseToDense",kx="SquaredDifference",Nx="Square",Ix="StaticRegexReplace",Sx="StridedSlice",Tx="StringNGrams",Cx="StringSplit",Ex="StringToHashBucketFast",Ax="Sub",Rx="Tan",_x="Tanh",Fx="Tile",Ox="TopK",Dx="Transform",Mx="Transpose",Lx="Unique",zx="Unpack",Px="UnsortedSegmentSum",Bx="ZerosLike",Wx="Step",Vx="FromPixels",Ux="RotateWithOffset",Gx="_FusedMatMul",jx="FusedConv2D",Hx="FusedDepthwiseConv2D";function qx(){var e;Fg().getBool("IS_TEST")||Fg().getBool("PROD")||(e=console).warn.apply(e,arguments)}var Kx=Dg("kernelRegistry",(function(){return new Map})),Xx=Dg("gradRegistry",(function(){return new Map}));function Yx(e,t){var n=ew(e,t);return Kx.get(n)}function Jx(e){return Xx.get(e)}function Zx(e){for(var t=Kx.entries(),n=[];;){var r=t.next(),a=r.done,i=r.value;if(a)break;var o=i[0],s=i[1];o.split("_")[0]===e&&n.push(s)}return n}function Qx(e){var t=e.kernelName,n=e.backendName,r=ew(t,n);Kx.has(r)&&qx("The kernel '"+t+"' for backend '"+n+"' is already registered"),Kx.set(r,e)}function $x(e){var t=e.kernelName;Xx.has(t)&&Fg().getBool("DEBUG")&&qx("Overriding the gradient for '"+t+"'"),Xx.set(t,e)}function ew(e,t){return t+"_"+e}var tw=rw,nw=null;try{nw=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function rw(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function aw(e){return!0===(e&&e.__isLong__)}rw.prototype.__isLong__,Object.defineProperty(rw.prototype,"__isLong__",{value:!0}),rw.isLong=aw;var iw={},ow={};function sw(e,t){var n,r,a;return t?(a=0<=(e>>>=0)&&e<256)&&(r=ow[e])?r:(n=lw(e,(0|e)<0?-1:0,!0),a&&(ow[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(r=iw[e])?r:(n=lw(e,e<0?-1:0,!1),a&&(iw[e]=n),n)}function uw(e,t){if(isNaN(e))return t?yw:gw;if(t){if(e<0)return yw;if(e>=fw)return Nw}else{if(e<=-mw)return Iw;if(e+1>=mw)return kw}return e<0?uw(-e,t).neg():lw(e%dw|0,e/dw|0,t)}function lw(e,t,n){return new rw(e,t,n)}rw.fromInt=sw,rw.fromNumber=uw,rw.fromBits=lw;var cw=Math.pow;function pw(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return gw;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return pw(e.substring(1),t,n).neg();for(var a=uw(cw(n,8)),i=gw,o=0;o<e.length;o+=8){var s=Math.min(8,e.length-o),u=parseInt(e.substring(o,o+s),n);if(s<8){var l=uw(cw(n,s));i=i.mul(l).add(uw(u))}else i=(i=i.mul(a)).add(uw(u))}return i.unsigned=t,i}function hw(e,t){return"number"==typeof e?uw(e,t):"string"==typeof e?pw(e,t):lw(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}rw.fromString=pw,rw.fromValue=hw;var dw=4294967296,fw=dw*dw,mw=fw/2,vw=sw(1<<24),gw=sw(0);rw.ZERO=gw;var yw=sw(0,!0);rw.UZERO=yw;var bw=sw(1);rw.ONE=bw;var xw=sw(1,!0);rw.UONE=xw;var ww=sw(-1);rw.NEG_ONE=ww;var kw=lw(-1,2147483647,!1);rw.MAX_VALUE=kw;var Nw=lw(-1,-1,!0);rw.MAX_UNSIGNED_VALUE=Nw;var Iw=lw(0,-2147483648,!1);rw.MIN_VALUE=Iw;var Sw=rw.prototype;Sw.toInt=function(){return this.unsigned?this.low>>>0:this.low},Sw.toNumber=function(){return this.unsigned?(this.high>>>0)*dw+(this.low>>>0):this.high*dw+(this.low>>>0)},Sw.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(Iw)){var t=uw(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var a=uw(cw(e,6),this.unsigned),i=this,o="";;){var s=i.div(a),u=(i.sub(s.mul(a)).toInt()>>>0).toString(e);if((i=s).isZero())return u+o;for(;u.length<6;)u="0"+u;o=""+u+o}},Sw.getHighBits=function(){return this.high},Sw.getHighBitsUnsigned=function(){return this.high>>>0},Sw.getLowBits=function(){return this.low},Sw.getLowBitsUnsigned=function(){return this.low>>>0},Sw.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Iw)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},Sw.isZero=function(){return 0===this.high&&0===this.low},Sw.eqz=Sw.isZero,Sw.isNegative=function(){return!this.unsigned&&this.high<0},Sw.isPositive=function(){return this.unsigned||this.high>=0},Sw.isOdd=function(){return 1==(1&this.low)},Sw.isEven=function(){return 0==(1&this.low)},Sw.equals=function(e){return aw(e)||(e=hw(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},Sw.eq=Sw.equals,Sw.notEquals=function(e){return!this.eq(e)},Sw.neq=Sw.notEquals,Sw.ne=Sw.notEquals,Sw.lessThan=function(e){return this.comp(e)<0},Sw.lt=Sw.lessThan,Sw.lessThanOrEqual=function(e){return this.comp(e)<=0},Sw.lte=Sw.lessThanOrEqual,Sw.le=Sw.lessThanOrEqual,Sw.greaterThan=function(e){return this.comp(e)>0},Sw.gt=Sw.greaterThan,Sw.greaterThanOrEqual=function(e){return this.comp(e)>=0},Sw.gte=Sw.greaterThanOrEqual,Sw.ge=Sw.greaterThanOrEqual,Sw.compare=function(e){if(aw(e)||(e=hw(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},Sw.comp=Sw.compare,Sw.negate=function(){return!this.unsigned&&this.eq(Iw)?Iw:this.not().add(bw)},Sw.neg=Sw.negate,Sw.add=function(e){aw(e)||(e=hw(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,a=65535&this.low,i=e.high>>>16,o=65535&e.high,s=e.low>>>16,u=0,l=0,c=0,p=0;return c+=(p+=a+(65535&e.low))>>>16,l+=(c+=r+s)>>>16,u+=(l+=n+o)>>>16,u+=t+i,lw((c&=65535)<<16|(p&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},Sw.subtract=function(e){return aw(e)||(e=hw(e)),this.add(e.neg())},Sw.sub=Sw.subtract,Sw.multiply=function(e){if(this.isZero())return gw;if(aw(e)||(e=hw(e)),nw)return lw(nw.mul(this.low,this.high,e.low,e.high),nw.get_high(),this.unsigned);if(e.isZero())return gw;if(this.eq(Iw))return e.isOdd()?Iw:gw;if(e.eq(Iw))return this.isOdd()?Iw:gw;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(vw)&&e.lt(vw))return uw(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,a=65535&this.low,i=e.high>>>16,o=65535&e.high,s=e.low>>>16,u=65535&e.low,l=0,c=0,p=0,h=0;return p+=(h+=a*u)>>>16,c+=(p+=r*u)>>>16,p&=65535,c+=(p+=a*s)>>>16,l+=(c+=n*u)>>>16,c&=65535,l+=(c+=r*s)>>>16,c&=65535,l+=(c+=a*o)>>>16,l+=t*u+n*s+r*o+a*i,lw((p&=65535)<<16|(h&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},Sw.mul=Sw.multiply,Sw.divide=function(e){if(aw(e)||(e=hw(e)),e.isZero())throw Error("division by zero");var t,n,r;if(nw)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?lw((this.unsigned?nw.div_u:nw.div_s)(this.low,this.high,e.low,e.high),nw.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?yw:gw;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return yw;if(e.gt(this.shru(1)))return xw;r=yw}else{if(this.eq(Iw))return e.eq(bw)||e.eq(ww)?Iw:e.eq(Iw)?bw:(t=this.shr(1).div(e).shl(1)).eq(gw)?e.isNegative()?bw:ww:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(Iw))return this.unsigned?yw:gw;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=gw}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(t)/Math.LN2),i=a<=48?1:cw(2,a-48),o=uw(t),s=o.mul(e);s.isNegative()||s.gt(n);)s=(o=uw(t-=i,this.unsigned)).mul(e);o.isZero()&&(o=bw),r=r.add(o),n=n.sub(s)}return r},Sw.div=Sw.divide,Sw.modulo=function(e){return aw(e)||(e=hw(e)),nw?lw((this.unsigned?nw.rem_u:nw.rem_s)(this.low,this.high,e.low,e.high),nw.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},Sw.mod=Sw.modulo,Sw.rem=Sw.modulo,Sw.not=function(){return lw(~this.low,~this.high,this.unsigned)},Sw.and=function(e){return aw(e)||(e=hw(e)),lw(this.low&e.low,this.high&e.high,this.unsigned)},Sw.or=function(e){return aw(e)||(e=hw(e)),lw(this.low|e.low,this.high|e.high,this.unsigned)},Sw.xor=function(e){return aw(e)||(e=hw(e)),lw(this.low^e.low,this.high^e.high,this.unsigned)},Sw.shiftLeft=function(e){return aw(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?lw(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):lw(0,this.low<<e-32,this.unsigned)},Sw.shl=Sw.shiftLeft,Sw.shiftRight=function(e){return aw(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?lw(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):lw(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},Sw.shr=Sw.shiftRight,Sw.shiftRightUnsigned=function(e){if(aw(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?lw(this.low>>>e|t<<32-e,t>>>e,this.unsigned):lw(32===e?t:t>>>e-32,0,this.unsigned)},Sw.shru=Sw.shiftRightUnsigned,Sw.shr_u=Sw.shiftRightUnsigned,Sw.toSigned=function(){return this.unsigned?lw(this.low,this.high,!1):this},Sw.toUnsigned=function(){return this.unsigned?this:lw(this.low,this.high,!0)},Sw.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},Sw.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},Sw.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},rw.fromBytes=function(e,t,n){return n?rw.fromBytesLE(e,t):rw.fromBytesBE(e,t)},rw.fromBytesLE=function(e,t){return new rw(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},rw.fromBytesBE=function(e,t){return new rw(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var Tw=tw||{__proto__:null,default:tw,__moduleExports:tw};function Cw(e){return Tw.fromString(e,!0,16)}var Ew=Cw("c3a5c85c97cb3127"),Aw=Cw("b492b66fbe98f273"),Rw=Cw("9ae16a3b2f90404f");function _w(e){return e.xor(e.shru(47))}function Fw(e,t,n){var r=e.slice(t,t+n);return Tw.fromBytes(Array.from(r),!0,!0)}function Ow(e,t){return Fw(e,t,8)}function Dw(e,t){return Fw(e,t,4)}function Mw(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function Lw(e,t,n){void 0===n&&(n=Cw("9ddfea08eb382d69"));var r=e.xor(t).mul(n);r=r.xor(r.shru(47));var a=t.xor(r).mul(n);return a=(a=a.xor(a.shru(47))).mul(n)}function zw(e,t,n,r){return function(e,t,n,r,a,i){a=a.add(e),i=Mw(i.add(a).add(r),21);var o=a;return a=(a=a.add(t)).add(n),i=i.add(Mw(a,44)),[a.add(r),i.add(o)]}(Ow(e,t),Ow(e,t+8),Ow(e,t+16),Ow(e,t+24),n,r)}function Pw(e,t){void 0===t&&(t=e.length);var n=Tw.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t){if(void 0===t&&(t=e.length),t>=8){var n=Rw.add(2*t),r=Ow(e,0).add(Rw),a=Ow(e,t-8);return Lw(Mw(a,37).mul(n).add(r),Mw(r,25).add(a).mul(n),n)}if(t>=4){var i=Rw.add(2*t);return Lw(Dw(e,0).shl(3).add(t),Dw(e,t-4),i)}if(t>0){var o=e[0]+(e[t>>1]<<8),s=t+(e[t-1]<<2);return _w(Rw.mul(o).xor(Ew.mul(s))).mul(Rw)}return Rw}(e,t):function(e,t){void 0===t&&(t=e.length);var n=Rw.add(2*t),r=Ow(e,0).mul(Aw),a=Ow(e,8),i=Ow(e,t-8).mul(n),o=Ow(e,t-16).mul(Rw);return Lw(Mw(r.add(a),43).add(Mw(i,30)).add(o),r.add(Mw(a.add(Rw),18)).add(i),n)}(e,t);if(t<=64)return function(e,t){void 0===t&&(t=e.length);var n=Rw.add(2*t),r=Ow(e,0).mul(Rw),a=Ow(e,8),i=Ow(e,t-8).mul(n),o=Ow(e,t-16).mul(Rw),s=Mw(r.add(a),43).add(Mw(i,30)).add(o),u=Lw(s,r.add(Mw(a.add(Rw),18)).add(i),n),l=Ow(e,16).mul(n),c=Ow(e,24),p=s.add(Ow(e,t-32)).mul(n),h=u.add(Ow(e,t-24)).mul(n);return Lw(Mw(l.add(c),43).add(Mw(p,30)).add(h),l.add(Mw(c.add(r),18)).add(p),n)}(e,t);var r=n,a=n.mul(Aw).add(113),i=_w(a.mul(Rw).add(113)).mul(Rw),o=[Tw.UZERO,Tw.UZERO],s=[Tw.UZERO,Tw.UZERO];r=r.mul(Rw).add(Ow(e,0));var u=0,l=64*(t-1>>6),c=l+(t-1&63)-63;do{r=Mw(r.add(a).add(o[0]).add(Ow(e,u+8)),37).mul(Aw),a=Mw(a.add(o[1]).add(Ow(e,u+48)),42).mul(Aw),r=r.xor(s[1]),a=a.add(o[0]).add(Ow(e,u+40)),i=Mw(i.add(s[0]),33).mul(Aw),o=zw(e,u,o[1].mul(Aw),r.add(s[0])),s=zw(e,u+32,i.add(s[1]),a.add(Ow(e,u+16)));var p=[r,i];i=p[0],r=p[1],u+=64}while(u!==l);var h=Aw.add(i.and(255).shl(1));u=c,s[0]=s[0].add(t-1&63),o[0]=o[0].add(s[0]),s[0]=s[0].add(o[0]),r=Mw(r.add(a).add(o[0]).add(Ow(e,u+8)),37).mul(h),a=Mw(a.add(o[1]).add(Ow(e,u+48)),42).mul(h),r=r.xor(s[1].mul(9)),a=a.add(o[0].mul(9).add(Ow(e,u+40))),i=Mw(i.add(s[0]),33).mul(h),o=zw(e,u,o[1].mul(h),r.add(s[0])),s=zw(e,u+32,i.add(s[1]),a.add(Ow(e,u+16)));var d=[r,i];return i=d[0],r=d[1],Lw(Lw(o[0],s[0],h).add(_w(a).mul(Ew)).add(i),Lw(o[1],s[1],h).add(r),h)}function Bw(e,t){return"string"===t?Gw(e):Ww([e],t)}function Ww(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=qw(e)),Fg().getBool("DEBUG")&&ig(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){for(var n=new Uint8Array(e.length),r=0;r<n.length;++r)0!==Math.round(e[r])&&(n[r]=1);return n}throw new Error("Unknown data type "+t)}function Vw(){return Fg().platform.now()}function Uw(e,t){return Fg().platform.fetch(e,t)}function Gw(e,t){return void 0===t&&(t="utf-8"),t=t||"utf-8",Fg().platform.encode(e,t)}function jw(e,t){return void 0===t&&(t="utf-8"),t=t||"utf-8",Fg().platform.decode(e,t)}function Hw(e){return Fg().platform.isTypedArray(e)}function qw(e,t,n){if(void 0===t&&(t=[]),void 0===n&&(n=!1),null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||Tg(e)||null==e||Hw(e)&&n)t.push(e);else if(Array.isArray(e)||Hw(e))for(var r=0;r<e.length;++r)qw(e[r],t,n);else{for(var a=-1,i=0,o=Object.keys(e);i<o.length;i++){var s=o[i];/^([1-9]+[0-9]*|0)$/.test(s)&&(a=Math.max(a,Number(s)))}for(var u=0;u<=a;u++)qw(e[u],t,n)}return t}var Kw={__proto__:null,createScalarValue:Bw,toTypedArray:Ww,now:Vw,fetch:Uw,encodeString:Gw,decodeString:jw,isTypedArray:Hw,flatten:qw,shuffle:Wv,shuffleCombo:function(e,t){if(e.length!==t.length)throw new Error("Array sizes must match to be shuffled together First array length was "+e.length+"Second array length was "+t.length);for(var n=e.length,r=0;n>0;)r=Math.random()*n|0,Gv(e,--n,r),Gv(t,n,r)},clamp:Vv,nearestLargerEven:Uv,swap:Gv,sum:jv,randUniform:function(e,t){var n=Math.random();return t*n+(1-n)*e},distSquared:function(e,t){for(var n=0,r=0;r<e.length;r++){var a=Number(e[r])-Number(t[r]);n+=a*a}return n},assert:Hv,assertShapesMatch:qv,assertNonNull:Kv,sizeFromShape:Xv,isScalarShape:function(e){return 0===e.length},arraysEqual:Yv,isInt:Jv,tanh:function(e){if(null!=Math.tanh)return Math.tanh(e);if(e===1/0)return 1;if(e===-1/0)return-1;var t=Math.exp(2*e);return(t-1)/(t+1)},sizeToSquarishShape:Zv,createShuffledIndices:function(e){for(var t=new Uint32Array(e),n=0;n<e;++n)t[n]=n;return Wv(t),t},rightPad:Qv,repeatedTry:$v,inferFromImplicitShape:eg,parseAxisParam:tg,squeezeShape:ng,getTypedArrayFromDType:rg,getArrayFromDType:ag,checkConversionForErrors:ig,isValidDtype:og,hasEncodingLoss:sg,bytesPerElement:ug,bytesFromStringArray:lg,isString:cg,isBoolean:pg,isNumber:hg,inferDtype:dg,isFunction:fg,nearestDivisor:mg,computeStrides:vg,toNestedArray:yg,convertBackendValuesAndArrayBuffer:bg,makeOnesTypedArray:xg,makeZerosTypedArray:wg,makeZerosNestedTypedArray:kg,assertNonNegativeIntegerDimensions:Ng,locToIndex:Ig,indexToLoc:Sg,isPromise:Tg,hexToLong:Cw,fingerPrint64:Pw},Xw=function(){function e(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new Yw)}var t=e.prototype;return t.profileKernel=function(e,t,n){var r,a,i=function(){r=n()},o=Vw();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(i);else{i();for(var s,u=Lv(r);!(s=u()).done;){s.value.dataSync()}a=Promise.resolve({kernelMs:Vw()-o})}if(Fg().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(var l=function(t){var n=r[t];n.data().then((function(t){!function(e,t,n){if("float32"!==t)return!1;for(var r=0;r<e.length;r++){var a=e[r];if(isNaN(a)||!isFinite(a))return console.warn("Found "+a+" in the result of '"+n+"'"),!0}}(t,n.dtype,e)}))},c=0;c<r.length;c++)l(c);return{kernelName:e,outputs:r,inputs:t,timeMs:a.then((function(e){return e.kernelMs})),extraInfo:a.then((function(e){return null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""}))}},t.logKernelProfile=function(e){var t=this,n=e.kernelName,r=e.outputs,a=e.timeMs,i=e.inputs,o=e.extraInfo;r.forEach((function(e){Promise.all([e.data(),a,o]).then((function(r){t.logger.logKernelProfile(n,e,r[0],r[1],i,r[2])}))}))},e}();var Yw=function(){function e(){}return e.prototype.logKernelProfile=function(e,t,n,r,a,i){var o="number"==typeof r?Qv(r+"ms",9):r.error,s=Qv(e,25),u=t.rank,l=t.size,c=Qv(t.shape.toString(),14),p="";for(var h in a){var d=a[h];if(null!=d){var f=d.shape||t.shape,m=f.length;p+=h+": "+m+"D "+(m>0?f:"")+" "}}console.log("%c"+s+"\t%c"+o+"\t%c"+u+"D "+c+"\t%c"+l+"\t%c"+p+"\t%c"+i,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")},e}();function Jw(e,t,n,r){var a=vg(t),i=function(e,t,n,r){var a=Xv(t),i=r[r.length-1],o=new Array(i).fill(0),s=t.length,u="complex64"===n?ek(e):e;if(s>1)for(var l=0;l<a/i;l++)for(var c=l*i,p=0;p<i;p++)o[p]=Math.max(o[p],Zw(u[c+p],0,n).length);return o}(e,t,n,a),o=t.length,s=$w(e,t,n,a,i),u=["Tensor"];return r&&(u.push(" dtype: "+n),u.push(" rank: "+o),u.push(" shape: ["+t+"]"),u.push(" values:")),u.push(s.map((function(e){return" "+e})).join("\n")),u.join("\n")}function Zw(e,t,n){return Qv(Array.isArray(e)?parseFloat(e[0].toFixed(7))+" + "+parseFloat(e[1].toFixed(7))+"j":cg(e)?"'"+e+"'":"bool"===n?Qw(e):parseFloat(e.toFixed(7)).toString(),t)}function Qw(e){return 0===e?"false":"true"}function $w(e,t,n,r,a,i){void 0===i&&(i=!0);var o="complex64"===n?2:1,s=t[0],u=t.length;if(0===u)return"complex64"===n?[Zw(ek(e)[0],0,n)]:"bool"===n?[Qw(e[0])]:[e[0].toString()];if(1===u){if(s>20){var l=3*o,c=Array.from(e.slice(0,l)),p=Array.from(e.slice((s-3)*o,s*o));return"complex64"===n&&(c=ek(c),p=ek(p)),["["+c.map((function(e,t){return Zw(e,a[t],n)})).join(", ")+", ..., "+p.map((function(e,t){return Zw(e,a[s-3+t],n)})).join(", ")+"]"]}return["["+("complex64"===n?ek(e):Array.from(e)).map((function(e,t){return Zw(e,a[t],n)})).join(", ")+"]"]}var h=t.slice(1),d=r.slice(1),f=r[0]*o,m=[];if(s>20){for(var v=0;v<3;v++){var g=v*f,y=g+f;m.push.apply(m,$w(e.slice(g,y),h,n,d,a,!1))}m.push("...");for(var b=s-3;b<s;b++){var x=b*f,w=x+f;m.push.apply(m,$w(e.slice(x,w),h,n,d,a,b===s-1))}}else for(var k=0;k<s;k++){var N=k*f,I=N+f;m.push.apply(m,$w(e.slice(N,I),h,n,d,a,k===s-1))}var S=2===u?",":"";m[0]="["+(s>0?m[0]+S:"");for(var T=1;T<m.length-1;T++)m[T]=" "+m[T]+S;for(var C=",\n",E=2;E<u;E++)C+="\n";return m[m.length-1]=" "+m[m.length-1]+"]"+(i?"":C),m}function ek(e){for(var t=[],n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var tk=function(){function e(e,t,n){var r=this;if(this.dtype=t,this.shape=e.slice(),this.size=Xv(e),null!=n){var a=n.length;Hv(a===this.size,(function(){return"Length of values '"+a+"' does not match the size inferred by the shape '"+r.size+"'."}))}if("complex64"===t)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||ag(t,this.size),this.strides=vg(e)}var t=e.prototype;return t.set=function(e){for(var t=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]),Hv(r.length===this.rank,(function(){return"The number of provided coordinates ("+r.length+") must match the rank ("+t.rank+")"}));var i=this.locToIndex(r);this.values[i]=e},t.get=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];0===t.length&&(t=[0]);for(var r=0,a=0,i=t;a<i.length;a++){var o=i[a];if(o<0||o>=this.shape[r]){var s="Requested out of range element at "+t+". Buffer shape="+this.shape;throw new Error(s)}r++}for(var u=t[t.length-1],l=0;l<t.length-1;++l)u+=this.strides[l]*t[l];return this.values[u]},t.locToIndex=function(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];for(var t=e[e.length-1],n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t},t.indexToLoc=function(e){if(0===this.rank)return[];if(1===this.rank)return[e];for(var t=new Array(this.shape.length),n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t},t.toTensor=function(){return nk().makeTensor(this.values,this.shape,this.dtype)},Tv(e,[{key:"rank",get:function(){return this.shape.length}}]),e}(),nk=null,rk=null;var ak=function(){function e(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=Xv(e),this.strides=vg(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}var t=e.prototype;return t.buffer=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.data();case 2:return t=e.sent,e.abrupt("return",rk.buffer(this.shape,this.dtype,t));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.bufferSync=function(){return rk.buffer(this.shape,this.dtype,this.dataSync())},t.array=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.data();case 2:return t=e.sent,e.abrupt("return",yg(this.shape,t,"complex64"===this.dtype));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.arraySync=function(){return yg(this.shape,this.dataSync(),"complex64"===this.dtype)},t.data=function(){var e=Iv(kv().mark((function e(){var t,n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.throwIfDisposed(),t=nk().read(this.dataId),"string"!==this.dtype){e.next=13;break}return e.next=5,t;case 5:return n=e.sent,e.prev=6,e.abrupt("return",n.map((function(e){return jw(e)})));case 10:throw e.prev=10,e.t0=e.catch(6),new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");case 13:return e.abrupt("return",t);case 14:case"end":return e.stop()}}),e,this,[[6,10]])})));return function(){return e.apply(this,arguments)}}(),t.dataToGPU=function(e){return this.throwIfDisposed(),nk().readToGPU(this.dataId,e)},t.dataSync=function(){this.throwIfDisposed();var e=nk().readSync(this.dataId);if("string"===this.dtype)try{return e.map((function(e){return jw(e)}))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e},t.bytes=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.throwIfDisposed(),e.next=3,nk().read(this.dataId);case 3:if(t=e.sent,"string"!==this.dtype){e.next=8;break}return e.abrupt("return",t);case 8:return e.abrupt("return",new Uint8Array(t.buffer));case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.dispose=function(){this.isDisposed||(nk().disposeTensor(this),this.isDisposedInternal=!0)},t.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.")},t.print=function(e){return void 0===e&&(e=!1),rk.print(this,e)},t.clone=function(){return this.throwIfDisposed(),rk.clone(this)},t.toString=function(e){return void 0===e&&(e=!1),Jw(this.dataSync(),this.shape,this.dtype,e)},t.cast=function(e){return this.throwIfDisposed(),rk.cast(this,e)},t.variable=function(e,t,n){return void 0===e&&(e=!0),this.throwIfDisposed(),nk().makeVariable(this,e,t,n)},Tv(e,[{key:"rank",get:function(){return this.shape.length}},{key:"isDisposed",get:function(){return this.isDisposedInternal}}]),e}();function ik(){return Dg("Tensor",(function(){return ak}))}Object.defineProperty(ak,Symbol.hasInstance,{value:function(e){return!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}}),ik();var ok,sk,uk,lk,ck,pk=function(e){function t(t,n,r,a){var i;return(i=e.call(this,t.shape,t.dtype,t.dataId,a)||this).trainable=n,i.name=r,i}Cv(t,e);var n=t.prototype;return n.assign=function(e){if(e.dtype!==this.dtype)throw new Error("dtype of the new value ("+e.dtype+") and previous value ("+this.dtype+") must match");if(!Yv(e.shape,this.shape))throw new Error("shape of the new value ("+e.shape+") and previous value ("+this.shape+") must match");nk().disposeTensor(this),this.dataId=e.dataId,nk().incRef(this,null)},n.dispose=function(){nk().disposeVariable(this),this.isDisposedInternal=!0},t}(ak);Object.defineProperty(pk,Symbol.hasInstance,{value:function(e){return e instanceof ak&&null!=e.assign&&e.assign instanceof Function}}),(ok=e.Rank||(e.Rank={})).R0="R0",ok.R1="R1",ok.R2="R2",ok.R3="R3",ok.R4="R4",ok.R5="R5",ok.R6="R6",function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(sk||(sk={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(uk||(uk={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(lk||(lk={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(ck||(ck={}));var hk={float32:lk,int32:sk,bool:uk,complex64:ck};function dk(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error("Can not upcast "+e+" with "+t)}return hk[e][t]}function fk(e){return dk(e,"int32")}function mk(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function vk(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}function gk(e,t){if(e.dtype===t.dtype)return[e,t];var n=dk(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function yk(e,t){Hv(e.dtype===t.dtype,(function(){return"The dtypes of the first("+e.dtype+") and second("+t.dtype+") input must match"}))}function bk(e,t){return t.some((function(t){return t.id===e.id}))}function xk(e){var t=[];return wk(e,t,new Set),t}function wk(e,t,n){if(null!=e)if(e instanceof ak)t.push(e);else if(r=e,Array.isArray(r)||"object"==typeof r){var r,a=e;for(var i in a){var o=a[i];n.has(o)||(n.add(o),wk(o,t,n))}}}var kk={__proto__:null,makeTypesMatch:gk,assertTypesMatch:yk,isTensorInList:bk,getTensorsInContainer:xk};function Nk(e){return null!=e.kernelName}var Ik=function(){function e(){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,get kernelNames(){return Array.from(new Set(this.kernels.map((function(e){return e.name}))))}}}return e.prototype.dispose=function(){for(var e in this.registeredVariables)this.registeredVariables[e].dispose()},e}(),Sk=function(){function e(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Ik}var t=e.prototype;return t.ready=function(){var e=Iv(kv().mark((function e(){var t,n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.pendingBackendInit){e.next=2;break}return e.abrupt("return",this.pendingBackendInit.then((function(){})));case 2:if(null==this.backendInstance){e.next=4;break}return e.abrupt("return");case 4:t=this.getSortedBackends(),n=0;case 6:if(!(n<t.length)){e.next=18;break}return r=t[n],e.next=10,this.initializeBackend(r).success;case 10:if(!e.sent){e.next=15;break}return e.next=14,this.setBackend(r);case 14:return e.abrupt("return");case 15:n++,e.next=6;break;case 18:throw new Error("Could not initialize any backends, all backend initializations failed.");case 19:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.backendNames=function(){return Object.keys(this.registryFactory)},t.findBackend=function(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;if(this.initializeBackend(e).asyncInit)return null}return this.registry[e]},t.findBackendFactory=function(e){return e in this.registryFactory?this.registryFactory[e].factory:null},t.registerBackend=function(e,t,n){return void 0===n&&(n=1),e in this.registryFactory?(qx(e+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[e]={factory:t,priority:n},!0)},t.setBackend=function(){var e=Iv(kv().mark((function e(t){var n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.registryFactory[t]){e.next=2;break}throw new Error("Backend name '"+t+"' not found in registry");case 2:if(this.backendName=t,null!=this.registry[t]){e.next=16;break}if(this.backendInstance=null,n=this.initializeBackend(t),r=n.success,!n.asyncInit){e.next=12;break}return e.next=9,r;case 9:e.t0=e.sent,e.next=13;break;case 12:e.t0=r;case 13:if(e.t0){e.next=16;break}return e.abrupt("return",!1);case 16:return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new Xw(this.backendInstance),e.abrupt("return",!0);case 20:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setupRegisteredKernels=function(){var e=this;Zx(this.backendName).forEach((function(t){null!=t.setupFunc&&t.setupFunc(e.backendInstance)}))},t.disposeRegisteredKernels=function(e){var t=this;Zx(e).forEach((function(n){null!=n.disposeFunc&&n.disposeFunc(t.registry[e])}))},t.initializeBackend=function(e){var t=this,n=this.registryFactory[e];if(null==n)throw new Error("Cannot initialize backend "+e+", no registration found.");try{var r=n.factory();if(!r||r instanceof Pv||"function"!=typeof r.then)return this.registry[e]=r,{success:!0,asyncInit:!1};var a=++this.pendingBackendInitId,i=r.then((function(n){return!(a<t.pendingBackendInitId)&&(t.registry[e]=n,t.pendingBackendInit=null,!0)})).catch((function(n){return a<t.pendingBackendInitId||(t.pendingBackendInit=null,qx("Initialization of backend "+e+" failed"),qx(n.stack||n.message)),!1}));return this.pendingBackendInit=i,{success:i,asyncInit:!0}}catch(t){return qx("Initialization of backend "+e+" failed"),qx(t.stack||t.message),{success:!1,asyncInit:!1}}},t.removeBackend=function(e){if(!(e in this.registryFactory))throw new Error(e+" backend not found in registry");this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)},t.getSortedBackends=function(){var e=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((function(t,n){return e.registryFactory[n].priority-e.registryFactory[t].priority}))},t.initializeBackendsAndReturnBest=function(){for(var e=this.getSortedBackends(),t=0;t<e.length;t++){var n=e[t],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.")},t.moveData=function(e,t){var n=this.state.tensorInfo.get(t),r=n.backend,a=this.readSync(t),i=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,a,n.shape,n.dtype,i),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++},t.tidy=function(e,t){var n,r=this,a=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");a=e}return this.scopedRun((function(){return r.startScope(a)}),(function(){return r.endScope(n)}),(function(){return(n=t())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n}))},t.scopedRun=function(e,t,n){e();try{var r=n();return t(),r}catch(e){throw t(),e}},t.nextTensorId=function(){return e.nextTensorId++},t.nextVariableId=function(){return e.nextVariableId++},t.clone=function(e){var t=Ek.runKernel(Yy,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(function(e){return{x:function(){var t={x:e},n={dtype:"float32"};return Ek.runKernel(ay,t,n)}}}),[],{}),t},t.runKernel=function(e,t,n){if(null==this.backendName&&this.backend,!(null!=Yx(e,this.backendName)))throw new Error("Kernel '"+e+"' not registered for backend '"+this.backendName+"'");return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})},t.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST")},t.checkKernelForMemLeak=function(e,t,n){var r=this.backend.numDataIds(),a=0;n.forEach((function(e){a+="complex64"===e.dtype?3:1}));var i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],o=r-t-a-i;if(o>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak ("+o+" data ids) after running '"+e+"'")},t.runKernelFunc=function(e){var t,n,r,a=this,i=[],o=this.isTapeOn(),s=this.state.numBytes,u=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;var l=Nk(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(Nk(e)){var c=e.kernelName,p=e.inputs,h=e.attrs;null==this.backendName&&this.backend;var d=Yx(c,this.backendName);Hv(null!=d,(function(){return"Cannot find registered kernel '"+c+"' for backend '"+a.backendName+"'"})),n=function(){var e=a.backend.numDataIds();r=d.kernelFunc({inputs:p,attrs:h,backend:a.backend});var t=Array.isArray(r)?r:[r];a.shouldCheckForMemLeaks()&&a.checkKernelForMemLeak(c,e,t);var n=t.map((function(e){return null!=e.rank?e:a.makeTensorFromTensorInfo(e)}));if(o){var s=a.getTensorsForGradient(c,p,n);i=a.saveTensorsForBackwardMode(s)}return n}}else{var f=e.forwardFunc,m=function(e){o&&(i=e.map((function(e){return a.keep(a.clone(e))})))};n=function(){var e=a.backend.numDataIds();r=a.tidy((function(){return f(a.backend,m)}));var t=Array.isArray(r)?r:[r];return a.shouldCheckForMemLeaks()&&a.checkKernelForMemLeak(l,e,t),t}}var v,g=e.inputs,y=e.attrs,b=Nk(e)?null:e.backwardsFunc;return this.scopedRun((function(){return a.state.kernelDepth++}),(function(){return a.state.kernelDepth--}),(function(){a.ENV.getBool("DEBUG")||a.state.profiling?(v=a.profiler.profileKernel(l,g,(function(){return n()})),a.ENV.getBool("DEBUG")&&a.profiler.logKernelProfile(v),t=v.outputs):t=n()})),o&&this.addTapeNode(l,g,t,b,i,y),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-s,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-u,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(g).map((function(e){return null!=g[e]?g[e].shape:null})),outputShapes:t.map((function(e){return e.shape})),kernelTimeMs:v.timeMs,extraInfo:v.extraInfo}),Array.isArray(r)?t:t[0]},t.saveTensorsForBackwardMode=function(e){var t=this,n=e.map((function(e){return t.keep(t.clone(e))}));return n},t.getTensorsForGradient=function(e,t,n){var r=Jx(e);if(null!=r){var a,i=r.inputsToSave||[],o=r.outputsToSave||[];r.saveAllInputs?(Hv(Array.isArray(t),(function(){return"saveAllInputs is true, expected inputs to be an array."})),a=Object.keys(t).map((function(e){return t[e]}))):a=i.map((function(e){return t[e]}));var s=n.filter((function(e,t){return o[t]}));return a.concat(s)}return[]},t.makeTensor=function(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;var a=e;"string"===n&&cg(e[0])&&(a=e.map((function(e){return Gw(e)})));var i=r.write(a,t,n),o=new ak(t,n,i,this.nextTensorId());if(this.trackTensor(o,r),"string"===n){var s=this.state.tensorInfo.get(i),u=lg(a);this.state.numBytes+=u-s.bytes,s.bytes=u}return o},t.makeTensorFromDataId=function(e,t,n,r){var a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)},t.makeTensorFromTensorInfo=function(e,t){var n=e.dataId,r=e.shape,a=e.dtype,i=new ak(r,a,n,this.nextTensorId());return this.trackTensor(i,t),i},t.makeVariable=function(e,t,n,r){void 0===t&&(t=!0),n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));var a=new pk(e,t,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},t.trackTensor=function(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;var n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*ug(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof pk||this.track(e)},t.incRef=function(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)},t.removeDataId=function(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)},t.disposeTensor=function(e){if(this.state.tensorInfo.has(e.dataId)){var t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){var n=e.size*ug(e.dtype);this.state.numBytes-=n}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}},t.disposeVariables=function(){for(var e in this.state.registeredVariables){var t=this.state.registeredVariables[e];this.disposeVariable(t)}},t.disposeVariable=function(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]},t.memory=function(){var e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e},t.profile=function(){var e=Iv(kv().mark((function e(t){var n,r,a,i,o;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.state.profiling=!0,n=this.state.numBytes,r=this.state.numTensors,this.state.activeProfile.kernels=[],e.next=6,t();case 6:this.state.activeProfile.result=e.sent,this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map((function(e){return e.totalBytesSnapshot}))),this.state.activeProfile.newBytes=this.state.numBytes-n,this.state.activeProfile.newTensors=this.state.numTensors-r,a=Lv(this.state.activeProfile.kernels);case 12:if((i=a()).done){e.next=22;break}return o=i.value,e.next=16,o.kernelTimeMs;case 16:return o.kernelTimeMs=e.sent,e.next=19,o.extraInfo;case 19:o.extraInfo=e.sent;case 20:e.next=12;break;case 22:return e.abrupt("return",this.state.activeProfile);case 23:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.isTapeOn=function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth},t.addTapeNode=function(e,t,n,r,a,i){var o=this,s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},u=Jx(e);null!=u&&(r=u.gradFunc),null!=r&&(s.gradient=function(e){return e=e.map((function(e,t){if(null==e){var r=n[t],a=wg(r.size,r.dtype);return o.makeTensor(a,r.shape,r.dtype)}return e})),r(e.length>1?e:e[0],a,i)}),this.state.activeTape.push(s)},t.keep=function(e){return e.kept=!0,e},t.startTape=function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++},t.endTape=function(){this.state.gradientDepth--},t.startScope=function(e){var t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t},t.endScope=function(e){for(var t=this,n=xk(e),r=new Set(n.map((function(e){return e.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(e){e.kept||e.scopeId!==o.id||t.track(e)}))},t.gradients=function(e,t,n,r){var a=this;if(void 0===r&&(r=!1),Hv(t.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",e)}));Hv(i instanceof ak,(function(){return"The result y returned by f() must be a tensor."}));var o=function(e,t,n){for(var r={},a={},i=0;i<t.length;i++)r[t[i].id]=!0;for(var o=0;o<e.length;o++){var s=e[o],u=s.inputs;for(var l in u){for(var c=u[l],p=!1,h=0;h<t.length;h++)if(r[c.id]){s.outputs.forEach((function(e){return r[e.id]=!0})),p=!0,a[s.id]=!0;break}if(p)break}}var d={};d[n.id]=!0;for(var f={},m=e.length-1;m>=0;m--)for(var v=e[m],g=v.inputs,y=0;y<v.outputs.length;y++)if(d[v.outputs[y].id]){for(var b in g)d[g[b].id]=!0,f[v.id]=!0;break}for(var x=[],w=0;w<e.length;w++){var k=e[w];if(a[k.id]&&f[k.id]){var N={};for(var I in k.inputs){var S=k.inputs[I];r[S.id]&&(N[I]=S)}var T=Object.assign({},k);T.inputs=N,T.outputs=k.outputs,x.push(T)}}return x}(this.state.activeTape,t,i);if(!r&&0===o.length&&t.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 e,r,s={};s[i.id]=null==n?(e=i.shape,r=xg(Xv(e),"float32"),Ek.makeTensor(r,e,"float32")):n,function(e,t,n,r){for(var a=function(a){var i=t[a],o=[];if(i.outputs.forEach((function(t){var n=e[t.id];null!=n?o.push(n):o.push(null)})),null==i.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+i.kernelName+".");var s=i.gradient(o),u=function(t){if(!(t in s))throw new Error("Cannot backprop through input "+t+". Available gradients found: "+Object.keys(s)+".");var a=n((function(){return s[t]()}));if("float32"!==a.dtype)throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input "+t+" must have 'float32' dtype, but has '"+a.dtype+"'");var o=i.inputs[t];if(!Yv(a.shape,o.shape))throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input '"+t+"' has shape '"+a.shape+"', which does not match the shape of the input '"+o.shape+"'");if(null==e[o.id])e[o.id]=a;else{var u=e[o.id];e[o.id]=r(u,a),u.dispose()}};for(var l in i.inputs)u(l)},i=t.length-1;i>=0;i--)a(i)}(s,o,(function(e){return a.tidy(e)}),Ak);var u=t.map((function(e){return s[e.id]}));return 0===a.state.gradientDepth&&(a.state.activeTape.forEach((function(e){for(var t,n=Lv(e.saved);!(t=n()).done;){t.value.dispose()}})),a.state.activeTape=null),{value:i,grads:u}}))},t.customGrad=function(e){var t=this;return Hv(fg(e),(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;Hv(r.every((function(e){return e instanceof ak})),(function(){return"The args passed in customGrad(f)(x1, x2,...) must all be tensors"}));var o={};r.forEach((function(e,t){o[t]=e}));var s=function(t,n){return Hv((i=e.apply(void 0,[].concat(r,[n]))).value instanceof ak,(function(){return"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"})),Hv(fg(i.gradFunc),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."})),i.value},u=function(e,t){var n=i.gradFunc(e,t),a=Array.isArray(n)?n:[n];Hv(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(...)."})),Hv(a.every((function(e){return e instanceof ak})),(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(e,t){o[t]=function(){return e}})),o};return t.runKernelFunc({forwardFunc:s,backwardsFunc:u,inputs:o})}},t.readSync=function(e){return this.state.tensorInfo.get(e).backend.readSync(e)},t.read=function(e){return this.state.tensorInfo.get(e).backend.read(e)},t.readToGPU=function(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)},t.time=function(){var e=Iv(kv().mark((function e(t){var n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Vw(),e.next=3,this.backend.time(t);case 3:return(r=e.sent).wallMs=Vw()-n,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.track=function(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e},t.reset=function(){for(var e in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new Ik,this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null},Tv(e,[{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 e=this.initializeBackendsAndReturnBest(),t=e.name;if(e.asyncInit)throw new Error("The highest priority backend '"+t+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");this.setBackend(t)}return this.backendInstance}},{key:"registeredVariables",get:function(){return this.state.registeredVariables}}]),e}();function Tk(){var t=Og();if(null==t._tfengine){var n=new Ag(t);t._tfengine=new Sk(n)}return function(t){e.ENV=t}(t._tfengine.ENV),nk=function(){return t._tfengine},t._tfengine}Sk.nextTensorId=0,Sk.nextVariableId=0;var Ck,Ek=Tk();function Ak(e,t){var n={a:e,b:t};return Ek.runKernel(Pg,n)}function Rk(e){if(void 0!==Ck)return Ck;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;var t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){var n=e;return n.userAgentData&&n.userAgentData.mobile}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 _k(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var Fk={__proto__:null,mockIsMobile:function(e){Ck=e},isMobile:Rk,isBrowser:_k},Ok=Fg();function Dk(e,t){var n=e;if(Hw(e))return"string"===t?[]:[e.length];if(mk(e)){var r=e.channels||"RGBA";return[e.height,e.width*r.length]}if(vk(e))return[e.buffer.size/(null==t?4:ug(t))];if(!Array.isArray(e))return[];for(var a=[];Array.isArray(n)||Hw(n)&&"string"!==t;)a.push(n.length),n=n[0];return Array.isArray(e)&&Fg().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Mk(e,a,[]),a}function Mk(e,t,n){if(n=n||[],Array.isArray(e)||Hw(e)){Hv(t.length>0,(function(){return"Element arr["+n.join("][")+"] should be a primitive, but is an array of "+e.length+" elements"})),Hv(e.length===t[0],(function(){return"Element arr["+n.join("][")+"] should have "+t[0]+" elements, but has "+e.length+" elements"}));for(var r=t.slice(1),a=0;a<e.length;++a)Mk(e[a],r,n.concat(a))}else Hv(0===t.length,(function(){return"Element arr["+n.join("][")+"] is a primitive, but should be an array/TypedArray of "+t[0]+" elements"}))}function Lk(e,t,n,r){if("string_or_numeric"!==e){if(null==e)throw new Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw new Error("Argument '"+n+"' passed to '"+r+"' must be "+e+" tensor, but got "+t+" tensor")}}function zk(e,t,n,r){if(void 0===r&&(r="numeric"),e instanceof ak)return Lk(r,e.dtype,t,n),e;var a=dg(e);if("string"!==a&&["bool","int32","float32"].indexOf(r)>=0&&(a=r),Lk(r,a,t,n),null==e||!Hw(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){var i=null==e?"null":e.constructor.name;throw new Error("Argument '"+t+"' passed to '"+n+"' must be a Tensor or TensorLike, but got '"+i+"'")}var o=Dk(e,a);Hw(e)||Array.isArray(e)||(e=[e]);var s="string"!==a?Ww(e,a):qw(e,[],!0);return Ek.makeTensor(s,o,a)}function Pk(e,t,n,r){if(void 0===r&&(r="numeric"),!Array.isArray(e))throw new Error("Argument "+t+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");return e.map((function(e,a){return zk(e,t+"["+a+"]",n,r)}))}Ok.registerFlag("DEBUG",(function(){return!1}),(function(e){e&&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.")})),Ok.registerFlag("IS_BROWSER",(function(){return _k()})),Ok.registerFlag("IS_NODE",(function(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node})),Ok.registerFlag("IS_CHROME",(function(){return"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)})),Ok.registerFlag("IS_SAFARI",(function(){return"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)})),Ok.registerFlag("PROD",(function(){return!1})),Ok.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(function(){return Ok.getBool("DEBUG")})),Ok.registerFlag("DEPRECATION_WARNINGS_ENABLED",(function(){return!0})),Ok.registerFlag("IS_TEST",(function(){return!1})),Ok.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(function(){return Ok.getBool("DEBUG")})),Ok.registerFlag("WRAP_TO_IMAGEBITMAP",(function(){return!1})),Ok.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(function(){return!1})),Ok.registerFlag("USE_SETTIMEOUTCUSTOM",(function(){return!1}));var Bk="__op";function Wk(e){var t=Object.keys(e);if(1!==t.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+t.length+" keys.");var n=t[0],r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=Bk;var a=function(){Ek.startScope(n);try{var e=r.apply(void 0,arguments);return Tg(e)&&console.error("Cannot return a Promise inside of tidy."),Ek.endScope(e),e}catch(e){throw Ek.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}var Vk=Wk({complex_:function(e,t){var n=zk(e,"real","complex"),r=zk(t,"imag","complex");qv(n.shape,r.shape,"real and imag shapes, "+n.shape+" and "+r.shape+", must match in call to tf.complex().");var a={real:n,imag:r};return Ek.runKernel(sy,a)}});function Uk(e,t,n,r){if(null==r)r=dg(e);else if("complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(vk(e)||mk(e)){if("float32"!==r&&"int32"!==r)throw new Error("Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is "+r+".");return Ek.backend.createTensorFromGPUData(e,t||n,r)}if(!Hw(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)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!=t){Ng(t);var a=Xv(t),i=Xv(n);Hv(a===i,(function(){return"Based on the provided shape, ["+t+"], 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!==Xv(t.slice(o));Hv(n[o]===t[o]||!u,(function(){return"Error creating a new Tensor. Inferred shape ("+n+") does not match the provided shape ("+t+"). "}))}}return Hw(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Ww(e,r):qw(e,[],!0),Ek.makeTensor(e,t,r)}function Gk(e,t,n){return Uk(e,t,Dk(e,n),n)}var jk={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};function Hk(e,t){return qk.apply(this,arguments)}function qk(){return qk=Iv(kv().mark((function e(t,n){var r,a,i,o,s,u;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=[],a=[],i=Array.isArray(t)?t.map((function(e){return e.name})):Object.keys(t),o=function(e){var o=i[e],s=Array.isArray(t)?t[e].tensor:t[o];if("float32"!==s.dtype&&"int32"!==s.dtype&&"bool"!==s.dtype&&"string"!==s.dtype&&"complex64"!==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 l=new Promise(function(){var e=Iv(kv().mark((function e(t){var n,r,a,i,o,u,l;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.bytes();case 2:for(n=e.sent,r=n.reduce((function(e,t){return e+t.length}),0)+4*n.length,a=new Uint8Array(r),i=0,o=0;o<n.length;o++)u=n[o],l=new Uint8Array(new Uint32Array([u.length]).buffer),a.set(l,i),i+=4,a.set(u,i),i+=u.length;t(a);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());a.push(l)}else a.push(s.data());null!=n&&(u.group=n),r.push(u)},s=0;s<i.length;++s)o(s);return e.next=7,Promise.all(a);case 7:return u=e.sent,e.abrupt("return",{data:Xk(u),specs:r});case 9:case"end":return e.stop()}}),e)}))),qk.apply(this,arguments)}function Kk(e,t){for(var n,r,a={},i=0,o=Lv(t);!(r=o()).done;){var s=r.value,u=s.name,l=s.dtype,c=s.shape,p=Xv(c),h=void 0;if("quantization"in s){var d=s.quantization;if("uint8"===d.dtype||"uint16"===d.dtype){if(!("min"in d)||!("scale"in d))throw new Error("Weight "+s.name+" with quantization "+d.dtype+" doesn't have corresponding metadata min and scale.")}else{if("float16"!==d.dtype)throw new Error("Weight "+s.name+" has unknown quantization dtype "+d.dtype+". Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.");if("float32"!==l)throw new Error("Weight "+s.name+" is quantized with "+d.dtype+" which only supports weights of type float32 not "+l+".")}var f=jk[d.dtype],m=e.slice(i,i+p*f),v="uint8"===d.dtype?new Uint8Array(m):new Uint16Array(m);if("float32"===l)if("uint8"===d.dtype||"uint16"===d.dtype){h=new Float32Array(v.length);for(var g=0;g<v.length;g++){var y=v[g];h[g]=y*d.scale+d.min}}else{if("float16"!==d.dtype)throw new Error("Unsupported quantization type "+d.dtype+" for weight type float32.");void 0===n&&(n=sN()),h=n(v)}else{if("int32"!==l)throw new Error("Unsupported dtype in weight '"+u+"': "+l);if("uint8"!==d.dtype&&"uint16"!==d.dtype)throw new Error("Unsupported quantization type "+d.dtype+" for weight type int32.");h=new Int32Array(v.length);for(var b=0;b<v.length;b++){var x=v[b];h[b]=Math.round(x*d.scale+d.min)}}i+=p*f}else if("string"===l){var w=Xv(s.shape);h=[];for(var k=0;k<w;k++){var N=new Uint32Array(e.slice(i,i+4))[0];i+=4;var I=new Uint8Array(e.slice(i,i+N));h.push(I),i+=N}}else{var S=jk[l],T=e.slice(i,i+p*S);if("float32"===l)h=new Float32Array(T);else if("int32"===l)h=new Int32Array(T);else if("bool"===l)h=new Uint8Array(T);else{if("complex64"!==l)throw new Error("Unsupported dtype in weight '"+u+"': "+l);h=new Float32Array(T);for(var C=new Float32Array(h.length/2),E=new Float32Array(h.length/2),A=0;A<C.length;A++)C[A]=h[2*A],E[A]=h[2*A+1];var R=Gk(C,c,"float32"),_=Gk(E,c,"float32");a[u]=Vk(R,_),R.dispose(),_.dispose()}i+=p*S}"complex64"!==l&&(a[u]=Gk(h,c,l))}return a}function Xk(e){if(null===e)throw new Error("Invalid input value: "+JSON.stringify(e));var t=0,n=[];e.forEach((function(e){if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+e.constructor.name)}));var r=new Uint8Array(t),a=0;return n.forEach((function(e){r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}var Yk="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function Jk(e){return Yk?Buffer.byteLength(e):new Blob([e]).size}function Zk(e){if(Yk)return Buffer.from(e).toString("base64");for(var t=new Uint8Array(e),n="",r=0,a=t.length;r<a;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function Qk(e){if(Yk){var t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}for(var n=atob(e),r=new Uint8Array(n.length),a=0;a<n.length;++a)r.set([n.charCodeAt(a)],a);return r.buffer}function $k(e){if(1===e.length)return e[0];var t=0;e.forEach((function(e){t+=e.byteLength}));var n=new Uint8Array(t),r=0;return e.forEach((function(e){n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function eN(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);var t=e.split("/");return t[t.length-1]}function tN(e,t){var n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(n.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}function nN(e,t,n){var r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(r.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");r.weightSpecs=t,r.weightData=n}return null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(r.initializerSignature=e.initializerSignature),r}function rN(e,t){return aN.apply(this,arguments)}function aN(){return aN=Iv(kv().mark((function e(t,n){var r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==t.weightsManifest){e.next=6;break}return e.next=3,n(t.weightsManifest);case 3:i=e.sent,r=i[0],a=i[1];case 6:return e.abrupt("return",nN(t,r,a));case 7:case"end":return e.stop()}}),e)}))),aN.apply(this,arguments)}function iN(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:Jk(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:Jk(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function oN(e){for(var t,n=[],r=Lv(e);!(t=r()).done;){var a=t.value;n.push.apply(n,a.weights)}return n}function sN(){var e=function(){var e=function(e){for(var t=e<<13,n=0;0==(8388608&t);)n-=8388608,t<<=1;return(t&=-8388609)|n+947912704},t=new Uint32Array(2048);t[0]=0;for(var n=1;n<1024;n++)t[n]=e(n);for(var r=1024;r<2048;r++)t[r]=939524096+(r-1024<<13);return t}(),t=function(){var e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(var t=1;t<31;t++)e[t]=t<<23;for(var n=33;n<63;n++)e[n]=2147483648+(n-32<<23);return e}(),n=function(){for(var e=new Uint32Array(64),t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return function(r){for(var a=new ArrayBuffer(4*r.length),i=new Uint32Array(a),o=0;o<r.length;o++){var s=r[o],u=e[n[s>>10]+(1023&s)]+t[s>>10];i[o]=u}return new Float32Array(a)}}var uN=function(){function e(){this.saveRouters=[],this.loadRouters=[]}return e.getInstance=function(){return null==e.instance&&(e.instance=new e),e.instance},e.registerSaveRouter=function(t){e.getInstance().saveRouters.push(t)},e.registerLoadRouter=function(t){e.getInstance().loadRouters.push(t)},e.getSaveHandlers=function(t){return e.getHandlers(t,"save")},e.getLoadHandlers=function(t,n){return e.getHandlers(t,"load",n)},e.getHandlers=function(t,n,r){var a=[];return("load"===n?e.getInstance().loadRouters:e.getInstance().saveRouters).forEach((function(e){var n=e(t,r);null!==n&&a.push(n)})),a},e}(),lN=function(e){return uN.getSaveHandlers(e)},cN=function(e,t){return uN.getLoadHandlers(e,t)},pN="tensorflowjs",hN="models_store",dN="model_info_store";function fN(){if(!Fg().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function mN(e){var t=e.result;t.createObjectStore(hN,{keyPath:"modelPath"}),t.createObjectStore(dN,{keyPath:"modelPath"})}var vN=function(){function e(e){if(this.indexedDB=fN(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}var t=e.prototype;return t.save=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.modelTopology instanceof ArrayBuffer)){e.next=2;break}throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");case 2:return e.abrupt("return",this.databaseAction(this.modelPath,t));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.load=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.databaseAction(this.modelPath));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.databaseAction=function(e,t){var n=this;return new Promise((function(e,r){var a=n.indexedDB.open(pN,1);a.onupgradeneeded=function(){return mN(a)},a.onsuccess=function(){var i=a.result;if(null==t){var o=i.transaction(hN,"readonly"),s=o.objectStore(hN).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."));e(s.result.modelArtifacts)},s.onerror=function(e){return i.close(),r(s.error)},o.oncomplete=function(){return i.close()}}else{var u,l,c=iN(t),p=i.transaction(dN,"readwrite"),h=p.objectStore(dN);try{u=h.put({modelPath:n.modelPath,modelArtifactsInfo:c})}catch(e){return r(e)}u.onsuccess=function(){var a,o=(l=i.transaction(hN,"readwrite")).objectStore(hN);try{a=o.put({modelPath:n.modelPath,modelArtifacts:t,modelArtifactsInfo:c})}catch(e){return r(e)}a.onsuccess=function(){return e({modelArtifactsInfo:c})},a.onerror=function(e){var t=(h=p.objectStore(dN)).delete(n.modelPath);t.onsuccess=function(){return i.close(),r(a.error)},t.onerror=function(e){return i.close(),r(a.error)}}},u.onerror=function(e){return i.close(),r(u.error)},p.oncomplete=function(){null==l?i.close():l.oncomplete=function(){return i.close()}}}},a.onerror=function(e){return r(a.error)}}))},e}();vN.URL_SCHEME="indexeddb://";var gN=function(e){return Fg().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(vN.URL_SCHEME)?(t=e.slice(vN.URL_SCHEME.length),new vN(t)):null;var t};function yN(e){return e.startsWith(vN.URL_SCHEME)?e.slice(vN.URL_SCHEME.length):e}uN.registerSaveRouter(gN),uN.registerLoadRouter(gN);var bN=function(){function e(){this.indexedDB=fN()}var t=e.prototype;return t.listModels=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){var r=t.indexedDB.open(pN,1);r.onupgradeneeded=function(){return mN(r)},r.onsuccess=function(){var t=r.result,a=t.transaction(dN,"readonly"),i=a.objectStore(dN).getAll();i.onsuccess=function(){for(var t,n={},r=Lv(i.result);!(t=r()).done;){var a=t.value;n[a.modelPath]=a.modelArtifactsInfo}e(n)},i.onerror=function(e){return t.close(),n(i.error)},a.oncomplete=function(){return t.close()}},r.onerror=function(e){return n(r.error)}})));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),t.removeModel=function(){var e=Iv(kv().mark((function e(t){var n=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=yN(t),e.abrupt("return",new Promise((function(e,r){var a=n.indexedDB.open(pN,1);a.onupgradeneeded=function(){return mN(a)},a.onsuccess=function(){var n,i=a.result,o=i.transaction(dN,"readwrite"),s=o.objectStore(dN),u=s.get(t);u.onsuccess=function(){if(null==u.result)return i.close(),r(new Error("Cannot find model with path '"+t+"' in IndexedDB."));var a=s.delete(t),o=function(){var a=(n=i.transaction(hN,"readwrite")).objectStore(hN).delete(t);a.onsuccess=function(){return e(u.result.modelArtifactsInfo)},a.onerror=function(e){return r(u.error)}};a.onsuccess=o,a.onerror=function(e){return o(),i.close(),r(u.error)}},u.onerror=function(e){return i.close(),r(u.error)},o.oncomplete=function(){null==n?i.close():n.oncomplete=function(){return i.close()}}},a.onerror=function(e){return r(a.error)}})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e}(),xN="/",wN="tensorflowjs_models",kN="info",NN="model_topology",IN="weight_specs",SN="weight_data",TN="model_metadata";function CN(e){return{info:[wN,e,kN].join(xN),topology:[wN,e,NN].join(xN),weightSpecs:[wN,e,IN].join(xN),weightData:[wN,e,SN].join(xN),modelMetadata:[wN,e,TN].join(xN)}}function EN(e){for(var t=0,n=Object.values(e);t<n.length;t++){var r=n[t];window.localStorage.removeItem(r)}}function AN(e){var t=e.split(xN);if(t.length<3)throw new Error("Invalid key format: "+e);return t.slice(1,t.length-1).join(xN)}function RN(e){return e.startsWith(_N.URL_SCHEME)?e.slice(_N.URL_SCHEME.length):e}var _N=function(){function e(e){if(!Fg().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==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=CN(this.modelPath)}var t=e.prototype;return t.save=function(){var e=Iv(kv().mark((function e(t){var n,r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.modelTopology instanceof ArrayBuffer)){e.next=4;break}throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");case 4:return n=JSON.stringify(t.modelTopology),r=JSON.stringify(t.weightSpecs),a=iN(t),e.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,Zk(t.weightData)),i={format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,signature:null!=t.signature?t.signature:void 0,userDefinedMetadata:null!=t.userDefinedMetadata?t.userDefinedMetadata:void 0,modelInitializer:null!=t.modelInitializer?t.modelInitializer:void 0,initializerSignature:null!=t.initializerSignature?t.initializerSignature:void 0,trainingConfig:null!=t.trainingConfig?t.trainingConfig:void 0},this.LS.setItem(this.keys.modelMetadata,JSON.stringify(i)),e.abrupt("return",{modelArtifactsInfo:a});case 17:throw e.prev=17,e.t0=e.catch(7),EN(this.keys),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 21:case"end":return e.stop()}}),e,this,[[7,17]])})));return function(t){return e.apply(this,arguments)}}(),t.load=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o,s;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(t=JSON.parse(this.LS.getItem(this.keys.info)))){e.next=3;break}throw new Error("In local storage, there is no model with name '"+this.modelPath+"'");case 3:if("JSON"===t.modelTopologyType){e.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)))){e.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)))){e.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,null!=o.signature&&(n.signature=o.signature),null!=o.userDefinedMetadata&&(n.userDefinedMetadata=o.userDefinedMetadata),null!=o.modelInitializer&&(n.modelInitializer=o.modelInitializer),null!=o.initializerSignature&&(n.initializerSignature=o.initializerSignature),null!=o.trainingConfig&&(n.trainingConfig=o.trainingConfig)),null!=(s=this.LS.getItem(this.keys.weightData))){e.next=19;break}throw new Error("In local storage, the binary weight values of model '"+this.modelPath+"' are missing.");case 19:return n.weightData=Qk(s),e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}();_N.URL_SCHEME="localstorage://";var FN=function(e){return Fg().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(_N.URL_SCHEME)?(t=e.slice(_N.URL_SCHEME.length),new _N(t)):null;var t};uN.registerSaveRouter(FN),uN.registerLoadRouter(FN);var ON=function(){function e(){Hv(Fg().getBool("IS_BROWSER"),(function(){return"Current environment is not a web browser"})),Hv("undefined"==typeof window||void 0!==window.localStorage,(function(){return"Current browser does not appear to support localStorage"})),this.LS=window.localStorage}var t=e.prototype;return t.listModels=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t={},n=wN+xN,r=xN+kN,a=0;a<this.LS.length;++a)(i=this.LS.key(a)).startsWith(n)&&i.endsWith(r)&&(o=AN(i),t[o]=JSON.parse(this.LS.getItem(i)));return e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.removeModel=function(){var e=Iv(kv().mark((function e(t){var n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=RN(t),n=CN(t),null!=this.LS.getItem(n.info)){e.next=4;break}throw new Error("Cannot find model at path '"+t+"'");case 4:return r=JSON.parse(this.LS.getItem(n.info)),EN(n),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}(),DN="://",MN=function(){function e(){this.managers={}}return e.getInstance=function(){return null==e.instance&&(e.instance=new e),e.instance},e.registerManager=function(t,n){Hv(null!=t,(function(){return"scheme must not be undefined or null."})),t.endsWith(DN)&&(t=t.slice(0,t.indexOf(DN))),Hv(t.length>0,(function(){return"scheme must not be an empty string."}));var r=e.getInstance();Hv(null==r.managers[t],(function(){return"A model store manager is already registered for scheme '"+t+"'."})),r.managers[t]=n},e.getManager=function(t){var n=e.getInstance().managers[t];if(null==n)throw new Error("Cannot find model manager for scheme '"+t+"'");return n},e.getSchemes=function(){return Object.keys(e.getInstance().managers)},e}();function LN(e){if(-1===e.indexOf(DN))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+MN.getSchemes().join(","));return{scheme:e.split(DN)[0],path:e.split(DN)[1]}}function zN(e,t,n){return PN.apply(this,arguments)}function PN(){return(PN=Iv(kv().mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r=!1),Hv(t!==n,(function(){return"Old path and new path are the same: '"+t+"'"})),Hv((a=uN.getLoadHandlers(t)).length>0,(function(){return"Copying failed because no load handler is found for source URL "+t+"."})),Hv(a.length<2,(function(){return"Copying failed because more than one ("+a.length+") load handlers for source URL "+t+"."})),i=a[0],Hv((o=uN.getSaveHandlers(n)).length>0,(function(){return"Copying failed because no save handler is found for destination URL "+n+"."})),Hv(o.length<2,(function(){return"Copying failed because more than one ("+a.length+") save handlers for destination URL "+n+"."})),s=o[0],u=LN(t).scheme,l=LN(t).path,c=u===LN(t).scheme,e.next=15,i.load();case 15:if(p=e.sent,!r||!c){e.next=19;break}return e.next=19,MN.getManager(u).removeModel(l);case 19:return e.next=21,s.save(p);case 21:if(h=e.sent,!r||c){e.next=25;break}return e.next=25,MN.getManager(u).removeModel(l);case 25:return e.abrupt("return",h.modelArtifactsInfo);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function BN(){return BN=Iv(kv().mark((function e(){var t,n,r,a,i,o,s;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=MN.getSchemes(),n={},r=Lv(t);case 3:if((a=r()).done){e.next=11;break}return i=a.value,e.next=7,MN.getManager(i).listModels();case 7:for(s in o=e.sent)n[i+DN+s]=o[s];case 9:e.next=3;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e)}))),BN.apply(this,arguments)}function WN(){return(WN=Iv(kv().mark((function e(t){var n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=LN(t),r=MN.getManager(n.scheme),e.abrupt("return",r.removeModel(n.path));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function VN(){return(VN=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!1,e.abrupt("return",zN(t,n,false));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function UN(){return(UN=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!0,e.abrupt("return",zN(t,n,true));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var GN=function(){function e(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}var t=e.prototype;return t.fetch=function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t){return fetch(e,t)})),t.now=function(){return performance.now()},t.encode=function(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error("Browser's encoder only supports utf-8, but got "+t);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)},t.decode=function(e,t){return new TextDecoder(t).decode(e)},t.setTimeoutCustom=function(e,t){var n=this;"undefined"!=typeof window&&Fg().getBool("USE_SETTIMEOUTCUSTOM")?(this.functionRefs.push(e),setTimeout((function(){window.postMessage({name:n.messageName,index:n.functionRefs.length-1},"*")}),t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",(function(e){e.source===window&&e.data.name===n.messageName&&(e.stopPropagation(),(0,n.functionRefs[e.data.index])(),n.handledMessageCount++,n.handledMessageCount===n.functionRefs.length&&(n.functionRefs=[],n.handledMessageCount=0))}),!0))):setTimeout(e,t)},t.isTypedArray=function(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray},e}();if(Fg().get("IS_BROWSER")){Fg().setPlatform("browser",new GN);try{MN.registerManager(_N.URL_SCHEME,new ON)}catch(e){}try{MN.registerManager(vN.URL_SCHEME,new bN)}catch(e){}}var jN,HN=function(){return require("node-fetch")};var qN=function(){function e(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}var t=e.prototype;return t.fetch=function(e,t){return null!=Fg().global.fetch?Fg().global.fetch(e,t):(null==jN&&(jN=HN()),jN(e,t))},t.now=function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6},t.encode=function(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error("Node built-in encoder only supports utf-8, but got "+t);return this.textEncoder.encode(e)},t.decode=function(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)},t.isTypedArray=function(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)},e}();function KN(e,t,n){return void 0===t&&(t="float32"),t=t||"float32",Ng(e),new tk(e,t,n)}Fg().get("IS_NODE")&&!Fg().get("IS_BROWSER")&&Fg().setPlatform("node",new qN);var XN=Wk({cast_:function(e,t){var n=zk(e,"x","cast");if(!og(t))throw new Error("Failed to cast to unknown dtype "+t);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var r={x:n},a={dtype:t};return Ek.runKernel(ay,r,a)}});var YN=Wk({clone_:function(e){var t={x:zk(e,"x","clone","string_or_numeric")};return Ek.runKernel(Yy,t)}});function JN(e,t){void 0===t&&(t=!1),console.log(e.toString(t))}function ZN(e){Fg().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function QN(){return Ek}function $N(){return Ek.memory()}function eI(e,t){return Ek.tidy(e,t)}function tI(e){xk(e).forEach((function(e){return e.dispose()}))}function nI(e){return Ek.keep(e)}function rI(e){return Ek.setBackend(e)}function aI(e,t,n){return void 0===n&&(n=1),Ek.registerBackend(e,t,n)}function iI(){return Ek.backend}Tk(),rk={buffer:KN,cast:XN,clone:YN,print:JN};var oI=Wk({add_:function(e,t){var n=zk(e,"a","add"),r=zk(t,"b","add"),a=gk(n,r),i={a:n=a[0],b:r=a[1]};return Ek.runKernel(Pg,i)}});var sI=Wk({floorDiv_:function(e,t){var n=zk(e,"a","floorDiv"),r=zk(t,"b","floorDiv"),a=gk(n,r),i={a:n=a[0],b:r=a[1]};return Ek.runKernel(Gy,i)}});var uI=Wk({div_:function(e,t){var n=zk(e,"a","div"),r=zk(t,"b","div"),a=gk(n,r);if(n=a[0],r=a[1],"int32"===n.dtype&&"int32"===r.dtype)return sI(n,r);var i={a:n,b:r};return Ek.runKernel(Ry,i,{})}});var lI=Wk({mul_:function(e,t){var n=zk(e,"a","mul"),r=zk(t,"b","mul"),a=gk(n,r),i={a:n=a[0],b:r=a[1]};return Ek.runKernel(Tb,i)}});var cI=Wk({abs_:function(e){var t=zk(e,"x","abs");if("complex64"===t.dtype){var n={x:t};return Ek.runKernel(uy,n)}var r={x:t};return Ek.runKernel(Mg,r)}});var pI=Wk({acos_:function(e){var t={x:zk(e,"x","acos")};return Ek.runKernel(Lg,t)}});var hI=Wk({acosh_:function(e){var t={x:zk(e,"x","acosh")};return Ek.runKernel(zg,t)}});var dI=Wk({addN_:function(e){Hv(Array.isArray(e),(function(){return"The argument passed to tf.addN() must be a list of tensors"})),Hv(e.length>=1,(function(){return"Must pass at least one tensor to tf.addN(), but got "+e.length}));var t=e.map((function(e,t){return zk(e,"tensors"+t,"addN")})),n=t[0];t.forEach((function(e){if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((function(e){if(!Yv(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));var r=t;return Ek.runKernel(Bg,r)}});var fI=Wk({all_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:zk(e,"x","all","bool")},a={axis:t,keepDims:n};return Ek.runKernel(Wg,r,a)}});var mI=Wk({any_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:zk(e,"x","any","bool")},a={axis:t,keepDims:n};return Ek.runKernel(Vg,r,a)}});var vI=Wk({argMax_:function(e,t){void 0===t&&(t=0);var n={x:zk(e,"x","argMax")},r={axis:t};return Ek.runKernel(Ug,n,r)}});var gI=Wk({argMin_:function(e,t){void 0===t&&(t=0);var n={x:zk(e,"x","argMin")},r={axis:t};return Ek.runKernel(Gg,n,r)}});var yI=Wk({asin_:function(e){var t={x:zk(e,"x","asin")};return Ek.runKernel(jg,t)}});var bI=Wk({asinh_:function(e){var t={x:zk(e,"x","asinh")};return Ek.runKernel(Hg,t)}});var xI=Wk({atan_:function(e){var t={x:zk(e,"x","atan")};return Ek.runKernel(qg,t)}});var wI=Wk({atan2_:function(e,t){var n=zk(e,"a","atan2"),r=zk(t,"b","atan2"),a=gk(n,r),i={a:n=a[0],b:r=a[1]};return Ek.runKernel(Xg,i)}});var kI=Wk({atanh_:function(e){var t={x:zk(e,"x","atanh")};return Ek.runKernel(Kg,t)}});function NI(e,t,n,r,a,i){void 0===a&&(a="NHWC");var o=e[3];return TI(e,[].concat(t,[o]),n,i,r,null,null,LI(a))}function II(e,t,n,r,a,i,o){void 0===o&&(o="channelsLast");var s,u=AI(t),l=u[0],c=u[1];if("channelsLast"===o)s=[l,c,e[3],e[3]];else{if("channelsFirst"!==o)throw new Error("Unknown dataFormat "+o);s=[l,c,e[1],e[1]]}return TI(e,s,n,r,a,i,!1,o)}function SI(e,t,n,r,a,i,o){void 0===o&&(o="NDHWC");var s,u,l=RI(t),c=l[0],p=l[1],h=l[2];if("NDHWC"===o)u="channelsLast",s=[c,p,h,e[4],e[4]];else{if("NCDHW"!==o)throw new Error("Unknown dataFormat "+o);u="channelsFirst",s=[c,p,h,e[1],e[1]]}return CI(e,s,n,r,a,!1,u,i)}function TI(e,t,n,r,a,i,o,s){void 0===o&&(o=!1),void 0===s&&(s="channelsLast");var u=-1,l=-1,c=-1,p=-1;if("channelsLast"===s)u=e[0],l=e[1],c=e[2],p=e[3];else{if("channelsFirst"!==s)throw new Error("Unknown dataFormat "+s);u=e[0],p=e[1],l=e[2],c=e[3]}var h,d=t[0],f=t[1],m=t[3],v=AI(n),g=v[0],y=v[1],b=AI(r),x=b[0],w=b[1],k=_I(d,x),N=_I(f,w),I=function(e,t,n,r,a,i,o,s,u){var l,c,p;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};var h=function(e,t,n,r,a){null==r&&(r=EI(e,t,n));var i=e[0],o=e[1],s=FI((i-t+2*r)/n+1,a),u=FI((o-t+2*r)/n+1,a);return[s,u]}([t,n],i,r,e,s);c=h[0],p=h[1]}else if("same"===e){c=Math.ceil(t/r),p=Math.ceil(n/a);var d=Math.max(0,(c-1)*r+i-t),f=Math.max(0,(p-1)*a+o-n),m=Math.floor(d/2),v=d-m,g=Math.floor(f/2);l={top:m,bottom:v,left:g,right:f-g,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-i+1)/r),p=Math.ceil((n-o+1)/a);else{if("object"!=typeof e)throw Error("Unknown padding parameter: "+e);var y="channelsLast"===u?e[1][0]:e[2][0],b="channelsLast"===u?e[1][1]:e[2][1],x="channelsLast"===u?e[2][0]:e[3][0],w="channelsLast"===u?e[2][1]:e[3][1];l={top:y,bottom:b,left:x,right:w,type:0===y&&0===b&&0===x&&0===w?"VALID":"EXPLICIT"},c=FI((t-i+y+b)/r+1,s),p=FI((n-o+x+w)/a+1,s)}return{padInfo:l,outHeight:c,outWidth:p}}(a,l,c,g,y,k,N,i,s),S=I.padInfo,T=I.outHeight,C=I.outWidth,E=o?m*p:m;return"channelsFirst"===s?h=[u,E,T,C]:"channelsLast"===s&&(h=[u,T,C,E]),{batchSize:u,dataFormat:s,inHeight:l,inWidth:c,inChannels:p,outHeight:T,outWidth:C,outChannels:E,padInfo:S,strideHeight:g,strideWidth:y,filterHeight:d,filterWidth:f,effectiveFilterHeight:k,effectiveFilterWidth:N,dilationHeight:x,dilationWidth:w,inShape:e,outShape:h,filterShape:t}}function CI(e,t,n,r,a,i,o,s){void 0===i&&(i=!1),void 0===o&&(o="channelsLast");var u=-1,l=-1,c=-1,p=-1,h=-1;if("channelsLast"===o)u=e[0],l=e[1],c=e[2],p=e[3],h=e[4];else{if("channelsFirst"!==o)throw new Error("Unknown dataFormat "+o);u=e[0],h=e[1],l=e[2],c=e[3],p=e[4]}var d,f=t[0],m=t[1],v=t[2],g=t[4],y=RI(n),b=y[0],x=y[1],w=y[2],k=RI(r),N=k[0],I=k[1],S=k[2],T=_I(f,N),C=_I(m,I),E=_I(v,S),A=function(e,t,n,r,a,i,o,s,u,l,c){var p,h,d,f;"valid"===e&&(e=0);if("number"==typeof e){p={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};var m=function(e,t,n,r,a,i){null==a&&(a=EI(e,t[0],r[0]));for(var o=[0,0,0,n],s=0;s<3;s++)e[s]+2*a>=t[s]&&(o[s]=FI((e[s]-t[s]+2*a)/r[s]+1,i));return o}([t,n,r,1],[s,u,l],1,[a,i,o],e,c);h=m[0],d=m[1],f=m[2]}else{if("same"!==e)throw Error("Unknown padding parameter: "+e);var v=((h=Math.ceil(t/a))-1)*a+s-t,g=((d=Math.ceil(n/i))-1)*i+u-n,y=((f=Math.ceil(r/o))-1)*o+l-r,b=Math.floor(v/2),x=v-b,w=Math.floor(g/2),k=g-w,N=Math.floor(y/2);p={top:w,bottom:k,left:N,right:y-N,front:b,back:x,type:"SAME"}}return{padInfo:p,outDepth:h,outHeight:d,outWidth:f}}(a,l,c,p,b,x,w,T,C,E,s),R=A.padInfo,_=A.outDepth,F=A.outHeight,O=A.outWidth,D=i?g*h:g;return"channelsFirst"===o?d=[u,D,_,F,O]:"channelsLast"===o&&(d=[u,_,F,O,D]),{batchSize:u,dataFormat:o,inDepth:l,inHeight:c,inWidth:p,inChannels:h,outDepth:_,outHeight:F,outWidth:O,outChannels:D,padInfo:R,strideDepth:b,strideHeight:x,strideWidth:w,filterDepth:f,filterHeight:m,filterWidth:v,effectiveFilterDepth:T,effectiveFilterHeight:C,effectiveFilterWidth:E,dilationDepth:N,dilationHeight:I,dilationWidth:S,inShape:e,outShape:d,filterShape:t}}function EI(e,t,n,r){void 0===r&&(r=1);var a=_I(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function AI(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function RI(e){return"number"==typeof e?[e,e,e]:e}function _I(e,t){return t<=1?e:e+(e-1)*(t-1)}function FI(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error("Unknown roundingMode "+t)}}function OI(e){var t=AI(e),n=t[0],r=t[1],a=t[2];return 1===n&&1===r&&1===a}function DI(e,t){return OI(e)||OI(t)}function MI(e){return AI(e).every((function(e){return e>0}))}function LI(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error("Unknown dataFormat "+e)}function zI(e,t,n){if(null!=n){if("string"==typeof t)throw Error("Error in "+e+": pad must be an integer when using dimRoundingMode "+n+" but got pad "+t+".");if("number"==typeof t)Hv(Jv(t),(function(){return"Error in "+e+": pad must be an integer when using dimRoundingMode "+n+" but got pad "+t+"."}));else{if("object"!=typeof t)throw Error("Error in "+e+": Unknown padding parameter: "+t);t.forEach((function(t){t.forEach((function(t){Hv(Jv(t),(function(){return"Error in "+e+": pad must be an integer when using dimRoundingMode "+n+" but got pad "+t+"."}))}))}))}}}var PI=Wk({reshape_:function(e,t){var n={x:zk(e,"x","reshape","string_or_numeric")},r={shape:t};return Ek.runKernel(qb,n,r)}});var BI=Wk({avgPool_:function(e,t,n,r,a){var i=zk(e,"x","avgPool","float32");Hv(DI(n,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '1'"}));var o=i,s=!1;3===i.rank&&(s=!0,o=PI(i,[1,i.shape[0],i.shape[1],i.shape[2]])),Hv(4===o.rank,(function(){return"Error in avgPool: x must be rank 4 but got rank "+o.rank+"."})),zI("avgPool",r,a);var u={x:o},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=Ek.runKernel(Yg,u,l);return c=XN(c,i.dtype),s?PI(c,[c.shape[1],c.shape[2],c.shape[3]]):c}});var WI=Wk({avgPool3d_:function(e,t,n,r,a,i){void 0===i&&(i="NDHWC");var o=zk(e,"x","avgPool3d","float32"),s=o,u=!1;4===o.rank&&(u=!0,s=PI(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),Hv(5===s.rank,(function(){return"Error in avgPool3d: x must be rank 5 but got rank "+s.rank+"."})),Hv("NDHWC"===i,(function(){return"Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of "+i})),Hv("number"==typeof n&&n>0||Array.isArray(n)&&n[0]>0&&n[1]>0&&n[2]>0,(function(){return"Error in avgPool3d: Stride must be > 0, but got '"+n+"'"})),zI("avgPool3d",r,a);var l={x:s},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i},p=Ek.runKernel(Zg,l,c);return p=XN(p,s.dtype),u?PI(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}});var VI=Wk({concat_:function(e,t){void 0===t&&(t=0),Hv(e.length>=1,(function(){return"Pass at least one tensor to concat"}));var n=Pk(e,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((function(e){if("complex64"!==e.dtype)throw new Error("Cannot concatenate complex64 tensors with a tensor\n with dtype "+e.dtype+". ")})),1===n.length)return YN(n[0]);var r=n,a={axis:t};return Ek.runKernel(ly,r,a)}});var UI=Wk({matMul_:function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var a=zk(e,"a","matMul"),i=zk(t,"b","matMul"),o=gk(a,i),s={a:a=o[0],b:i=o[1]},u={transposeA:n,transposeB:r};return Ek.runKernel($g,s,u)}});var GI=Wk({sigmoid_:function(e){var t={x:zk(e,"x","sigmoid","float32")};return Ek.runKernel(cx,t)}});var jI=Wk({slice_:function(e,t,n){var r=zk(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");var a={x:r},i={begin:t,size:n};return Ek.runKernel(ox,a,i)}});var HI=Wk({tanh_:function(e){var t={x:zk(e,"x","tanh","float32")};return Ek.runKernel(_x,t)}});var qI=Wk({basicLSTMCell_:function(e,t,n,r,a,i){var o=zk(e,"forgetBias","basicLSTMCell"),s=zk(t,"lstmKernel","basicLSTMCell"),u=zk(n,"lstmBias","basicLSTMCell"),l=zk(r,"data","basicLSTMCell"),c=zk(a,"c","basicLSTMCell"),p=zk(i,"h","basicLSTMCell"),h=VI([l,p],1),d=UI(h,s),f=oI(d,u),m=f.shape[0],v=f.shape[1]/4,g=[m,v],y=jI(f,[0,0],g),b=jI(f,[0,v],g),x=jI(f,[0,2*v],g),w=jI(f,[0,3*v],g),k=oI(lI(GI(y),HI(b)),lI(c,GI(oI(o,x))));return[k,lI(HI(k),GI(w))]}});var KI=Wk({batchToSpaceND_:function(e,t,n){var r=zk(e,"x","batchToSpaceND"),a=t.reduce((function(e,t){return e*t}));Hv(r.rank>=1+t.length,(function(){return"input rank is "+r.rank+" but should be > than blockShape.length "+t.length})),Hv(n.length===t.length,(function(){return"crops.length is "+n.length+" but should be equal to blockShape.length "+t.length})),Hv(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 "+t.join(" * ")+" === "+a}));var i={x:r},o={blockShape:t,crops:n};return Ek.runKernel(ey,i,o)}});var XI=Wk({batchNorm_:function(e,t,n,r,a,i){null==i&&(i=.001);var o,s,u=zk(e,"x","batchNorm"),l=zk(t,"mean","batchNorm"),c=zk(n,"variance","batchNorm");null!=a&&(o=zk(a,"scale","batchNorm")),null!=r&&(s=zk(r,"offset","batchNorm")),Hv(l.rank===c.rank,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),Hv(null==s||l.rank===s.rank,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),Hv(null==o||l.rank===o.rank,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}));var p=function(e){return 0===e.rank||1===e.rank?PI(e,[1,1,1,e.size]):2===e.rank?PI(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?PI(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e}(u),h={x:p,scale:o,offset:s,mean:l,variance:c},d={varianceEpsilon:i},f=Ek.runKernel(jy,h,d);return PI(f,u.shape)}});var YI=Wk({batchNorm2d_:function(e,t,n,r,a,i){var o,s,u=zk(e,"x","batchNorm"),l=zk(t,"mean","batchNorm"),c=zk(n,"variance","batchNorm");return null!=a&&(o=zk(a,"scale","batchNorm")),null!=r&&(s=zk(r,"offset","batchNorm")),Hv(2===u.rank,(function(){return"Error in batchNorm2D: x must be rank 2 but got rank "+u.rank+"."})),Hv(2===l.rank||1===l.rank,(function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank "+l.rank+"."})),Hv(2===c.rank||1===c.rank,(function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank "+c.rank+"."})),null!=o&&Hv(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&&Hv(2===s.rank||1===s.rank,(function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank "+s.rank+"."})),XI(u,l,c,s,o,i)}});var JI=Wk({batchNorm3d_:function(e,t,n,r,a,i){var o,s,u=zk(e,"x","batchNorm"),l=zk(t,"mean","batchNorm"),c=zk(n,"variance","batchNorm");return null!=a&&(o=zk(a,"scale","batchNorm")),null!=r&&(s=zk(r,"offset","batchNorm")),Hv(3===u.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+"."})),Hv(3===l.rank||1===l.rank,(function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank "+l.rank+"."})),Hv(3===c.rank||1===c.rank,(function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank "+c.rank+"."})),null!=o&&Hv(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&&Hv(3===s.rank||1===s.rank,(function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank "+s.rank+"."})),XI(u,l,c,s,o,i)}});var ZI=Wk({batchNorm4d_:function(e,t,n,r,a,i){var o,s,u=zk(e,"x","batchNorm"),l=zk(t,"mean","batchNorm"),c=zk(n,"variance","batchNorm");return null!=a&&(o=zk(a,"scale","batchNorm")),null!=r&&(s=zk(r,"offset","batchNorm")),Hv(4===u.rank,(function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+u.rank+"."})),Hv(4===l.rank||1===l.rank,(function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank "+l.rank+"."})),Hv(4===c.rank||1===c.rank,(function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank "+c.rank+"."})),null!=o&&Hv(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&&Hv(4===s.rank||1===s.rank,(function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank "+s.rank+"."})),XI(u,l,c,s,o,i)}});var QI=Wk({bincount_:function(e,t,n){var r=zk(e,"x","bincount"),a=zk(t,"weights","bincount");Hv("int32"===r.dtype,(function(){return"Error in bincount: input dtype must be int32, but got "+r.dtype})),Hv(n>=0,(function(){return"size must be non-negative, but got "+n+"."})),Hv(a.size===r.size||0===a.size,(function(){return"Error in bincount: weights must have the same size as input or0-length, but got input shape: "+r.shape+", weights shape: "+a.shape+"."}));var i={x:r,weights:a},o={size:n};return Ek.runKernel(ty,i,o)}});var $I=Wk({broadcastArgs_:function(e,t){var n=zk(e,"s0","broadcastArgs","int32"),r=zk(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error("broadcastArgs(): first input must be a vector (rank=1). Has rank "+n.rank);if(1!==r.rank)throw new Error("broadcastArgs(): second input must be a vector (rank=1). Has rank "+r.rank);var a={s0:n,s1:r};return Ek.runKernel(ry,a)}});var eS=Wk({broadcastTo_:function(e,t){var n=zk(e,"broadcastTo","x"),r=n.shape;if(Ng(t),t.length<n.rank)throw new Error("broadcastTo(): shape.length="+t.length+" < input.rank="+n.rank+".");if(t.length>n.rank){for(var a=n.shape.slice();a.length<t.length;)a.unshift(1);n=PI(n,a)}for(var i=n.shape,o=Array.from(t),s=t.length-1;s>=0;s--)if(i[s]===t[s])o[s]=1;else if(1!==n.shape[s])throw new Error("broadcastTo(): ["+r+"] cannot be broadcast to ["+t+"].");var u=o.map((function(e,t){return e>1?t:-1})).filter((function(e){return e>=0}));if(0===u.length)return YN(n);var l={x:n},c={reps:o};return Ek.runKernel(Fx,l,c)}});var tS=Wk({ceil_:function(e){var t={x:zk(e,"x","ceil","float32")};return Ek.runKernel(iy,t)}});function nS(e,t,n){Ng(e);var r={shape:e,value:t,dtype:n=n||dg(t)};return Ek.runKernel(Wy,{},r)}var rS=Wk({clipByValue_:function(e,t,n){var r=zk(e,"x","clipByValue");if(Hv(t<=n,(function(){return"Error in clip: min ("+t+") must be less than or equal to max ("+n+")."})),t===n)return nS(r.shape,t,r.dtype);var a={x:r},i={clipValueMin:t,clipValueMax:n};return Ek.runKernel(oy,a,i)}});var aS=Wk({concat1d_:function(e){return VI(e,0)}});var iS=Wk({concat2d_:function(e,t){return VI(e,t)}});var oS=Wk({concat3d_:function(e,t){return VI(e,t)}});var sS=Wk({concat4d_:function(e,t){return VI(e,t)}});var uS=Wk({conv2d_:function(e,t,n,r,a,i,o){void 0===a&&(a="NHWC"),void 0===i&&(i=[1,1]);var s=zk(e,"x","conv2d","float32"),u=zk(t,"filter","conv2d","float32"),l=s,c=!1;3===s.rank&&(c=!0,l=PI(s,[1,s.shape[0],s.shape[1],s.shape[2]])),Hv(4===l.rank,(function(){return"Error in conv2d: input must be rank 4, but got rank "+l.rank+"."})),Hv(4===u.rank,(function(){return"Error in conv2d: filter must be rank 4, but got rank "+u.rank+"."})),zI("conv2d",r,o);var p="NHWC"===a?l.shape[3]:l.shape[1];Hv(p===u.shape[2],(function(){return"Error in conv2d: depth of input ("+p+") must match input depth for filter "+u.shape[2]+"."})),Hv(DI(n,i),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"})),Hv(MI(i),(function(){return"Error in conv2D: Dilated rates should be larger than 0."})),Hv(MI(n),(function(){return"Error in conv2D: Strides should be larger than 0."}));var h={x:l,filter:u},d={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:o},f=Ek.runKernel(cy,h,d);return c?PI(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});var lS=Wk({conv1d_:function(e,t,n,r,a,i,o){void 0===a&&(a="NWC"),void 0===i&&(i=1);var s=zk(e,"x","conv1d"),u=zk(t,"filter","conv1d"),l=s,c=!1;2===s.rank&&(c=!0,l=PI(s,[1,s.shape[0],s.shape[1]])),Hv(3===l.rank,(function(){return"Error in conv1d: input must be rank 3, but got rank "+l.rank+"."})),Hv(3===u.rank,(function(){return"Error in conv1d: filter must be rank 3, but got rank "+u.rank+"."})),zI("conv1d",r,o),Hv(l.shape[2]===u.shape[1],(function(){return"Error in conv1d: depth of input ("+l.shape[2]+") must match input depth for filter "+u.shape[1]+"."})),Hv(DI(n,i),(function(){return"Error in conv1D: Either stride or dilation must be 1. Got stride "+n+" and dilation '"+i+"'"})),Hv(MI(i),(function(){return"Error in conv1D: Dilated rates should be larger than 0."})),Hv(MI(n),(function(){return"Error in conv1D: Stride should be larger than 0."})),Hv("NWC"===a,(function(){return"Error in conv1d: got dataFormat of "+a+" but only NWC is currently supported."}));var p=PI(u,[1,u.shape[0],u.shape[1],u.shape[2]]),h=PI(l,[l.shape[0],1,l.shape[1],l.shape[2]]),d=uS(h,p,[1,n],r,"NHWC",[1,i],o);return PI(d,c?[d.shape[2],d.shape[3]]:[d.shape[0],d.shape[2],d.shape[3]])}});var cS=Wk({conv2DBackpropInput_:function(e,t,n,r,a,i,o){void 0===i&&(i="NHWC"),Hv(e.length===t.rank,(function(){return"Length of inShape ("+e.length+") and rank of dy ("+t.rank+") must match"}));var s=e,u=t,l=!1;3===t.rank&&(l=!0,u=PI(t,[1,t.shape[0],t.shape[1],t.shape[2]]),s=[1,e[0],e[1],e[2]]),Hv(4===s.length,(function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+s.length+"."})),Hv(4===u.rank,(function(){return"Error in conv2dDerInput: dy must be rank 4, but got rank "+u.rank})),Hv(4===n.rank,(function(){return"Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank}));var c="NHWC"===i?s[3]:s[1],p="NHWC"===i?u.shape[3]:u.shape[1];Hv(c===n.shape[2],(function(){return"Error in conv2dDerInput: depth of input ("+c+") must match input depth for filter "+n.shape[2]+"."})),Hv(p===n.shape[3],(function(){return"Error in conv2dDerInput: depth of output ("+p+") must match output depth for filter "+n.shape[3]+"."})),zI("conv2dDerInput",a,o);var h={dy:u,filter:n},d={strides:r,pad:a,dataFormat:i,dimRoundingMode:o,inputShape:s},f=Ek.runKernel(hy,h,d);return l?PI(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});var pS=Wk({conv2dTranspose_:function(e,t,n,r,a,i){var o=zk(e,"x","conv2dTranspose"),s=zk(t,"filter","conv2dTranspose");return cS(n,o,s,r,a,"NHWC",i)}});var hS=Wk({conv3d_:function(e,t,n,r,a,i){void 0===a&&(a="NDHWC"),void 0===i&&(i=[1,1,1]);var o=zk(e,"x","conv3d"),s=zk(t,"filter","conv3d"),u=o,l=!1;4===o.rank&&(l=!0,u=PI(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),Hv(5===u.rank,(function(){return"Error in conv3d: input must be rank 5, but got rank "+u.rank+"."})),Hv(5===s.rank,(function(){return"Error in conv3d: filter must be rank 5, but got rank "+s.rank+"."})),Hv(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]+"."})),Hv(DI(n,i),(function(){return"Error in conv3D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"})),Hv("NDHWC"===a,(function(){return"Error in conv3d: got dataFormat of "+a+" but only NDHWC is currently supported."})),Hv(MI(i),(function(){return"Error in conv3D: Dilated rates should be larger than 0."})),Hv(MI(n),(function(){return"Error in conv3D: Strides should be larger than 0."}));var c={x:u,filter:s},p={strides:n,pad:r,dataFormat:a,dilations:i},h=Ek.runKernel(dy,c,p);return l?PI(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}});var dS=Wk({conv3DBackpropInput_:function(e,t,n,r,a){Hv(e.length===t.rank,(function(){return"Length of inShape ("+e.length+") and rank of dy ("+t.rank+") must match"}));var i=e,o=t,s=!1;4===t.rank&&(s=!0,o=PI(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);var u=i[4],l=o.shape[4];Hv(5===i.length,(function(){return"Error in conv3dDerInput: inShape must be length 5, but got length "+i.length+"."})),Hv(5===o.rank,(function(){return"Error in conv3dDerInput: dy must be rank 5, but got rank "+o.rank})),Hv(5===n.rank,(function(){return"Error in conv3dDerInput: filter must be rank 5, but got rank "+n.rank})),Hv(u===n.shape[3],(function(){return"Error in conv3dDerInput: depth of input ("+u+") must match input depth for filter "+n.shape[3]+"."})),Hv(l===n.shape[4],(function(){return"Error in conv3dDerInput: depth of output ("+l+") must match output depth for filter "+n.shape[4]+"."}));var c={dy:o,filter:n},p={pad:a,strides:r,inputShape:i},h=Ek.runKernel(my,c,p);return s?PI(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}});var fS=Wk({conv3dTranspose_:function(e,t,n,r,a){var i=zk(e,"x","conv3dTranspose"),o=zk(t,"filter","conv3dTranspose");return dS(n,i,o,r,a)}});var mS=Wk({cos_:function(e){var t={x:zk(e,"x","cos","float32")};return Ek.runKernel(vy,t)}});var vS=Wk({cosh_:function(e){var t={x:zk(e,"x","cosh","float32")};return Ek.runKernel(gy,t)}});var gS=Wk({cumprod_:function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var a={x:zk(e,"x","cumprod")},i={axis:t,exclusive:n,reverse:r};return Ek.runKernel(yy,a,i)}});var yS=Wk({cumsum_:function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var a={x:zk(e,"x","cumsum")},i={axis:t,exclusive:n,reverse:r};return Ek.runKernel(by,a,i)}});var bS=Wk({denseBincount_:function(e,t,n,r){void 0===r&&(r=!1);var a=zk(e,"x","denseBincount"),i=zk(t,"weights","denseBincount");Hv("int32"===a.dtype,(function(){return"Error in denseBincount: input dtype must be int32, but got "+a.dtype})),Hv(a.rank<=2,(function(){return"Error in denseBincount: input must be at most rank 2, but got rank "+a.rank+"."})),Hv(n>=0,(function(){return"size must be non-negative, but got "+n+"."})),Hv(i.size===a.size||0===i.size,(function(){return"Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: "+a.shape+", weights shape: "+i.shape+"."}));var o={x:a,weights:i},s={size:n,binaryOutput:r};return Ek.runKernel(wy,o,s)}});var xS=Wk({depthToSpace_:function(e,t,n){void 0===n&&(n="NHWC");var r=zk(e,"x","depthToSpace","float32"),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];Hv(t>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+t})),Hv(a*t>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n "+a+" and "+t+" for depthToSpace with input shape\n "+r.shape})),Hv(i*t>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n "+i+" and "+t+" for depthToSpace with input shape\n "+r.shape})),Hv(o%(t*t)==0,(function(){return"Dimension size must be evenly divisible by "+t*t+" but is "+o+" for depthToSpace with input shape "+r.shape}));var s={x:r},u={blockSize:t,dataFormat:n};return Ek.runKernel(ky,s,u)}});var wS=Wk({depthwiseConv2d_:function(e,t,n,r,a,i,o){void 0===a&&(a="NHWC"),void 0===i&&(i=[1,1]);var s=zk(e,"x","depthwiseConv2d","float32"),u=zk(t,"filter","depthwiseConv2d","float32"),l=s,c=!1;3===s.rank&&(c=!0,l=PI(s,[1,s.shape[0],s.shape[1],s.shape[2]])),Hv(4===l.rank,(function(){return"Error in depthwiseConv2d: input must be rank 4, but got rank "+l.rank+"."})),Hv(4===u.rank,(function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+u.rank+"."}));var p="NHWC"===a?l.shape[3]:l.shape[1];Hv(p===u.shape[2],(function(){return"Error in depthwiseConv2d: number of input channels ("+p+") must match the inChannels dimension in filter "+u.shape[2]+"."})),zI("depthwiseConv2d",r,o);var h={x:l,filter:u},d={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:o},f=Ek.runKernel(Ny,h,d);return c?PI(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});var kS=Wk({diag_:function(e){var t={x:zk(e,"x","diag")};return Ek.runKernel(Ty,t)}});var NS=Wk({dilation2d_:function(e,t,n,r,a,i){void 0===a&&(a=[1,1]),void 0===i&&(i="NHWC");var o=zk(e,"x","dilation2d"),s=zk(t,"filter","dilation2d");Hv(3===o.rank||4===o.rank,(function(){return"Error in dilation2d: input must be rank 3 or 4, but got rank "+o.rank+"."})),Hv(3===s.rank,(function(){return"Error in dilation2d: filter must be rank 3, but got rank "+s.rank+"."})),Hv("NHWC"===i,(function(){return"Error in dilation2d: Only NHWC is currently supported, but got dataFormat of "+i}));var u=o,l=!1;3===o.rank&&(u=PI(o,[1,o.shape[0],o.shape[1],o.shape[2]]),l=!0),Hv(u.shape[3]===s.shape[2],(function(){return"Error in dilation2d: input and filter must have the same depth: "+u.shape[3]+" vs "+s.shape[2]}));var c={x:u,filter:s},p={strides:n,pad:r,dilations:a},h=Ek.runKernel(Cy,c,p);return l?PI(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});function IS(e,t){for(var n=e.length,r=[],a=0;a<n;a++){var i=n-1-a,o=e[i]||1;(t[t.length-1-a]||1)>1&&1===o&&r.unshift(i)}return r}function SS(e,t){for(var n=[],r=0;r<t.length;r++){var a=e[e.length-r-1],i=t.length-r-1,o=t[i];(null==a||1===a&&o>1)&&n.unshift(i)}return n}function TS(e,t){for(var n=Math.max(e.length,t.length),r=new Array(n),a=0;a<n;a++){var i=e[e.length-a-1];null==i&&(i=1);var o=t[t.length-a-1];if(null==o&&(o=1),1===i)r[n-a-1]=o;else if(1===o)r[n-a-1]=i;else{if(i!==o)throw Error("Operands could not be broadcast together with shapes "+e+" and "+t+".");r[n-a-1]=i}}return r}var CS={__proto__:null,getBroadcastDims:IS,getReductionAxes:SS,assertAndGetBroadcastShape:TS};var ES=Wk({equal_:function(e,t){var n=zk(e,"a","equal","string_or_numeric"),r=zk(t,"b","equal","string_or_numeric"),a=gk(n,r);n=a[0],r=a[1],TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(My,i)}});var AS=Wk({where_:function(e,t,n){var r=zk(t,"a","where"),a=zk(n,"b","where"),i=zk(e,"condition","where","bool"),o=TS(TS(i.shape,r.shape),a.shape),s={condition:eS(i,o),t:eS(r,o),e:eS(a,o)};return Ek.runKernel(ax,s)}});var RS=Wk({zerosLike_:function(e){var t={x:zk(e,"x","zerosLike")};return Ek.runKernel(Bx,t)}});var _S=Wk({divNoNan_:function(e,t){var n=zk(e,"a","div"),r=zk(t,"b","div"),a=gk(n,r);n=a[0],r=a[1];var i=uI(n,r),o=RS(i),s=ES(r,o);return AS(s,o,i)}});var FS=Wk({dot_:function(e,t){var n=zk(e,"t1","dot"),r=zk(t,"t2","dot");Hv(!(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(Hv(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=PI(n,[1,-1]),s=PI(r,[-1,1]),u=UI(o,s);return PI(u,[])}if(1===n.rank&&2===r.rank){var l=PI(n,[1,-1]),c=PI(r,[r.shape[0],r.shape[1]]),p=UI(l,c);return PI(p,[p.size])}if(2===n.rank&&1===r.rank){var h=PI(r,[-1,1]),d=UI(n,h);return PI(d,[d.size])}var f=PI(r,[r.shape[0],r.shape[1]]);return UI(n,f)}});var OS=Wk({einsum_:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var a=n.map((function(e,t){return zk(e,"tensors"+t,"einsum")})),i={equation:e};return Ek.runKernel(_y,a,i)}});var DS=Wk({elu_:function(e){var t={x:zk(e,"x","elu","float32")};return Ek.runKernel(Fy,t)}});var MS=Wk({erf_:function(e){var t=zk(e,"x","erf");Hv("int32"===t.dtype||"float32"===t.dtype,(function(){return"Input dtype must be `int32` or `float32`."})),"int32"===t.dtype&&(t=XN(t,"float32"));var n={x:t};return Ek.runKernel(Dy,n)}});function LS(e,t){for(var n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function zS(e,t,n){for(var r=e.length+t.length,a=[],i=0,o=0,s=0;s<r;s++)-1===n.indexOf(s)?a.push(e[i++]):a.push(t[o++]);return a}function PS(e,t){for(var n=[],r=e.length,a=0;a<r;a++)-1===t.indexOf(a)&&n.push(e[a]);var i=t.map((function(t){return e[t]}));return[n,i]}function BS(e,t){return zS(e,t.map((function(e){return 1})),t)}function WS(e,t,n){Hv(LS(t,n),(function(){return e+" supports only inner-most axes for now. Got axes "+t+" and rank-"+n+" input."}))}function VS(e,t){if(LS(e,t))return null;for(var n=[],r=0;r<t;++r)-1===e.indexOf(r)&&n.push(r);return e.forEach((function(e){return n.push(e)})),n}function US(e){return e.map((function(e,t){return[t,e]})).sort((function(e,t){return e[1]-t[1]})).map((function(e){return e[0]}))}function GS(e,t){for(var n=[],r=t-e;r<t;++r)n.push(r);return n}var jS=Wk({max_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:zk(e,"x","max")},a={reductionIndices:t,keepDims:n};return Ek.runKernel(db,r,a)}});var HS=Wk({min_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:zk(e,"x","min")},a={axis:t,keepDims:n};return Ek.runKernel(wb,r,a)}});var qS=Wk({pow_:function(e,t){var n=zk(e,"base","pow"),r=zk(t,"exp","pow"),a=gk(n,r),i={a:n=a[0],b:r=a[1]};return Ek.runKernel(Lb,i)}});function KS(e,t){if((Hw(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&Hw(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Uk(e,[],[],t)}var XS=Wk({sqrt_:function(e){var t={x:zk(e,"x","sqrt","float32")};return Ek.runKernel(hx,t)}});var YS=Wk({square_:function(e){var t=zk(e,"x","square");return Ek.runKernel("Square",{x:t},{})}});var JS=Wk({sum_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=zk(e,"x","sum");"bool"===r.dtype&&(r=XN(r,"int32"));var a={x:r},i={axis:t,keepDims:n};return Ek.runKernel(dx,a,i)}});function ZS(e,t,n){if(void 0===n&&(n=null),0===e.rank)return cI(e);if(1!==e.rank&&null===n)return ZS(PI(e,[-1]),t,n);if(1===e.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===t)return JS(cI(e),n);if(t===1/0)return jS(cI(e),n);if(t===-1/0)return HS(cI(e),n);if("euclidean"===t||2===t)return XS(JS(qS(cI(e),KS(2,"int32")),n));throw new Error("Error in norm: invalid ord value: "+t)}if(Array.isArray(n)&&2===n.length){if(1===t)return jS(JS(cI(e),n[0]),n[1]-1);if(t===1/0)return jS(JS(cI(e),n[1]),n[0]);if(t===-1/0)return HS(JS(cI(e),n[1]),n[0]);if("fro"===t||"euclidean"===t)return XS(JS(YS(e),n));throw new Error("Error in norm: invalid ord value: "+t)}throw new Error("Error in norm: invalid axis: "+n)}var QS=Wk({norm_:function(e,t,n,r){void 0===t&&(t="euclidean"),void 0===n&&(n=null),void 0===r&&(r=!1);var a=ZS(e=zk(e,"x","norm"),t,n),i=a.shape;if(r){var o=tg(n,e.shape);i=BS(a.shape,o)}return PI(a,i)}});var $S=Wk({euclideanNorm_:function(e,t,n){return void 0===t&&(t=null),void 0===n&&(n=!1),QS(e,"euclidean",t,n)}});var eT=Wk({exp_:function(e){var t={x:zk(e,"x","exp")};return Ek.runKernel(Ly,t)}});var tT=Wk({expandDims_:function(e,t){void 0===t&&(t=0);var n=zk(e,"x","expandDims","string_or_numeric");Hv(t<=n.rank,(function(){return"Axis must be <= rank of the tensor"}));var r={input:n},a={dim:t};return Ek.runKernel(zy,r,a)}});var nT=Wk({expm1_:function(e){var t={x:zk(e,"x","expm1")};return Ek.runKernel(Py,t)}});var rT=Wk({tile_:function(e,t){var n=zk(e,"x","tile","string_or_numeric");Hv(n.rank===t.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of reps "+t+"."}));var r={x:n},a={reps:t};return Ek.runKernel(Fx,r,a)}});var aT=Wk({eye_:function(e,t,n,r){void 0===r&&(r="float32"),null==t&&(t=e);for(var a=KN([e,t],r),i=e<=t?e:t,o=0;o<i;++o)a.set(1,o,o);var s=PI(a.toTensor(),[e,t]);if(null==n)return s;if(1===n.length)return rT(tT(s,0),[n[0],1,1]);if(2===n.length)return rT(tT(tT(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return rT(tT(tT(tT(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 iT=Wk({floor_:function(e){var t={x:zk(e,"x","floor","float32")};return Ek.runKernel(Uy,t)}});var oT=Wk({gather_:function(e,t,n,r){void 0===n&&(n=0),void 0===r&&(r=0);var a={x:zk(e,"x","gather"),indices:zk(t,"indices","gather","int32")},i={axis:n,batchDims:r};return Ek.runKernel(Hy,a,i)}});var sT=Wk({greater_:function(e,t){var n=zk(e,"a","greater","string_or_numeric"),r=zk(t,"b","greater","string_or_numeric"),a=gk(n,r);n=a[0],r=a[1],TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(Ky,i)}});var uT=Wk({greaterEqual_:function(e,t){var n=zk(e,"a","greaterEqual","string_or_numeric"),r=zk(t,"b","greaterEqual","string_or_numeric"),a=gk(n,r);n=a[0],r=a[1],TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(Xy,i)}});var lT=Wk({imag_:function(e){var t={input:zk(e,"input","imag")};return Ek.runKernel(Zy,t)}});var cT=Wk({isFinite_:function(e){var t={x:zk(e,"x","isFinite")};return Ek.runKernel(Qy,t)}});var pT=Wk({isInf_:function(e){var t={x:zk(e,"x","isInf")};return Ek.runKernel($y,t)}});var hT=Wk({isNaN_:function(e){var t={x:zk(e,"x","isNaN")};return Ek.runKernel(eb,t)}});var dT=Wk({leakyRelu_:function(e,t){void 0===t&&(t=.2);var n={x:zk(e,"x","leakyRelu")},r={alpha:t};return Ek.runKernel(tb,n,r)}});var fT=Wk({less_:function(e,t){var n=zk(e,"a","less","string_or_numeric"),r=zk(t,"b","less","string_or_numeric"),a=gk(n,r);n=a[0],r=a[1],TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(nb,i)}});var mT=Wk({lessEqual_:function(e,t){var n=zk(e,"a","lessEqual","string_or_numeric"),r=zk(t,"b","lessEqual","string_or_numeric"),a=gk(n,r);n=a[0],r=a[1],TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(rb,i)}});function vT(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");var r={start:e,stop:t,num:n};return Ek.runKernel(ab,{},r)}var gT=Wk({localResponseNormalization_:function(e,t,n,r,a){void 0===t&&(t=5),void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=.5);var i=zk(e,"x","localResponseNormalization");Hv(4===i.rank||3===i.rank,(function(){return"Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank "+i.rank+"."})),Hv(Jv(t),(function(){return"Error in localResponseNormalization: depthRadius must be an integer but got depthRadius "+t+"."}));var o=i,s=!1;3===i.rank&&(s=!0,o=PI(i,[1,i.shape[0],i.shape[1],i.shape[2]]));var u={x:o},l={depthRadius:t,bias:n,alpha:r,beta:a},c=Ek.runKernel(pb,u,l);return s?PI(c,[c.shape[1],c.shape[2],c.shape[3]]):c}});var yT=Wk({log_:function(e){var t={x:zk(e,"x","log","float32")};return Ek.runKernel(ib,t)}});var bT=Wk({log1p_:function(e){var t={x:zk(e,"x","log1p")};return Ek.runKernel(ob,t)}});function xT(e,t){Hv(fg(e),(function(){return"The f passed in variableGrads(f) must be a function"})),Hv(null==t||Array.isArray(t)&&t.every((function(e){return e instanceof pk})),(function(){return"The varList passed in variableGrads(f, varList) must be an array of variables"}));var n=null!=t;if(!n)for(var r in t=[],Ek.registeredVariables)t.push(Ek.registeredVariables[r]);var a=n?t.filter((function(e){return!e.trainable})):null,i=t.length;t=t.filter((function(e){return e.trainable})),Hv(t.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=Ek.gradients(e,t,null,!0),s=o.value,u=o.grads;Hv(u.some((function(e){return null!=e})),(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()."})),Hv(0===s.rank,(function(){return"The f passed in variableGrads(f) must return a scalar, but it returned a rank-"+s.rank+" tensor"}));var l={};return t.forEach((function(e,t){null!=u[t]&&(l[e.name]=u[t])})),null!=a&&a.forEach((function(e){return l[e.name]=null})),{value:s,grads:l}}function wT(e){return Ek.customGrad(e)}function kT(e){if(e.filter((function(e){return null==e})).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.")}var NT=Wk({neg_:function(e){var t={x:zk(e,"x","neg")};return Ek.runKernel(Cb,t)}});var IT=Wk({softplus_:function(e){var t={x:zk(e,"x","softplus")};return Ek.runKernel(px,t)}});var ST=Wk({logSigmoid_:function(e){var t=zk(e,"x","logSigmoid"),n=wT((function(e){return{value:NT(IT(NT(e))),gradFunc:function(t){return lI(t,GI(NT(e)))}}}));return n(t)}});var TT=Wk({sub_:function(e,t){var n=zk(e,"a","sub"),r=zk(t,"b","sub"),a=gk(n,r),i={a:n=a[0],b:r=a[1]};return Ek.runKernel(Ax,i)}});var CT=Wk({logSoftmax_:function(e,t){void 0===t&&(t=-1);var n=zk(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and axis was "+t);var r=wT((function(e,n){var r=jS(e,t,!0),a=TT(e,r),i=TT(XN(a,"float32"),yT(JS(eT(a),t,!0)));n([i]);return{value:i,gradFunc:function(e,n){var r=n[0],a=eT(r);return TT(e,lI(JS(e,t,!0),a))}}}));return r(n)}});var ET=Wk({logSumExp_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=zk(e,"x","logSumExp"),a=tg(t,r.shape),i=jS(r,a,!0),o=TT(r,i),s=eT(o),u=JS(s,a),l=yT(u),c=oI(PI(i,l.shape),l);if(n){var p=BS(c.shape,a);return PI(c,p)}return c}});var AT=Wk({logicalAnd_:function(e,t){var n=zk(e,"a","logicalAnd","bool"),r=zk(t,"b","logicalAnd","bool");TS(n.shape,r.shape);var a={a:n,b:r};return Ek.runKernel(sb,a)}});var RT=Wk({logicalNot_:function(e){var t={x:zk(e,"x","logicalNot","bool")};return Ek.runKernel(ub,t)}});var _T=Wk({logicalOr_:function(e,t){var n=zk(e,"a","logicalOr","bool"),r=zk(t,"b","logicalOr","bool");TS(n.shape,r.shape);var a={a:n,b:r};return Ek.runKernel(lb,a)}});var FT=Wk({logicalXor_:function(e,t){var n=zk(e,"a","logicalXor","bool"),r=zk(t,"b","logicalXor","bool");return TS(n.shape,r.shape),AT(_T(e,t),RT(AT(e,t)))}}),OT=2147483648;var DT=Wk({searchSorted_:function(e,t,n){void 0===n&&(n="left");var r=zk(e,"sortedSequence","searchSorted"),a=zk(t,"values","searchSorted"),i=r.shape[r.shape.length-1],o=a.shape[a.shape.length-1],s=PI(r,[-1,i]),u=PI(a,[-1,o]);if(s.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(s.shape[0]!==u.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(Xv(u.shape)>=OT)throw new Error("values tensor size must less than 2147483648");if(s.shape[1]>=OT)throw new Error("trailing dim_size must less than 2147483648 for int32 output type, was "+s.shape[1]);var l={sortedSequence:s,values:u},c={side:n};return Ek.runKernel(rx,l,c)}});function MT(e,t){return DT(e,t,"left")}var LT=Wk({maxPool_:function(e,t,n,r,a){var i=zk(e,"x","maxPool"),o=i,s=!1;3===i.rank&&(s=!0,o=PI(i,[1,i.shape[0],i.shape[1],i.shape[2]])),Hv(4===o.rank,(function(){return"Error in maxPool: input must be rank 4 but got rank "+o.rank+"."})),Hv(DI(n,1),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '1'"})),zI("maxPool",r,a);var u={x:o},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=Ek.runKernel(mb,u,l);return s?PI(c,[c.shape[1],c.shape[2],c.shape[3]]):c}});var zT=Wk({maxPool3d_:function(e,t,n,r,a,i){void 0===t&&(t=[1,1,1]),void 0===i&&(i="NDHWC");var o=zk(e,"x","maxPool3d"),s=o,u=!1;4===o.rank&&(u=!0,s=PI(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),Hv(5===s.rank,(function(){return"Error in maxPool3d: x must be rank 5 but got rank "+s.rank+"."})),Hv("NDHWC"===i,(function(){return"Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of "+i})),zI("maxPool3d",r,a);var l={x:s},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i},p=Ek.runKernel(gb,l,c);return u?PI(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}});var PT=Wk({maxPoolWithArgmax_:function(e,t,n,r,a){void 0===a&&(a=!1);var i={x:zk(e,"x","maxPoolWithArgmax")},o={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},s=Ek.runKernel(bb,i,o);return{result:s[0],indexes:s[1]}}});var BT=Wk({maximum_:function(e,t){var n=zk(e,"a","maximum"),r=zk(t,"b","maximum"),a=gk(n,r);n=a[0],r=a[1],"bool"===n.dtype&&(n=XN(n,"int32"),r=XN(r,"int32")),TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(fb,i)}});var WT=Wk({mean_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:zk(e,"x","mean")},a={axis:t,keepDims:n};return Ek.runKernel(xb,r,a)}});function VT(e,t){if(void 0===t&&(t="float32"),Ng(e),"complex64"===t){var n=VT(e,"float32"),r=VT(e,"float32");return Vk(n,r)}var a=wg(Xv(e),t);return Ek.makeTensor(a,e,t)}function UT(e,t){if(void 0===t&&(t="float32"),Ng(e),"complex64"===t){var n=UT(e,"float32"),r=VT(e,"float32");return Vk(n,r)}var a=xg(Xv(e),t);return Ek.makeTensor(a,e,t)}function GT(e,t,n){var r=(void 0===n?{}:n).indexing,a=void 0===r?"xy":r;if("xy"!==a&&"ij"!==a)throw new TypeError(a+" is not a valid third argument to meshgrid");if(void 0===e)return[];var i=zk(e,"x","meshgrid",e instanceof ak?e.dtype:"float32");if(void 0===t)return[i];var o=zk(t,"y","meshgrid",t instanceof ak?t.dtype:"float32"),s=Xv(i.shape),u=Xv(o.shape);return"xy"===a?(i=PI(i,[1,-1]),o=PI(o,[-1,1]),[UI(UT([u,1],i.dtype),i),UI(o,UT([1,s],o.dtype))]):(i=PI(i,[-1,1]),o=PI(o,[1,-1]),[UI(i,UT([1,u],i.dtype)),UI(UT([s,1],o.dtype),o)])}var jT=Wk({minimum_:function(e,t){var n=zk(e,"a","minimum"),r=zk(t,"b","minimum"),a=gk(n,r);n=a[0],r=a[1],"bool"===n.dtype&&(n=XN(n,"int32"),r=XN(r,"int32")),TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(kb,i)}});var HT=Wk({mirrorPad_:function(e,t,n){Hv("reflect"===n||"symmetric"===n,(function(){return"Invalid mode. Mode must be either reflect or symmetric. Got "+n+"."}));var r=zk(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");Hv(t.length===r.rank,(function(){return"Padding doesn't match input. Must be "+r.rank+". Got "+t.length+"."}));for(var a="reflect"===n?1:0,i=function(e){Hv(2===t[e].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Hv(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(function(){return"Padding in dimension "+e+" cannot be greater than or equal to "+(r.shape[e]-a)+" or less than 0 for input of shape "+r.shape}))},o=0;o<r.rank;o++)i(o);var s={paddings:t,mode:n},u={x:r};return Ek.runKernel(Nb,u,s)}});var qT=Wk({mod_:function(e,t){var n=zk(e,"a","mod"),r=zk(t,"b","mod"),a=gk(n,r),i={a:n=a[0],b:r=a[1]};return Ek.runKernel(Ib,i)}});var KT=Wk({moments_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=tg(t,(e=zk(e,"x","moments")).shape),a=WT(e,r,n),i=a.shape;n||(i=BS(a.shape,r));var o=YS(TT(XN(e,"float32"),PI(a,i)));return{mean:a,variance:WT(o,r,n)}}});var XT=Wk({multiRNNCell_:function(e,t,n,r){for(var a=zk(t,"data","multiRNNCell"),i=Pk(n,"c","multiRNNCell"),o=Pk(r,"h","multiRNNCell"),s=a,u=[],l=0;l<e.length;l++){var c=e[l](s,i[l],o[l]);u.push(c[0]),u.push(c[1]),s=c[1]}for(var p=[],h=[],d=0;d<u.length;d+=2)p.push(u[d]),h.push(u[d+1]);return[p,h]}});var YT=Wk({multinomial_:function(e,t,n,r){void 0===r&&(r=!1);var a=zk(e,"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={logits:1===o?PI(a,[1,-1]):a},u={numSamples:t,seed:n,normalized:r},l=Ek.runKernel(Sb,s,u);return 1===o?PI(l,[l.size]):l}});var JT=Wk({notEqual_:function(e,t){var n=zk(e,"a","notEqual","string_or_numeric"),r=zk(t,"b","notEqual","string_or_numeric"),a=gk(n,r);n=a[0],r=a[1],TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(Eb,i)}});var ZT=Wk({oneHot_:function(e,t,n,r,a){if(void 0===n&&(n=1),void 0===r&&(r=0),void 0===a&&(a="int32"),t<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+t);var i={indices:zk(e,"indices","oneHot","int32")},o={dtype:a,depth:t,onValue:n,offValue:r};return Ek.runKernel(Ob,i,o)}});var QT=Wk({onesLike_:function(e){var t={x:zk(e,"x","onesLike")};return Ek.runKernel(Fb,t)}});var $T=Wk({outerProduct_:function(e,t){var n=zk(e,"v1","outerProduct"),r=zk(t,"v2","outerProduct");Hv(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=PI(n,[-1,1]),i=PI(r,[1,-1]);return UI(a,i)}});var eC=Wk({pad_:function(e,t,n){void 0===n&&(n=0);var r=zk(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var a={paddings:t,constantValue:n},i={x:r};return Ek.runKernel(Mb,i,a)}});var tC=Wk({pad1d_:function(e,t,n){return void 0===n&&(n=0),Hv(2===t.length,(function(){return"Invalid number of paddings. Must be length of 2."})),eC(e,[t],n)}});var nC=Wk({pad2d_:function(e,t,n){return void 0===n&&(n=0),Hv(2===t.length&&2===t[0].length&&2===t[1].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),eC(e,t,n)}});var rC=Wk({pad3d_:function(e,t,n){return void 0===n&&(n=0),Hv(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),eC(e,t,n)}});var aC=Wk({pad4d_:function(e,t,n){return void 0===n&&(n=0),Hv(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),eC(e,t,n)}});var iC=Wk({spaceToBatchND_:function(e,t,n){var r=zk(e,"x","spaceToBatchND");Hv(r.rank>=1+t.length,(function(){return"input rank "+r.rank+" should be > than [blockShape] "+t.length})),Hv(n.length===t.length,(function(){return"paddings.shape[0] "+n.length+" must be equal to [blockShape] "+t.length})),Hv(r.shape.reduce((function(e,r,a){return a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e}),!0),(function(){return"input spatial dimensions "+r.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+t.toString()}));var a={x:r},i={blockShape:t,paddings:n};return Ek.runKernel(fx,a,i)}});var oC=Wk({pool_:function(e,t,n,r,a,i,o){null==a&&(a=[1,1]),null==i&&(i=1),0===r&&(r="valid");var s=zk(e,"x","maxPool"),u=s,l=!1;3===s.rank&&(l=!0,u=PI(s,[1,s.shape[0],s.shape[1],s.shape[2]])),Hv(DI(i,a),(function(){return"Error in pool: Either strides or dilations must be 1. Got strides "+i+" and dilations '"+a+"'"}));var c,p=II(u.shape,t,i,a,r),h=[p.dilationHeight,p.dilationWidth];c="same"===r?function(e,t){var n=e.map((function(e,n){return e+(e-1)*(t[n]-1)})).map((function(e){return e-1})),r=n.map((function(e){return Math.floor(e/2)})),a=n.map((function(e,t){return e-r[t]}));return n.map((function(e,t){return[r[t],a[t]]}))}([p.filterHeight,p.filterWidth],h):[[0,0],[0,0]];var d=1===h[0]&&1===h[1],f=function(e,t,n){var r=n.map((function(e){return e[0]})),a=n.map((function(e){return e[1]})),i=e.concat(r,a),o=t.map((function(e,t){return(e-i[t]%e)%e})),s=a.map((function(e,t){return e+o[t]})),u=t.map((function(e,t){return[r[t],s[t]]})),l=t.map((function(e,t){return[0,o[t]]}));return[u,l]}([p.inHeight,p.inWidth],h,c),m=f[0],v=f[1],g=d?r:"valid",y=d?u:iC(u,h,m),b=("avg"===n?function(){return BI(y,t,i,g,o)}:function(){return LT(y,t,i,g,o)})(),x=d?b:KI(b,h,v);return l?PI(x,[x.shape[1],x.shape[2],x.shape[3]]):x}});var sC=Wk({prelu_:function(e,t){var n={x:zk(e,"x","prelu"),alpha:zk(t,"alpha","prelu")};return Ek.runKernel(zb,n)}});var uC=Wk({prod_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=zk(e,"x","prod");"bool"===r.dtype&&(r=XN(r,"int32"));var a={x:r},i={axis:t,keepDims:n};return Ek.runKernel(Pb,a,i)}});var lC=Wk({raggedGather_:function(e,t,n,r){var a={paramsNestedSplits:e.map((function(e,t){return zk(e,"tensors"+t,"raggedGather","int32")})),paramsDenseValues:zk(t,"paramsDenseValues","raggedGather"),indices:zk(n,"indices","raggedGather","int32")},i={outputRaggedRank:r},o=Ek.runKernel(Bb,a,i);return{outputNestedSplits:o.slice(0,o.length-1),outputDenseValues:o[o.length-1]}}});var cC=Wk({raggedRange_:function(e,t,n){var r=zk(e,"starts","raggedRange"),a={starts:r,limits:zk(t,"limits","raggedRange",r.dtype),deltas:zk(n,"deltas","raggedRange",r.dtype)},i=Ek.runKernel(Wb,a);return{rtNestedSplits:i[0],rtDenseValues:i[1]}}});var pC=Wk({raggedTensorToTensor_:function(e,t,n,r,a){var i=zk(e,"shape","raggedTensorToTensor","int32"),o=zk(t,"values","raggedTensorToTensor"),s={shape:i,values:o,defaultValue:zk(n,"defaultValue","raggedTensorToTensor",o.dtype),rowPartitionTensors:r.map((function(e,t){return zk(e,"tensors"+t,"raggedTensorToTensor","int32")}))},u={rowPartitionTypes:a};return Ek.runKernel(Vb,s,u)}});var hC=Wk({rand_:function(e,t,n){Ng(e);var r=Xv(e),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]=t();return Ek.makeTensor(a,e,n)}}),dC=n((function(e){!function(e,t,n){function r(e){var t=this,n=function(){var e=4022871197,t=function(t){t=String(t);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)};return t}();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function i(e,t){var n=new r(e),i=t&&t.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}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.alea=i}(0,e,!1)})),fC=n((function(e){!function(e,t,n){function r(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function i(e,t){var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.xor128=i}(0,e,!1)})),mC=n((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function i(e,t){var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.xorwow=i}(0,e,!1)})),vC=n((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n<t.length;++n)r[7&n]=r[7&n]<<15^t.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],e.x=r,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function i(e,t){null==e&&(e=+new Date);var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&(i.x&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.xorshift7=i}(0,e,!1)})),gC=n((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,o,s=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i<u;++i)t&&(r^=t.charCodeAt((i+32)%t.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&(t&&t.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;e.w=o,e.X=s,e.i=a}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function i(e,t){null==e&&(e=+new Date);var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&(i.X&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.xor4096=i}(0,e,!1)})),yC=n((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function i(e,t){var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.tychei=i}(0,e,!1)})),bC=n((function(e){!function(t,n,r){var a,i=256,o=r.pow(i,6),s=r.pow(2,52),u=2*s,l=255;function c(e,l,c){var v=[],g=f(d((l=1==l?{entropy:!0}:l||{}).entropy?[e,m(n)]:null==e?function(){try{var e;return a&&(e=a.randomBytes)?e=e(i):(e=new Uint8Array(i),(t.crypto||t.msCrypto).getRandomValues(e)),m(e)}catch(e){var r=t.navigator,o=r&&r.plugins;return[+new Date,t,o,t.screen,m(n)]}}():e,3),v),y=new p(v),b=function(){for(var e=y.g(6),t=o,n=0;e<s;)e=(e+n)*i,t*=i,n=y.g(1);for(;e>=u;)e/=2,t/=2,n>>>=1;return(e+n)/t};return b.int32=function(){return 0|y.g(4)},b.quick=function(){return y.g(4)/4294967296},b.double=b,f(m(y.S),n),(l.pass||c||function(e,t,n,a){return a&&(a.S&&h(a,y),e.state=function(){return h(y,{})}),n?(r.random=e,t):e})(b,g,"global"in l?l.global:this==r,l.state)}function p(e){var t,n=e.length,r=this,a=0,o=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a<i;)s[a]=a++;for(a=0;a<i;a++)s[a]=s[o=l&o+e[a%n]+(t=s[a])],s[o]=t;(r.g=function(e){for(var t,n=0,a=r.i,o=r.j,s=r.S;e--;)t=s[a=l&a+1],n=n*i+s[l&(s[a]=s[o=l&o+t])+(s[o]=t)];return r.i=a,r.j=o,n})(i)}function h(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function d(e,t){var n,r=[],a=typeof e;if(t&&"object"==a)for(n in e)try{r.push(d(e[n],t-1))}catch(e){}return r.length?r:"string"==a?e:e+"\0"}function f(e,t){for(var n,r=e+"",a=0;a<r.length;)t[l&a]=l&(n^=19*t[l&a])+r.charCodeAt(a++);return m(t)}function m(e){return String.fromCharCode.apply(0,e)}if(f(r.random(),n),e.exports){e.exports=c;try{a=require("crypto")}catch(e){}}else r.seedrandom=c}("undefined"!=typeof self?self:t,[],Math)}));bC.alea=dC,bC.xor128=fC,bC.xorwow=mC,bC.xorshift7=vC,bC.xor4096=gC,bC.tychei=yC;var xC=bC.alea;function wC(){return 32===Ek.backend.floatPrecision()?.001:.1}function kC(e,t,n){var r=!0;if((Hw(e)||Hw(t))&&(r=!1),Hw(e)&&Hw(t)&&(r=!0),r){var a=e.constructor.name,i=t.constructor.name;if(a!==i)throw new Error("Arrays are of different type. Actual: "+a+". Expected: "+i)}if(Array.isArray(e)&&Array.isArray(t)){var o=Dk(e),s=Dk(t);if(!Yv(o,s))throw new Error("Arrays have different shapes. Actual: ["+o+"]. Expected: ["+s+"]")}var u=Hw(e)?e:qw(e),l=Hw(t)?t:qw(t);if(u.length!==l.length)throw new Error("Arrays have different lengths actual: "+u.length+" vs expected: "+l.length+".\nActual: "+u+".\nExpected: "+l+".");for(var c=0;c<l.length;++c){var p=u[c],h=l[c];if(!n(p,h))throw new Error("Arrays differ: actual["+c+"] = "+p+", expected["+c+"] = "+h+".\nActual: "+u+".\nExpected: "+l+".")}"undefined"!=typeof expect&&expect().nothing()}function NC(e,t,n){if(null==n&&(n=wC()),!IC(e,t,n))throw new Error("Numbers differ: actual === "+e+", expected === "+t);"undefined"!=typeof expect&&expect().nothing()}function IC(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function SC(){return(SC=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.play();case 2:if(!("requestVideoFrameCallback"in t)){e.next=5;break}return e.next=5,new Promise((function(e){t.requestVideoFrameCallback(e)}));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var TC={__proto__:null,TEST_EPSILON_FLOAT16:.1,expectArraysClose:function(e,t,n){return null==n&&(n=wC()),kC(e,t,(function(e,t){return IC(e,t,n)}))},testEpsilon:wC,expectPromiseToFail:function(e,t){e().then((function(){return t.fail()}),(function(){return t()})),"undefined"!=typeof expect&&expect().nothing()},expectArraysEqual:function(e,t){var n="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return cg(e)||cg(e[0])||cg(t)||cg(t[0])?kC(e,n,(function(e,t){return e==t})):kC(e,t,(function(e,t){return IC(e,t,0)}))},expectNumbersClose:NC,expectValuesInRange:function(e,t,n){for(var r=0;r<e.length;r++)if(e[r]<t||e[r]>n)throw new Error("Value out of range:"+e[r]+" low: "+t+", high: "+n)},expectArrayBuffersEqual:function(e,t){var n=new Float32Array(e),r=new Float32Array(t);if(n.length!==r.length)throw new Error("Expected ArrayBuffer to be of length "+r.length+", but it was "+n.length);for(var a=0;a<r.length;a++)if(n[a]!==r[a])throw new Error("Expected ArrayBuffer value at "+a+" to be "+r[a]+" but got "+n[a]+" instead")},encodeStrings:function e(t){for(var n=0;n<t.length;n++){var r=t[n];Array.isArray(r)?e(r):t[n]=Gw(r)}return t},createVideoElement:function(e){var t=document.createElement("video");return"playsInline"in t&&(t.playsInline=!0),t.muted=!0,t.loop=!0,t.style.position="fixed",t.style.left="0px",t.style.top="0px",t.preload="auto",t.appendChild(e),new Promise((function(e){t.addEventListener("loadeddata",(function(n){return e(t)})),t.load()}))},play:function(e){return SC.apply(this,arguments)}},CC=function(){function e(e,t,n,r,a){this.mean=e,this.stdDev=t,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=xC(i.toString())}var t=e.prototype;return t.nextValue=function(){if(!isNaN(this.nextVal)){var e=this.nextVal;return this.nextVal=NaN,e}for(var t,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);t=this.mean+this.stdDev*a*s,n=this.mean+this.stdDev*i*s,this.truncated&&!this.isValidTruncated(t)||(r=!0)}return this.truncated&&!this.isValidTruncated(n)||(this.nextVal=this.convertValue(n)),this.convertValue(t)},t.convertValue=function(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)},t.isValidTruncated=function(e){return e<=this.upper&&e>=this.lower},e}(),EC=function(){function e(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;var a=r||Math.random();this.randu=xC(a.toString()),this.randn=new CC(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}var t=e.prototype;return t.nextValue=function(){for(var e,t,n,r,a,i;;){do{r=this.randn.nextValue(),i=1+this.c*r}while(i<=0);if(i*=i*i,t=1-.331*(e=r*r)*e,n=.5*e+this.d*(1-i+Math.log(i)),(a=this.randu())<t||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)},t.convertValue=function(e){return"float32"===this.dtype?e:Math.round(e)},e}(),AC=function(){function e(e,t,n,r){var a=this;if(void 0===e&&(e=0),void 0===t&&(t=1),this.canReturnFloat=function(){return null==a.dtype||"float32"===a.dtype},this.min=e,this.range=t-e,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 "+e+" - "+t+" <= 1 and dtype is not float");this.random=xC(r)}var t=e.prototype;return t.convertValue=function(e){return this.canReturnFloat()?e:Math.round(e)},t.nextValue=function(){return this.convertValue(this.min+this.range*this.random())},e}();var RC=Wk({randomGamma_:function(e,t,n,r,a){if(void 0===n&&(n=1),void 0===r&&(r="float32"),Ng(e),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type "+r);for(var i=new EC(t,n,r,a),o=KN(e,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});var _C=Wk({randomNormal_:function(e,t,n,r,a){if(void 0===t&&(t=0),void 0===n&&(n=1),Ng(e),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var i=new CC(t,n,r,!1,a),o=KN(e,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});var FC=Wk({randomStandardNormal_:function(e,t,n){if(null!=t&&"bool"===t)throw new Error("Unsupported data type "+t);return _C(e,0,1,t,n)}});var OC=Wk({randomUniform_:function(e,t,n,r,a){void 0===t&&(t=0),void 0===n&&(n=1),void 0===r&&(r="float32"),Ng(e);for(var i=KN(e,r),o=new AC(t,n,null,a),s=0;s<i.values.length;s++)i.values[s]=o.nextValue();return i.toTensor()}});function DC(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r="float32"),0===n)throw new Error("Cannot have a step of zero");var a={start:e,stop:t,step:n,dtype:r};return Ek.runKernel(Ub,{},a)}var MC=Wk({real_:function(e){var t={input:zk(e,"input","real")};return Ek.runKernel(Gb,t)}});var LC=Wk({reciprocal_:function(e){var t={x:zk(e,"x","reciprocal")};return Ek.runKernel(jb,t)}});var zC=Wk({relu_:function(e){var t={x:zk(e,"x","relu")};return Ek.runKernel(Hb,t)}});var PC=Wk({relu6_:function(e){var t={x:zk(e,"x","relu6")};return Ek.runKernel(Zb,t)}});var BC=Wk({reverse_:function(e,t){var n={x:zk(e,"x","reverse")},r={dims:t};return Ek.runKernel(Qb,n,r)}});var WC=Wk({reverse1d_:function(e){var t=zk(e,"x","reverse");return Hv(1===t.rank,(function(){return"Error in reverse1D: x must be rank 1 but got rank "+t.rank+"."})),BC(t,0)}});var VC=Wk({reverse2d_:function(e,t){var n=zk(e,"x","reverse");return Hv(2===n.rank,(function(){return"Error in reverse2D: x must be rank 2 but got rank "+n.rank+"."})),BC(n,t)}});var UC=Wk({reverse3d_:function(e,t){var n=zk(e,"x","reverse");return Hv(3===n.rank,(function(){return"Error in reverse3D: x must be rank 3 but got rank "+n.rank+"."})),BC(n,t)}});var GC=Wk({reverse4d_:function(e,t){var n=zk(e,"x","reverse");return Hv(4===n.rank,(function(){return"Error in reverse4D: x must be rank 4 but got rank "+n.rank+"."})),BC(n,t)}});var jC=Wk({round_:function(e){var t={x:zk(e,"x","round")};return Ek.runKernel($b,t)}});var HC=Wk({rsqrt_:function(e){var t={x:zk(e,"x","rsqrt","float32")};return Ek.runKernel(ex,t)}});var qC=Wk({selu_:function(e){var t={x:zk(e,"x","selu")};return Ek.runKernel(ix,t)}});var KC=Wk({separableConv2d_:function(e,t,n,r,a,i,o){void 0===i&&(i=[1,1]),void 0===o&&(o="NHWC");var s=zk(e,"x","separableConv2d"),u=zk(t,"depthwiseFilter","separableConv2d"),l=zk(n,"pointwiseFilter","separableConv2d"),c=s,p=!1;if(3===s.rank&&(p=!0,c=PI(s,[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");Hv(4===c.rank,(function(){return"Error in separableConv2d: input must be rank 4, but got rank "+c.rank+"."})),Hv(4===u.rank,(function(){return"Error in separableConv2d: depthwise filter must be rank 4, but got rank "+u.rank+"."})),Hv(4===l.rank,(function(){return"Error in separableConv2d: pointwise filter must be rank 4, but got rank "+u.rank+"."})),Hv(1===l.shape[0],(function(){return"Error in separableConv2d: the first dimension of pointwise filter must be 1, but got "+l.shape[0]+"."})),Hv(1===l.shape[1],(function(){return"Error in separableConv2d: the second dimension of pointwise filter must be 1, but got "+l.shape[1]+"."}));var h=u.shape[2],d=u.shape[3];Hv(l.shape[2]===h*d,(function(){return"Error in separableConv2d: the third dimension of pointwise filter must be "+h*d+", but got "+l.shape[2]+"."}));var f=wS(c,u,r,a,o,i),m=uS(f,l,1,"valid",o);return p?PI(m,[m.shape[1],m.shape[2],m.shape[3]]):m}});function XC(){return XC=Iv(kv().mark((function e(t,n){var r,a,i,o,s,u,l,c,p,h,d;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=zk(t,"x","setdiff1d"),a=zk(n,"y","setdiff1d"),Hv(r.dtype===a.dtype,(function(){return"x and y should have the same dtype, but got x ("+r.dtype+") and y ("+a.dtype+")."})),Hv(1===r.rank,(function(){return"x should be 1D tensor, but got x ("+r.shape+")."})),Hv(1===a.rank,(function(){return"y should be 1D tensor, but got y ("+a.shape+")."})),e.next=7,r.data();case 7:return i=e.sent,e.next=10,a.data();case 10:for(o=e.sent,s=new Set(o),u=0,l=0;l<i.length;l++)s.has(i[l])||u++;for(c=new tk([u],r.dtype),p=new tk([u],"int32"),h=0,d=0;h<i.length;h++)s.has(i[h])||(c.values[d]=i[h],p.values[d]=h,d++);return e.abrupt("return",[c.toTensor(),p.toTensor()]);case 18:case"end":return e.stop()}}),e)}))),XC.apply(this,arguments)}var YC=function(e,t){return XC.apply(this,arguments)};var JC=Wk({sign_:function(e){var t={x:zk(e,"x","sign")};return Ek.runKernel(lx,t)}});var ZC=Wk({sin_:function(e){var t={x:zk(e,"x","sin","float32")};return Ek.runKernel(sx,t)}});var QC=Wk({sinh_:function(e){var t={x:zk(e,"x","sinh")};return Ek.runKernel(ux,t)}});var $C=Wk({slice1d_:function(e,t,n){var r=zk(e,"x","slice1d");return Hv(1===r.rank,(function(){return"slice1d expects a rank-1 tensor, but got a rank-"+r.rank+" tensor"})),jI(r,[t],[n])}});var eE=Wk({slice2d_:function(e,t,n){var r=zk(e,"x","slice2d");return Hv(2===r.rank,(function(){return"slice2d expects a rank-2 tensor, but got a rank-"+r.rank+" tensor"})),jI(r,t,n)}});var tE=Wk({slice3d_:function(e,t,n){var r=zk(e,"x","slice3d");return Hv(3===r.rank,(function(){return"slice3d expects a rank-3 tensor, but got a rank-"+r.rank+" tensor"})),jI(r,t,n)}});var nE=Wk({slice4d_:function(e,t,n){var r=zk(e,"x","slice4d");return Hv(4===r.rank,(function(){return"slice4d expects a rank-4 tensor, but got a rank-"+r.rank+" tensor"})),jI(r,t,n)}});var rE=Wk({softmax_:function(e,t){void 0===t&&(t=-1);var n=zk(e,"logits","softmax","float32");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and dim was "+t);var r={logits:n},a={dim:t};return Ek.runKernel(vx,r,a)}});var aE=Wk({fft_:function(e){Hv("complex64"===e.dtype,(function(){return"The dtype for tf.spectral.fft() must be complex64 but got "+e.dtype+"."}));var t={input:e};return Ek.runKernel(By,t)}});var iE=Wk({ifft_:function(e){Hv("complex64"===e.dtype,(function(){return"The dtype for tf.spectral.ifft() must be complex64 but got "+e.dtype+"."}));var t={input:e};return Ek.runKernel(Jy,t)}});var oE=Wk({irfft_:function(e){var t,n=e.shape[e.shape.length-1],r=e.size/n;if(n<=2){var a=PI(e,[r,n]);t=iE(a)}else{var i=[r,2*(n-1)],o=PI(MC(e),[r,n]),s=PI(lT(e),[r,n]),u=BC(jI(o,[0,1],[r,n-2]),1),l=lI(BC(jI(s,[0,1],[r,n-2]),1),KS(-1)),c=VI([o,u],1),p=VI([s,l],1),h=PI(Vk(c,p),[i[0],i[1]]);t=iE(h)}if(t=MC(t),3===e.rank&&0!==e.shape[0]){var d=t,f=e.shape[0];t=PI(t,[f,t.shape[0]/f,t.shape[1]]),d.dispose()}return t}});var sE=Wk({split_:function(e,t,n){void 0===n&&(n=0);var r={x:zk(e,"x","split")},a={numOrSizeSplits:t,axis:n};return Ek.runKernel(mx,r,a)}});var uE=Wk({rfft_:function(e,t){Hv("float32"===e.dtype,(function(){return"The dtype for rfft() must be real value but got "+e.dtype}));var n,r=e.shape[e.shape.length-1],a=e.size/r;if(null!=t&&t<r){var i=e.shape.map((function(e){return 0})),o=e.shape.map((function(e){return e}));o[e.shape.length-1]=t,n=jI(e,i,o),r=t}else if(null!=t&&t>r){var s=e.shape.map((function(e){return e}));s[e.shape.length-1]=t-r,n=VI([e,VT(s)],e.shape.length-1),r=t}else n=e;var u=RS(n),l=PI(Vk(n,u),[a,r]),c=aE(l),p=Math.floor(r/2)+1,h=MC(c),d=lT(c),f=sE(h,[p,r-p],h.shape.length-1),m=sE(d,[p,r-p],d.shape.length-1),v=n.shape.slice();return v[n.shape.length-1]=p,PI(Vk(f[0],m[0]),v)}});var lE=Wk({squaredDifference_:function(e,t){var n=zk(e,"a","squaredDifference"),r=zk(t,"b","squaredDifference"),a=gk(n,r);n=a[0],r=a[1],TS(n.shape,r.shape);var i={a:n,b:r};return Ek.runKernel(kx,i,{})}});var cE=Wk({squeeze_:function(e,t){var n=zk(e,"x","squeeze","string_or_numeric");return PI(n,ng(n.shape,t).newShape)}});var pE=Wk({stack_:function(e,t){void 0===t&&(t=0);var n=Pk(e,"tensors","stack","string_or_numeric");Hv(n.length>=1,(function(){return"Pass at least one tensor to tf.stack"})),n.length>0&&Hv(t<=n[0].rank,(function(){return"Axis must be <= rank of the tensor"}));var r=n,a={axis:t};return Ek.runKernel(Db,r,a)}});var hE=Wk({step_:function(e,t){void 0===t&&(t=0);var n={x:zk(e,"x","step")},r={alpha:t};return Ek.runKernel(Wx,n,r)}});var dE=Wk({stridedSlice_:function(e,t,n,r,a,i,o,s,u){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);var l={x:zk(e,"x","stridedSlice","string_or_numeric")},c={begin:t,end:n,strides:r,beginMask:a,endMask:i,ellipsisMask:o,newAxisMask:s,shrinkAxisMask:u};return Ek.runKernel(Sx,l,c)}});var fE=Wk({tan_:function(e){var t={x:zk(e,"x","tan","float32")};return Ek.runKernel(Rx,t)}});function mE(e,t){Kv(e);var n=Dk(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Uk(e,null,n,t)}function vE(e,t,n){if(Kv(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");var r=Dk(e,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==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Uk(e,t,r,n)}function gE(e,t,n){if(Kv(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");var r=Dk(e,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==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Uk(e,t,r,n)}function yE(e,t,n){if(Kv(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");var r=Dk(e,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==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Uk(e,t,r,n)}function bE(e,t,n){if(Kv(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");var r=Dk(e,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==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Uk(e,t,r,n)}function xE(e,t,n){if(Kv(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");var r=Dk(e,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==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return Uk(e,t=t||r,r,n)}function wE(e,t,n){var r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,i="Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: "+n.shape+", indices.shape: "+t.shape+", shape: "+e+", sliceDim: "+r+", and batchDim: "+a+".";if(n.rank<a)throw new Error(i+" update.rank < "+a+". ");if(e.length<r+(n.rank-a))throw new Error(i+" Output shape length < "+(r+(n.rank-a)));if(n.rank!==a+e.length-r)throw new Error(i+" update.rank != "+(a+e.length-r));for(var o=0;o<a;++o)if(n.shape[o]!==t.shape[o])throw new Error(i+" updates.shape["+o+"] ("+n.shape[o]+") != indices.shape["+o+"] ("+t.shape[o]+").");for(var s=0;s<n.rank-a;++s)if(n.shape[s+a]!==e[s+r])throw new Error(i+" updates.shape["+(s+a)+"] ("+n.shape[s+a]+") != shape["+(s+a)+"] ("+e[s+a]+")")}function kE(e,t,n){if(t.rank<1)throw new Error("tf.scatterND() expects the indices to be rank 1 or higher, but the rank was "+t.rank+".");if(e.rank<1)throw new Error("tf.scatterND() expects the updates to be rank 1 or higher, but the rank was "+e.rank+".");if("int32"!==t.dtype)throw new Error("The dtype of 'indices' should be int32, but got dtype: "+t.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===t.size)throw new Error("Indices specified for empty output. indices shape: "+t.shape);if(0===e.size)throw new Error("Updates specified for empty output. updates shape: "+e.shape)}wE(n,t,e)}function NE(e,t,n){for(var r=t.shape.length,a=r>1?t.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:Xv(t.shape)/u,sliceSize:o,strides:[].concat(vg(n.slice(0,a)),[1]),outputSize:Xv(n)}}var IE={__proto__:null,validateUpdateShape:wE,validateInput:kE,calculateShapes:NE};var SE=Wk({tensorScatterUpdate_:function(e,t,n){var r=zk(e,"tensor","tensorScatterupdate"),a=zk(t,"indices","tensorScatterupdate","int32"),i=zk(n,"updates","tensorScatterupdate");if(kE(i,a,r.shape),r.dtype!==i.dtype)throw new Error("tensor and updates must have the same dtype, instead they are "+r.dtype+" and "+i.dtype+".");var o={tensor:r,indices:a,updates:i};return Ek.runKernel(nx,o,{})}});var TE=Wk({topk_:function(e,t,n){void 0===t&&(t=1),void 0===n&&(n=!0);var r=zk(e,"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(t<0)throw new Error("'k' passed to topk() must be >= 0 but got "+t);if(t>a)throw new Error("'k' passed to topk() must be <= the last dimension ("+a+") but got "+t);var i={x:r},o={k:t,sorted:n},s=Ek.runKernel(Ox,i,o);return{values:s[0],indices:s[1]}}});var CE=Wk({truncatedNormal_:function(e,t,n,r,a){if(void 0===t&&(t=0),void 0===n&&(n=1),Ng(e),null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");for(var i=new CC(t,n,r,!0,a),o=KN(e,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});var EE=Wk({unique_:function(e,t){void 0===t&&(t=0);var n=zk(e,"x","unique","string_or_numeric");Hv(n.rank>0,(function(){return"The input tensor must be at least 1D"}));var r={x:n},a={axis:t},i=Ek.runKernel(Lx,r,a);return{values:i[0],indices:i[1]}}});var AE=Wk({unsortedSegmentSum_:function(e,t,n){var r=zk(e,"x","unsortedSegmentSum"),a=zk(t,"segmentIds","unsortedSegmentSum","int32");Hv(Jv(n),(function(){return"numSegments must be of dtype int"}));var i={x:r,segmentIds:a},o={numSegments:n};return Ek.runKernel(Px,i,o)}});var RE=Wk({unstack_:function(e,t){void 0===t&&(t=0);var n=zk(e,"x","unstack","string_or_numeric");Hv(t>=-n.shape.length&&t<n.shape.length,(function(){return"Axis = "+t+" is not in [-"+n.shape.length+", "+n.shape.length+")"}));var r={value:n},a={axis:t};return Ek.runKernel(zx,r,a)}});function _E(e,t){return DT(e,t,"right")}function FE(e,t,n,r){return void 0===t&&(t=!0),Ek.makeVariable(e,t,n,r)}function OE(e,t){for(var n=[],r=0;r<t.length;r++)t[r]&&n.push(r);for(var a=KN(e,"int32"),i=KN([n.length,e.length],"int32"),o=0;o<n.length;o++){var s=a.indexToLoc(n[o]),u=o*e.length;i.values.set(s,u)}return i.toTensor()}function DE(){return(DE=Iv(kv().mark((function e(t){var n,r,a;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=zk(t,"condition","whereAsync","bool"),e.next=3,n.data();case 3:return r=e.sent,a=OE(n.shape,r),t!==n&&n.dispose(),e.abrupt("return",a);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ME=function(e){return DE.apply(this,arguments)};function LE(){return LE=Iv(kv().mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,d,f,m,v;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(a=zk(t,"tensor","boolMask"),i=zk(n,"mask","boolMask","bool"),o=null==r?0:r,s=i.rank,u=a.shape,Hv(s>0,(function(){return"mask cannot be scalar"})),qv(u.slice(o,o+s),i.shape,"mask's shape must match the first K dimensions of tensor's shape,"),l=1,c=o;c<o+s;c++)l*=u[c];return p=u.slice(0,o).concat([l],u.slice(o+s)),h=PI(a,p),d=PI(i,[-1]),e.next=14,ME(d);case 14:return f=e.sent,m=cE(f,[1]),v=oT(h,m,o),t!==a&&a.dispose(),n!==i&&i.dispose(),m.dispose(),h.dispose(),d.dispose(),f.dispose(),e.abrupt("return",v);case 24:case"end":return e.stop()}}),e)}))),LE.apply(this,arguments)}var zE=function(e,t,n){return LE.apply(this,arguments)};var PE=Wk({transpose_:function(e,t,n){var r=zk(e,"x","transpose");if(null==t&&(t=r.shape.map((function(e,t){return t})).reverse()),Hv(r.rank===t.length,(function(){return"Error in transpose: rank of input "+r.rank+" must match length of perm "+t+"."})),t.forEach((function(e){Hv(e>=0&&e<r.rank,(function(){return"All entries in 'perm' must be between 0 and "+(r.rank-1)+" but got "+t}))})),r.rank<=1)return r.clone();var a={x:r},i={perm:t};return"complex64"===r.dtype?eI((function(){var e=MC(r),t=lT(r);return e=Ek.runKernel(Mx,{x:e},i),t=Ek.runKernel(Mx,{x:t},i),n&&(t=NT(t)),Vk(e,t)})):Ek.runKernel(Mx,a,i)}});var BE=Wk({movingAverage_:function(e,t,n,r,a){void 0===a&&(a=!0);var i=zk(e,"v","movingAverage"),o=zk(t,"x","movingAverage"),s=zk(n,"decay","movingAverage");yk(i,o),Hv(Yv(i.shape,o.shape),(function(){return"Shape mismatch in v and x"}));var u=KS(1),l=TT(u,s),c=lI(TT(o,i),l);if(a){Hv(null!=r,(function(){return"When using zeroDebias: true, step is required."}));var p=zk(r,"step","movingAverage");c=uI(c,TT(u,qS(s,p)))}return oI(i,c)}});var WE=Wk({scatterND_:function(e,t,n){Ng(n);var r=zk(e,"indices","scatterND","int32"),a=zk(t,"updates","scatterND");kE(a,r,n);var i={indices:r,updates:a},o={shape:n};return Ek.runKernel(tx,i,o)}});var VE=Wk({sparseToDense_:function(e,t,n,r){void 0===r&&(r=0),Ng(n);var a=zk(e,"sparseIndices","sparseToDense","int32"),i=zk(t,"sparseValues","sparseToDense","string_or_numeric"),o=zk(r,"defaultValue","sparseToDense",i.dtype);!function(e,t,n,r){if("int32"!==e.dtype)throw new Error("tf.sparseToDense() expects the indices to be int32 type, but the dtype was "+e.dtype+".");if(e.rank>2)throw new Error("sparseIndices should be a scalar, vector, or matrix, but got shape "+e.shape+".");var a=e.rank>0?e.shape[0]:1,i=e.rank>1?e.shape[1]:1;if(n.length!==i)throw new Error("outputShape has incorrect number of elements:, "+n.length+", should be: "+i+".");var o=t.size;if(0!==t.rank&&(1!==t.rank||o!==a))throw new Error("sparseValues has incorrect shape "+t.shape+", should be [] or ["+a+"]");if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,i,n,o);var s={sparseIndices:a,sparseValues:i,defaultValue:o},u={outputShape:n};return Ek.runKernel(wx,s,u)}});var UE=Wk({gatherND_:function(e,t){var n=zk(t,"indices","gatherND","int32"),r={params:zk(e,"x","gatherND","string_or_numeric"),indices:n};return Ek.runKernel(qy,r)}});var GE=Wk({dropout_:function(e,t,n,r){var a=zk(e,"x","dropout");if(Hv("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."})),Hv(t>=0&&t<1,(function(){return"rate must be a float in the range [0, 1), but got "+t+"."})),0===t)return e instanceof ak?a.clone():a;var i=function(e,t){if(null==t)return e.shape.slice();if(Yv(e.shape,t))return t;if(e.shape.length===t.length){for(var n=[],r=0;r<e.shape.length;r++)null==t[r]&&null!=e.shape[r]?n.push(e.shape[r]):n.push(t[r]);return n}return t}(a,n),o=1-t,s=uI(iT(oI(OC(i,0,1,"float32",r),o)),o);return lI(a,s)}});function jE(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function HE(e,t,n){for(var r=1-e%2,a=new Float32Array(e),i=0;i<e;++i){var o=2*Math.PI*i/(e+r-1);a[i]=t-n*Math.cos(o)}return mE(a,"float32")}function qE(){return qE=Iv(kv().mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,d,f,m,v,g;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r=1),a=zk(t,"predictions","inTopK"),i=zk(n,"targets","inTopK"),Hv(a.rank>1,(function(){return"inTopK() expects the predictions to be of rank 2 or higher, but got "+a.rank})),Hv(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})),qv(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],Hv(r>0&&r<=o,(function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last dimension ("+o+"), but got "+r})),e.next=10,a.data();case 10:return s=e.sent,e.next=13,i.data();case 13:u=e.sent,l=s.length/o,c=o,p=rg("bool",l),h=0;case 17:if(!(h<l)){e.next=35;break}for(d=h*c,f=s.subarray(d,d+c),m=[],v=0;v<f.length;v++)m.push({value:f[v],index:v});m.sort((function(e,t){return t.value-e.value})),p[h]=0,g=0;case 25:if(!(g<r)){e.next=32;break}if(m[g].index!==u[h]){e.next=29;break}return p[h]=1,e.abrupt("break",32);case 29:g++,e.next=25;break;case 32:h++,e.next=17;break;case 35:return t!==a&&a.dispose(),n!==i&&i.dispose(),e.abrupt("return",Gk(p,i.shape,"bool"));case 38:case"end":return e.stop()}}),e)}))),qE.apply(this,arguments)}var KE=function(e,t,n){return qE.apply(this,arguments)};var XE=Wk({conv2DBackpropFilter_:function(e,t,n,r,a,i,o){void 0===i&&(i="NHWC");var s=e;3===e.rank&&(s=PI(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var u=t;3===u.rank&&(u=PI(t,[1,t.shape[0],t.shape[1],t.shape[2]])),Hv(4===s.rank,(function(){return"Error in conv2dDerFilter: input must be rank 4, but got shape "+s.shape+"."})),Hv(4===u.rank,(function(){return"Error in conv2dDerFilter: dy must be rank 4, but got shape "+u.shape+"."})),Hv(4===n.length,(function(){return"Error in conv2dDerFilter: filterShape must be length 4, but got "+n+"."}));var l="NHWC"===i?s.shape[3]:s.shape[1],c="NHWC"===i?u.shape[3]:u.shape[1];Hv(l===n[2],(function(){return"Error in conv2dDerFilter: depth of input "+l+") must match input depth in filter ("+n[2]+"."})),Hv(c===n[3],(function(){return"Error in conv2dDerFilter: depth of dy ("+c+") must match output depth for filter ("+n[3]+")."})),zI("conv2dDerFilter",a,o);var p={x:s,dy:u},h={strides:r,pad:a,dataFormat:i,dimRoundingMode:o,filterShape:n};return Ek.runKernel(py,p,h)}});function YE(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return lI(e,hE(t));throw new Error("Cannot compute gradient for fused activation "+n+".")}function JE(e,t){var n=t,r=SS(e.shape,t.shape);return r.length>0&&(n=JS(n,r)),PI(n,e.shape)}function ZE(e,t,n,r){if("linear"===t)return e;if("relu"===t)return zC(e);if("elu"===t)return DS(e);if("relu6"===t)return PC(e);if("prelu"===t)return sC(e,n);if("leakyrelu"===t)return dT(e,r);if("sigmoid"===t)return GI(e);throw new Error("Unknown fused activation "+t+".")}var QE=function(e,t){return!(e>0)||"linear"===t};var $E=Wk({fusedConv2d_:function(e){var t=e.x,n=e.filter,r=e.strides,a=e.pad,i=e.dataFormat,o=void 0===i?"NHWC":i,s=e.dilations,u=void 0===s?[1,1]:s,l=e.dimRoundingMode,c=e.bias,p=e.activation,h=void 0===p?"linear":p,d=e.preluActivationWeights,f=e.leakyreluAlpha;if(h=h||"linear",!1===QE(Ek.state.gradientDepth,h)){Hv("NHWC"===o,(function(){return"Error in fused conv2d: got dataFormat of "+o+" but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear."}));var m=uS(t,n,r,a,o,u,l);return null!=c&&(m=oI(m,c)),ZE(m,h,d,f)}var v=zk(t,"x","conv2d","float32"),g=zk(n,"filter","conv2d","float32"),y=v,b=!1;3===v.rank&&(b=!0,y=PI(v,[1,v.shape[0],v.shape[1],v.shape[2]])),Hv(4===y.rank,(function(){return"Error in fused conv2d: input must be rank 4, but got rank "+y.rank+"."})),Hv(4===g.rank,(function(){return"Error in fused conv2d: filter must be rank 4, but got rank "+g.rank+"."})),zI("fused conv2d",a,l);var x="NHWC"===o?y.shape[3]:y.shape[1];Hv(g.shape[2]===x,(function(){return"Error in conv2d: depth of input ("+x+") must match input depth for filter "+g.shape[2]+"."})),Hv(DI(r,u),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"}));var w,k,N=TI(y.shape,g.shape,r,u,a,l);if(null!=c){var I=gk(w=zk(c,"bias","fused conv2d"),v);w=I[0],"NHWC"===o?TS(N.outShape,w.shape):(Hv(w.shape.length<=1,(function(){return"Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-"+w.shape.length+"."})),Hv(0===w.shape.length||w.shape[0]===N.outChannels||1===w.shape[0],(function(){return"Error in fused conv2d: bias shape ("+w.shape+") is not compatible with the number of output channels ("+N.outChannels+")"})))}if(null!=d){var S=d.shape;if(Hv(S.length<=1||3===S.length,(function(){return"Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-"+S.length+"."})),1===S.length)Hv(1===S[0]||S[0]===N.outChannels,(function(){return"Error in fused conv2d: PReLU activation weights ("+S+") is not compatible with the number of output channels ("+N.outChannels+")."}));else if(3===S.length)try{TS(S,N.outShape)}catch(e){var T="Error in fused conv2d: PReLU activation weights ("+S+") is not compatible with the output shape of the conv2d ("+N.outShape+").";throw Error(T)}k=zk(d,"prelu weights","fused conv2d")}var C=function(e,t){Hv("NHWC"===o,(function(){return"Error in gradient of fused conv2D: got dataFormat of "+o+" but only NHWC is currently supported."}));var n=t[0],i=t[1],s=t[2],l=t[3],c=YE(e,s,h);Hv(OI(u),(function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+u+"'"}));var p=[cS(i.shape,c,n,r,a),XE(i,c,n.shape,r,a)];if(null!=l){var d=JE(l,c);p.push(d)}return p},E={x:y,filter:g,bias:w,preluActivationWeights:k},A={strides:r,pad:a,dataFormat:o,dilations:u,dimRoundingMode:l,activation:h,leakyreluAlpha:f};if(null==c){var R=wT((function(e,t,n){var r=Ek.runKernel(jx,E,A);return n([t,e,r]),b&&(r=PI(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:C}}));return R(y,g)}var _=wT((function(e,t,n,r){var a=Ek.runKernel(jx,E,A);return r([t,e,a,n]),b&&(a=PI(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:C}}));return _(y,g,w)}});var eA=Wk({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,i,o){void 0===i&&(i=[1,1]);var s=e;3===e.rank&&(s=PI(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var u=t;3===u.rank&&(u=PI(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var l={x:s,dy:u},c={strides:r,pad:a,dimRoundingMode:o,dilations:i,filterShape:n};return Ek.runKernel(Iy,l,c)}});var tA=Wk({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,i,o){void 0===i&&(i=[1,1]);var s=t,u=!1;3===t.rank&&(u=!0,s=PI(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var l={dy:s,filter:n},c={strides:r,pad:a,dimRoundingMode:o,dilations:i,inputShape:e},p=Ek.runKernel(Sy,l,c);return u?PI(p,[p.shape[1],p.shape[2],p.shape[3]]):p}});var nA=Wk({fusedDepthwiseConv2d_:function(e){var t=e.x,n=e.filter,r=e.strides,a=e.pad,i=e.dataFormat,o=void 0===i?"NHWC":i,s=e.dilations,u=void 0===s?[1,1]:s,l=e.dimRoundingMode,c=e.bias,p=e.activation,h=void 0===p?"linear":p,d=e.preluActivationWeights,f=e.leakyreluAlpha;if(!1===QE(Ek.state.gradientDepth,h)){var m=wS(t,n,r,a,o,u,l);return null!=c&&(m=oI(m,c)),ZE(m,h,d,f)}var v=zk(t,"x","depthwiseConv2d","float32"),g=zk(n,"filter","depthwiseConv2d","float32"),y=v,b=!1;3===v.rank&&(b=!0,y=PI(v,[1,v.shape[0],v.shape[1],v.shape[2]])),Hv(4===y.rank,(function(){return"Error in fused depthwiseConv2d: input must be rank 4, but got rank "+y.rank+"."})),Hv(4===g.rank,(function(){return"Error in fused depthwiseConv2d: filter must be rank 4, but got rank "+g.rank+"."})),Hv(y.shape[3]===g.shape[2],(function(){return"Error in fused depthwiseConv2d: number of input channels ("+y.shape[3]+") must match the inChannels dimension in filter "+g.shape[2]+"."})),null==u&&(u=[1,1]),Hv(DI(r,u),(function(){return"Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),zI("fused depthwiseConv2d",a,l);var x,w,k=TI(y.shape,g.shape,r,u,a,l,!0);if(null!=c){var N=gk(x=zk(c,"bias","fused conv2d"),v);x=N[0],TS(k.outShape,x.shape)}null!=d&&(w=zk(d,"prelu weights","fused depthwiseConv2d"));var I=function(e,t){Hv(OI(u),(function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+u+"'"}));var n=t[0],i=t[1],o=t[2],s=t[3],c=YE(e,o,h),p=tA(i.shape,c,n,r,a,u,l),d=eA(i,c,n.shape,r,a,u,l);return null!=s?[p,d,JE(x,c)]:[p,d]},S={x:y,filter:g,bias:x,preluActivationWeights:w},T={strides:r,pad:a,dataFormat:o,dilations:u,dimRoundingMode:l,activation:h,leakyreluAlpha:f};if(null==c){var C=wT((function(e,t,n){var r=Ek.runKernel(Hx,S,T);return n([t,e,r]),b&&(r=PI(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:I}}));return C(y,g)}var E=wT((function(e,t,n,r){var a=Ek.runKernel(Hx,S,T);return r([t,e,a,n]),b&&(a=PI(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:I}}));return E(y,g,x)}});var rA=Wk({fusedMatMul_:function(e){var t=e.a,n=e.b,r=e.transposeA,a=void 0!==r&&r,i=e.transposeB,o=void 0!==i&&i,s=e.bias,u=e.activation,l=void 0===u?"linear":u,c=e.preluActivationWeights,p=e.leakyreluAlpha,h=void 0===p?.2:p;if(!1===QE(Ek.state.gradientDepth,l)){var d=UI(t,n,a,o);return null!=s&&(d=oI(d,s)),ZE(d,l,c,h)}var f=zk(t,"a","fused matMul"),m=zk(n,"b","fused matMul"),v=gk(f,m);f=v[0],m=v[1];var g=a?f.shape[f.rank-2]:f.shape[f.rank-1],y=o?m.shape[m.rank-1]:m.shape[m.rank-2],b=a?f.shape[f.rank-1]:f.shape[f.rank-2],x=o?m.shape[m.rank-2]:m.shape[m.rank-1],w=f.shape.slice(0,-2),k=m.shape.slice(0,-2),N=Xv(w),I=Xv(k);Hv(g===y,(function(){return"Error in fused matMul: inner shapes ("+g+") and ("+y+") of Tensors with shapes "+f.shape+" and "+m.shape+" and transposeA="+a+" and transposeB="+o+" must match."}));var S,T,C=TS(f.shape.slice(0,-2),m.shape.slice(0,-2)).concat([b,x]),E=PI(f,a?[N,g,b]:[N,b,g]),A=PI(m,o?[I,x,y]:[I,y,x]);null!=s&&(S=gk(S=zk(s,"bias","fused matMul"),f)[0],TS(C,S.shape)),null!=c&&(T=zk(c,"prelu weights","fused matMul"));var R=function(e,t){var n,r,i=t[0],u=t[1],c=t[2],p=t[3],h=YE(PI(e,c.shape),c,l);return a||o?!a&&o?(n=UI(h,u,!1,!1),r=UI(h,i,!0,!1)):a&&!o?(n=UI(u,h,!1,!0),r=UI(i,h,!1,!1)):(n=UI(u,h,!0,!0),r=UI(h,i,!0,!0)):(n=UI(h,u,!1,!0),r=UI(i,h,!0,!1)),null!=s?[n,r,JE(p,h)]:[n,r]},_={a:E,b:A,bias:S,preluActivationWeights:T},F={transposeA:a,transposeB:o,activation:l,leakyreluAlpha:h};if(null==s){var O=wT((function(e,t,n){var r=Ek.runKernel(Gx,_,F);return n([e,t,r]),{value:PI(r,C),gradFunc:R}}));return O(E,A)}var D=wT((function(e,t,n,r){var a=Ek.runKernel(Gx,_,F);return r([e,t,a,n]),{value:PI(a,C),gradFunc:R}}));return D(E,A,S)}}),aA={__proto__:null,conv2d:$E,depthwiseConv2d:nA,matMul:rA};var iA=Wk({hammingWindow_:function(e){return HE(e,.54,.46)}});var oA=Wk({hannWindow_:function(e){return HE(e,.5,.5)}});var sA=Wk({frame_:function(e,t,n,r,a){void 0===r&&(r=!1),void 0===a&&(a=0);for(var i=0,o=[];i+t<=e.size;)o.push(jI(e,i,t)),i+=n;if(r)for(;i<e.size;){var s=i+t-e.size,u=VI([jI(e,i,t-s),nS([s],a)]);o.push(u),i+=n}return 0===o.length?vE([],[0,t]):PI(VI(o),[o.length,t])}});var uA=Wk({stft_:function(e,t,n,r,a){void 0===a&&(a=oA),null==r&&(r=jE(t));var i=sA(e,t,n),o=lI(i,a(t));return uE(o,r)}});var lA=Wk({cropAndResize_:function(e,t,n,r,a,i){void 0===a&&(a="bilinear"),void 0===i&&(i=0);var o=zk(e,"image","cropAndResize"),s=zk(t,"boxes","cropAndResize","float32"),u=zk(n,"boxInd","cropAndResize","int32"),l=s.shape[0];Hv(4===o.rank,(function(){return"Error in cropAndResize: image must be rank 4,but got rank "+o.rank+"."})),Hv(2===s.rank&&4===s.shape[1],(function(){return"Error in cropAndResize: boxes must be have size ["+l+",4] but had shape "+s.shape+"."})),Hv(1===u.rank&&u.shape[0]===l,(function(){return"Error in cropAndResize: boxInd must be have size ["+l+"] but had shape "+s.shape+"."})),Hv(2===r.length,(function(){return"Error in cropAndResize: cropSize must be of length 2, but got length "+r.length+"."})),Hv(r[0]>=1&&r[1]>=1,(function(){return"cropSize must be atleast [1,1], but was "+r})),Hv("bilinear"===a||"nearest"===a,(function(){return"method must be bilinear or nearest, but was "+a}));var c={image:o,boxes:s,boxInd:u},p={method:a,extrapolationValue:i,cropSize:r};return Ek.runKernel(xy,c,p)}});var cA=Wk({flipLeftRight_:function(e){var t=zk(e,"image","flipLeftRight","float32");Hv(4===t.rank,(function(){return"Error in flipLeftRight: image must be rank 4,but got rank "+t.rank+"."}));var n={image:t};return Ek.runKernel(Vy,n,{})}});var pA=Wk({grayscaleToRGB_:function(e){var t=zk(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];Hv(t.rank>=2,(function(){return"Error in grayscaleToRGB: images must be at least rank 2, but got rank "+t.rank+"."})),Hv(1===r,(function(){return"Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size "+r+"."}));var a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,rT(t,a)}});var hA=Wk({rotateWithOffset_:function(e,t,n,r){void 0===n&&(n=0),void 0===r&&(r=.5);var a=zk(e,"image","rotateWithOffset","float32");Hv(4===a.rank,(function(){return"Error in rotateWithOffset: image must be rank 4,but got rank "+a.rank+"."}));var i={image:a},o={radians:t,fillValue:n,center:r};return Ek.runKernel(Ux,i,o)}});function dA(e,t,n,r,a,i){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==i&&(i=0);var o=e.shape[0];return n=Math.min(n,o),Hv(0<=r&&r<=1,(function(){return"iouThreshold must be in [0, 1], but was '"+r+"'"})),Hv(2===e.rank,(function(){return"boxes must be a 2D tensor, but was of rank '"+e.rank+"'"})),Hv(4===e.shape[1],(function(){return"boxes must have 4 columns, but 2nd dimension was "+e.shape[1]})),Hv(1===t.rank,(function(){return"scores must be a 1D tensor"})),Hv(t.shape[0]===o,(function(){return"scores has incompatible shape with boxes. Expected "+o+", but was "+t.shape[0]})),Hv(0<=i&&i<=1,(function(){return"softNmsSigma must be in [0, 1], but was '"+i+"'"})),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}var fA=Wk({nonMaxSuppression_:function(e,t,n,r,a){void 0===r&&(r=.5),void 0===a&&(a=Number.NEGATIVE_INFINITY);var i=zk(e,"boxes","nonMaxSuppression","float32"),o=zk(t,"scores","nonMaxSuppression","float32"),s=dA(i,o,n,r,a),u={maxOutputSize:n=s.maxOutputSize,iouThreshold:r=s.iouThreshold,scoreThreshold:a=s.scoreThreshold};return Ek.runKernel(Ab,{boxes:i,scores:o},u)}});function mA(e,t,n){var r=function(e,t,n){return function(e,t,n){var r=0,a=e.length,i=0,o=!1;for(;r<a;){var s=n(t,e[i=r+(a-r>>>1)]);s>0?r=i+1:(a=i,o=!s)}return o?r:-r-1}(e,t,n||vA)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function vA(e,t){return e>t?1:e<t?-1:0}function gA(e,t,n,r,a){return xA(e,t,n,r,a,0)}function yA(e,t,n,r,a,i){return xA(e,t,n,r,a,0,!1,i,!0)}function bA(e,t,n,r,a,i){return xA(e,t,n,r,a,i,!0)}function xA(e,t,n,r,a,i,o,s,u){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===u&&(u=!1);for(var l=[],c=0;c<t.length;c++)t[c]>a&&l.push({score:t[c],boxIndex:c,suppressBeginIndex:0});l.sort(NA);for(var p=i>0?-.5/i:0,h=[],d=[];h.length<n&&l.length>0;){var f=l.pop(),m=f.score,v=f.boxIndex,g=f.suppressBeginIndex;if(m<a)break;for(var y=!1,b=h.length-1;b>=g;--b){var x=wA(e,v,h[b]);if(x>=r){y=!0;break}if(f.score=f.score*kA(r,p,x),f.score<=a)break}f.suppressBeginIndex=h.length,y||(f.score===m?(h.push(v),d.push(f.score)):f.score>a&&mA(l,f,NA))}var w=h.length,k=n-w;s&&k>0&&(h.push.apply(h,new Array(k).fill(0)),d.push.apply(d,new Array(k).fill(0)));var N={selectedIndices:h};return o&&(N.selectedScores=d),u&&(N.validOutputs=w),N}function wA(e,t,n){var r=e.subarray(4*t,4*t+4),a=e.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]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),h=Math.max(a[1],a[3]),d=(s-i)*(u-o),f=(p-l)*(h-c);if(d<=0||f<=0)return 0;var m=Math.max(i,l),v=Math.max(o,c),g=Math.min(s,p),y=Math.min(u,h),b=Math.max(g-m,0)*Math.max(y-v,0);return b/(d+f-b)}function kA(e,t,n){var r=Math.exp(t*n*n);return n<=e?r:0}function NA(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}function IA(){return(IA=Iv(kv().mark((function e(t,n,r,a,i){var o,s,u,l,c,p,h,d;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===a&&(a=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),o=zk(t,"boxes","nonMaxSuppressionAsync"),s=zk(n,"scores","nonMaxSuppressionAsync"),u=dA(o,s,r,a,i),r=u.maxOutputSize,a=u.iouThreshold,i=u.scoreThreshold,e.next=10,Promise.all([o.data(),s.data()]);case 10:return l=e.sent,c=l[0],p=l[1],h=gA(c,p,r,a,i),d=h.selectedIndices,o!==t&&o.dispose(),s!==n&&s.dispose(),e.abrupt("return",mE(d,"int32"));case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var SA=function(e,t,n,r,a){return IA.apply(this,arguments)};var TA=Wk({nonMaxSuppressionWithScore_:function(e,t,n,r,a,i){void 0===r&&(r=.5),void 0===a&&(a=Number.NEGATIVE_INFINITY),void 0===i&&(i=0);var o=zk(e,"boxes","nonMaxSuppression"),s=zk(t,"scores","nonMaxSuppression"),u=dA(o,s,n,r,a,i),l={boxes:o,scores:s},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:i=u.softNmsSigma},p=Ek.runKernel(_b,l,c);return{selectedIndices:p[0],selectedScores:p[1]}}});function CA(){return(CA=Iv(kv().mark((function e(t,n,r,a,i,o){var s,u,l,c,p,h,d,f,m;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===a&&(a=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=0),s=zk(t,"boxes","nonMaxSuppressionAsync"),u=zk(n,"scores","nonMaxSuppressionAsync"),l=dA(s,u,r,a,i,o),r=l.maxOutputSize,a=l.iouThreshold,i=l.scoreThreshold,o=l.softNmsSigma,e.next=12,Promise.all([s.data(),u.data()]);case 12:return c=e.sent,p=c[0],h=c[1],d=bA(p,h,r,a,i,o),f=d.selectedIndices,m=d.selectedScores,s!==t&&s.dispose(),u!==n&&u.dispose(),e.abrupt("return",{selectedIndices:mE(f,"int32"),selectedScores:mE(m)});case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var EA=function(e,t,n,r,a,i){return CA.apply(this,arguments)};var AA=Wk({nonMaxSuppressionPadded_:function(e,t,n,r,a,i){void 0===r&&(r=.5),void 0===a&&(a=Number.NEGATIVE_INFINITY),void 0===i&&(i=!1);var o=zk(e,"boxes","nonMaxSuppression"),s=zk(t,"scores","nonMaxSuppression"),u=dA(o,s,n,r,a,null),l={boxes:o,scores:s},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:i},p=Ek.runKernel(Rb,l,c);return{selectedIndices:p[0],validOutputs:p[1]}}});function RA(){return(RA=Iv(kv().mark((function e(t,n,r,a,i,o){var s,u,l,c,p,h,d,f,m,v,g,y;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===a&&(a=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=!1),s=zk(t,"boxes","nonMaxSuppressionAsync"),u=zk(n,"scores","nonMaxSuppressionAsync"),l=dA(s,u,r,a,i,null),c=l.maxOutputSize,p=l.iouThreshold,h=l.scoreThreshold,e.next=11,Promise.all([s.data(),u.data()]);case 11:return d=e.sent,f=d[0],m=d[1],v=yA(f,m,c,p,h,o),g=v.selectedIndices,y=v.validOutputs,s!==t&&s.dispose(),u!==n&&u.dispose(),e.abrupt("return",{selectedIndices:mE(g,"int32"),validOutputs:KS(y,"int32")});case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var _A=function(e,t,n,r,a,i){return RA.apply(this,arguments)};var FA=Wk({resizeBilinear_:function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var a=zk(e,"images","resizeBilinear");Hv(3===a.rank||4===a.rank,(function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got rank "+a.rank+"."})),Hv(2===t.length,(function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+t+"."})),Hv(!1===r||!1===n,(function(){return"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."}));var i=a,o=!1;3===a.rank&&(o=!0,i=PI(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var s={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=Ek.runKernel(Yb,s,u);return o?PI(l,[l.shape[1],l.shape[2],l.shape[3]]):l}});var OA=Wk({resizeNearestNeighbor_:function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var a=zk(e,"images","resizeNearestNeighbor");Hv(3===a.rank||4===a.rank,(function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank "+a.rank+"."})),Hv(2===t.length,(function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+t+"."})),Hv("float32"===a.dtype||"int32"===a.dtype,(function(){return"`images` must have `int32` or `float32` as dtype"})),Hv(!1===r||!1===n,(function(){return"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."}));var i=a,o=!1;3===a.rank&&(o=!0,i=PI(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var s={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=Ek.runKernel(Kb,s,u);return o?PI(l,[l.shape[1],l.shape[2],l.shape[3]]):l}});var DA=Wk({threshold_:function(e,t,n,r){void 0===t&&(t="binary"),void 0===n&&(n=!1),void 0===r&&(r=.5);var a,i,o,s,u=zk(e,"image","threshold"),l=u.shape[0]*u.shape[1],c=lI(mE([r]),255);if(Hv(3===u.rank,(function(){return"Error in threshold: image must be rank 3,but got rank "+u.rank+"."})),Hv(3===u.shape[2]||1===u.shape[2],(function(){return"Error in threshold: image color channel must be equal to 3 or 1but got "+u.shape[2]+"."})),Hv("int32"===u.dtype||"float32"===u.dtype,(function(){return"Error in dtype: image dtype must be int32 or float32,but got dtype "+u.dtype+"."})),Hv("otsu"===t||"binary"===t,(function(){return"Method must be binary or otsu, but was "+t})),3===u.shape[2]){var p=sE(u,[1,1,1],-1);a=p[0],i=p[1],o=p[2];var h=lI(a,.2989),d=lI(i,.587),f=lI(o,.114);s=oI(oI(h,d),f)}else s=e;"otsu"===t&&(c=function(e,t){for(var n,r,a,i,o,s,u=mE([-1]),l=mE([0]),c=mE([0]),p=0;p<e.size-1;p++){n=jI(e,0,p+1),r=jI(e,p+1),o=uI(JS(n),t),s=uI(JS(r),t);var h=JS(lI(n,DC(0,n.size)));a=uI(h,JS(n));var d=nS(r.shape,n.size),f=oI(DC(0,r.size),d),m=lI(r,f);i=uI(JS(m),JS(r));var v=TT(a,i),g=TT(a,i),y=lI(o,s);c=lI(lI(y,v),g);var b=sT(c,l);l=AS(b,c,l),u=AS(b,mE([p]),u)}return u}(QI(XN(jC(s),"int32"),Gk([]),256),l));var m=n?mT(s,c):sT(s,c);return XN(lI(m,255),"int32")}});var MA=Wk({transform_:function(e,t,n,r,a,i){void 0===n&&(n="nearest"),void 0===r&&(r="constant"),void 0===a&&(a=0);var o=zk(e,"image","transform","float32"),s=zk(t,"transforms","transform","float32");Hv(4===o.rank,(function(){return"Error in transform: image must be rank 4,but got rank "+o.rank+"."})),Hv(2===s.rank&&(s.shape[0]===o.shape[0]||1===s.shape[0])&&8===s.shape[1],(function(){return"Error in transform: Input transform should be batch x 8 or 1 x 8"})),Hv(null==i||2===i.length,(function(){return"Error in transform: outputShape must be [height, width] or null, but got "+i+"."}));var u={image:o,transforms:s},l={interpolation:n,fillMode:r,fillValue:a,outputShape:i};return Ek.runKernel(Dx,u,l)}});var LA=Wk({bandPart_:function(e,t,n){var r=zk(e,"a","bandPart");Hv(r.rank>=2,(function(){return"bandPart(): Rank must be at least 2, got "+r.rank+"."}));var a,i,o=r.shape,s=r.shape.slice(-2),u=s[0],l=s[1];"number"==typeof t?(Hv(t%1==0,(function(){return"bandPart(): numLower must be an integer, got "+t+"."})),Hv(t<=u,(function(){return"bandPart(): numLower ("+t+") must not be greater than the number of rows ("+u+")."})),a=zk(t<0?u:t,"numLower","bandPart")):(Hv("int32"===t.dtype,(function(){return"bandPart(): numLower's dtype must be an int32."})),a=AS(fT(t,0),u,jT(t,u))),"number"==typeof n?(Hv(n%1==0,(function(){return"bandPart(): numUpper must be an integer, got "+n+"."})),Hv(n<=l,(function(){return"bandPart(): numUpper ("+n+") must not be greater than the number of columns ("+l+")."})),i=zk(n<0?l:n,"numUpper","bandPart")):(Hv("int32"===n.dtype,(function(){return"bandPart(): numUpper's dtype must be an int32."})),i=AS(fT(n,0),l,jT(n,l)));var c=PI(DC(0,u,1,"int32"),[-1,1]),p=DC(0,l,1,"int32"),h=TT(c,p),d=AT(mT(h,a),uT(h,NT(i))),f=VT([u,l],r.dtype);return PI(pE(RE(PI(r,[-1,u,l])).map((function(e){return AS(d,e,f)}))),o)}});var zA=Wk({gramSchmidt_:function(e){var t;Array.isArray(e)?function(){t=!1,Hv(null!=e&&e.length>0,(function(){return"Gram-Schmidt process: input must not be null, undefined, or empty"}));for(var n=e[0].shape[0],r=function(t){Hv(e[t].shape[0]===n,(function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: ("+e[t].shape[0]+" vs. "+n+")"}))},a=1;a<e.length;++a)r(a)}():(t=!0,e=sE(e,e.shape[0],0).map((function(e){return cE(e,[0])}))),Hv(e.length<=e[0].shape[0],(function(){return"Gram-Schmidt: Number of vectors ("+e.length+") exceeds number of dimensions ("+e[0].shape[0]+")."}));for(var n=[],r=e,a=function(e){n.push(Ek.tidy((function(){var t=r[e];if(e>0)for(var a=0;a<e;++a){var i=lI(JS(lI(n[a],t)),n[a]);t=TT(t,i)}return uI(t,QS(t,"euclidean"))})))},i=0;i<e.length;++i)a(i);return t?pE(n,0):n}});function PA(e,t){return void 0===t&&(t=!1),Ek.tidy((function(){Hv(2===e.shape.length,(function(){return"qr2d() requires a 2D Tensor, but got a "+e.shape.length+"D Tensor."}));for(var n=e.shape[0],r=e.shape[1],a=aT(n),i=YN(e),o=vE([[1]],[1,1]),s=YN(o),u=n>=r?r:n,l=function(e){var t=i,u=s,l=a,c=Ek.tidy((function(){var t=jI(i,[e,e],[n-e,1]),u=QS(t),l=jI(i,[e,e],[1,1]),c=AS(sT(l,0),vE([[-1]]),vE([[1]])),p=TT(l,lI(c,u)),h=uI(t,p);s=1===h.shape[0]?YN(o):VI([o,jI(h,[1,0],[h.shape[0]-1,h.shape[1]])],0);var d=NT(uI(UI(c,p),u)),f=jI(i,[e,0],[n-e,r]),m=lI(d,s),v=PE(s);if(0===e)i=TT(f,UI(m,UI(v,f)));else{var g=TT(f,UI(m,UI(v,f)));i=VI([jI(i,[0,0],[e,r]),g],0)}var y=PE(m),b=jI(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=TT(b,UI(UI(b,s),y));else{var x=TT(b,UI(UI(b,s),y));a=VI([jI(a,[0,0],[n,e]),x],1)}return[s,i,a]}));s=c[0],i=c[1],a=c[2],tI([t,u,l])},c=0;c<u;++c)l(c);return!t&&n>r&&(a=jI(a,[0,0],[n,r]),i=jI(i,[0,0],[r,r])),[a,i]}))}var BA,WA=Wk({qr_:function(e,t){if(void 0===t&&(t=!1),Hv(e.rank>=2,(function(){return"qr() requires input tensor to have a rank >= 2, but got rank "+e.rank})),2===e.rank)return PA(e,t);var n=e.shape.slice(0,e.shape.length-2).reduce((function(e,t){return e*t})),r=RE(PI(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],i=[];return r.forEach((function(e){var n=PA(e,t),r=n[0],o=n[1];a.push(r),i.push(o)})),[PI(pE(a,0),e.shape),PI(pE(i,0),e.shape)]}});(BA=e.Reduction||(e.Reduction={}))[BA.NONE=0]="NONE",BA[BA.MEAN=1]="MEAN",BA[BA.SUM=2]="SUM",BA[BA.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS";var VA=Wk({computeWeightedLoss_:function(t,n,r){void 0===r&&(r=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=zk(t,"losses","computeWeightedLoss"),i=null;null!=n&&(i=zk(n,"weights","computeWeightedLoss"));var o=null==i?a:lI(a,i);if(r===e.Reduction.NONE)return o;if(r===e.Reduction.SUM)return JS(o);if(r===e.Reduction.MEAN){if(null==i)return WT(o);var s=a.size/i.size,u=uI(JS(o),JS(i));return s>1?uI(u,KS(s)):u}if(r===e.Reduction.SUM_BY_NONZERO_WEIGHTS){if(null==i)return uI(JS(o),KS(a.size));var l=lI(i,UT(a.shape)),c=XN(JS(JT(l,KS(0))),"float32");return uI(JS(o),c)}throw Error("Unknown reduction: "+r)}});var UA=Wk({absoluteDifference_:function(t,n,r,a){void 0===a&&(a=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=zk(t,"labels","absoluteDifference"),o=zk(n,"predictions","absoluteDifference"),s=null;null!=r&&(s=zk(r,"weights","absoluteDifference")),qv(i.shape,o.shape,"Error in absoluteDifference: ");var u=cI(TT(i,o));return VA(u,s,a)}});var GA=Wk({cosineDistance_:function(t,n,r,a,i){void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=zk(t,"labels","cosineDistance"),s=zk(n,"predictions","cosineDistance"),u=null;null!=a&&(u=zk(a,"weights","cosineDistance")),qv(o.shape,s.shape,"Error in cosineDistance: ");var l=KS(1),c=TT(l,JS(lI(o,s),r,!0));return VA(c,u,i)}});var jA=Wk({hingeLoss_:function(t,n,r,a){void 0===a&&(a=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=zk(t,"labels","hingeLoss"),o=zk(n,"predictions","hingeLoss"),s=null;null!=r&&(s=zk(r,"weights","hingeLoss")),qv(i.shape,o.shape,"Error in hingeLoss: ");var u=KS(1);i=TT(lI(KS(2),i),u);var l=zC(TT(u,lI(i,o)));return VA(l,s,a)}});var HA=Wk({huberLoss_:function(t,n,r,a,i){void 0===a&&(a=1),void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=zk(t,"labels","huberLoss"),s=zk(n,"predictions","huberLoss"),u=null;null!=r&&(u=zk(r,"weights","huberLoss")),qv(o.shape,s.shape,"Error in huberLoss: ");var l=KS(a),c=cI(TT(s,o)),p=jT(c,l),h=TT(c,p),d=oI(lI(KS(.5),YS(p)),lI(l,h));return VA(d,u,i)}});var qA=Wk({logLoss_:function(t,n,r,a,i){void 0===a&&(a=1e-7),void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=zk(t,"labels","logLoss"),s=zk(n,"predictions","logLoss"),u=null;null!=r&&(u=zk(r,"weights","logLoss")),qv(o.shape,s.shape,"Error in logLoss: ");var l=KS(1),c=KS(a),p=NT(lI(o,yT(oI(s,c)))),h=lI(TT(l,o),yT(oI(TT(l,s),c))),d=TT(p,h);return VA(d,u,i)}});var KA=Wk({meanSquaredError_:function(t,n,r,a){void 0===a&&(a=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=zk(t,"labels","meanSquaredError"),o=zk(n,"predictions","meanSquaredError"),s=null;null!=r&&(s=zk(r,"weights","meanSquaredError")),qv(i.shape,o.shape,"Error in meanSquaredError: ");var u=lE(i,o);return VA(u,s,a)}});var XA=Wk({sigmoidCrossEntropy_:function(t,n,r,a,i){void 0===a&&(a=0),void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=zk(t,"multiClassLabels","sigmoidCrossEntropy"),s=zk(n,"logits","sigmoidCrossEntropy"),u=null;if(null!=r&&(u=zk(r,"weights","sigmoidCrossEntropy")),qv(o.shape,s.shape,"Error in sigmoidCrossEntropy: "),a>0){var l=KS(a),c=KS(1),p=KS(.5);o=oI(lI(o,TT(c,l)),lI(p,l))}var h=function(e,t){var n=zk(e,"labels","sigmoidCrossEntropyWithLogits"),r=zk(t,"logits","sigmoidCrossEntropyWithLogits");qv(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var a=zC(r),i=lI(r,n),o=bT(eT(NT(cI(r))));return oI(TT(a,i),o)}(o,s);return VA(h,u,i)}});var YA=Wk({softmaxCrossEntropy_:function(t,n,r,a,i){void 0===a&&(a=0),void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=zk(t,"onehotLabels","softmaxCrossEntropy"),s=zk(n,"logits","softmaxCrossEntropy"),u=null;if(null!=r&&(u=zk(r,"weights","softmaxCrossEntropy")),qv(o.shape,s.shape,"Error in softmaxCrossEntropy: "),a>0){var l=KS(a),c=KS(1),p=KS(o.shape[1]);o=oI(lI(o,TT(c,l)),uI(l,p))}var h=function(e,t,n){if(void 0===n&&(n=-1),-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank "+t.rank+" and dim was "+n);var r=wT((function(e,t,r){var a=ET(t,[n],!0),i=TT(XN(t,"float32"),a);r([e,i]);var o=NT(lI(i,e));return{value:JS(o,[n]),gradFunc:function(e,t){var r=t[0],a=t[1],i=BS(e.shape,[n]);return[lI(PI(e,i),TT(XN(r,"float32"),eT(a))),lI(PI(e,i),TT(eT(a),XN(r,"float32")))]}}}));return r(e,t)}(o,s);return VA(h,u,i)}});var JA=Wk({sparseFillEmptyRows_:function(e,t,n,r){var a=zk(e,"indices","sparseFillEmptyRows","int32"),i=zk(t,"values","sparseFillEmptyRows"),o=zk(n,"denseShape","sparseFillEmptyRows","int32"),s=zk(r,"defaultValue","sparseFillEmptyRows",i.dtype);if(2!==a.rank)throw new Error("Indices should be Tensor2D but received shape\n "+a.shape);if(1!==i.rank)throw new Error("Values should be Tensor1D but received shape "+i.shape);if(1!==o.rank)throw new Error("Dense shape should be Tensor1D but received shape "+o.shape);if(0!==s.rank)throw new Error("Default value should be a scalar but received shape "+s.shape);var u={indices:a,values:i,denseShape:o,defaultValue:s},l=Ek.runKernel(gx,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}});var ZA=Wk({sparseReshape_:function(e,t,n){var r=zk(e,"inputIndices","sparseReshape","int32"),a=zk(t,"inputShape","sparseReshape","int32"),i=zk(n,"newShape","sparseReshape","int32");if(2!==r.rank)throw new Error("Input indices should be Tensor2D but received shape\n "+r.shape);if(1!==a.rank)throw new Error("Input shape should be Tensor1D but received shape "+a.shape);if(1!==i.rank)throw new Error("New shape should be Tensor1D but received shape "+i.shape);var o={inputIndices:r,inputShape:a,newShape:i},s=Ek.runKernel(yx,o);return{outputIndices:s[0],outputShape:s[1]}}});var QA=Wk({sparseSegmentMean_:function(e,t,n){var r=zk(e,"data","sparseSegmentMean"),a=zk(t,"indices","sparseSegmentMean","int32"),i=zk(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error("Indices should be Tensor1D but received shape\n "+a.shape);if(1!==i.rank)throw new Error("Segment ids should be Tensor1D but received shape\n "+i.shape);var o={data:r,indices:a,segmentIds:i};return Ek.runKernel(bx,o)}});var $A=Wk({sparseSegmentSum_:function(e,t,n){var r=zk(e,"data","sparseSegmentSum"),a=zk(t,"indices","sparseSegmentSum","int32"),i=zk(n,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error("Indices should be Tensor1D but received shape\n "+a.shape);if(1!==i.rank)throw new Error("Segment ids should be Tensor1D but received shape\n "+i.shape);var o={data:r,indices:a,segmentIds:i};return Ek.runKernel(xx,o)}});var eR=Wk({stringNGrams_:function(e,t,n,r,a,i,o,s){var u=zk(e,"data","stringNGrams","string");if("string"!==u.dtype)throw new Error("Data must be of datatype string");if(1!==u.shape.length)throw new Error("Data must be a vector, saw: "+u.shape);var l=zk(t,"dataSplits","stringNGrams");if("int32"!==l.dtype)throw new Error("Data splits must be of datatype int32");var c={separator:n,nGramWidths:r,leftPad:a,rightPad:i,padWidth:o,preserveShortSequences:s},p={data:u,dataSplits:l},h=Ek.runKernel(Tx,p,c);return{nGrams:h[0],nGramsSplits:h[1]}}});var tR=Wk({stringSplit_:function(e,t,n){void 0===n&&(n=!0);var r=zk(e,"input","stringSplit","string"),a=zk(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error("Input should be Tensor1D but received shape "+r.shape);if(0!==a.rank)throw new Error("Delimiter should be a scalar but received shape "+a.shape);var i={skipEmpty:n},o={input:r,delimiter:a},s=Ek.runKernel(Cx,o,i);return{indices:s[0],values:s[1],shape:s[2]}}});var nR=Wk({stringToHashBucketFast_:function(e,t){var n=zk(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");var a={input:n};return Ek.runKernel(Ex,a,r)}});var rR=Wk({staticRegexReplace_:function(e,t,n,r){void 0===r&&(r=!0);var a=zk(e,"input","staticRegexReplace","string"),i={pattern:t,rewrite:n,replaceGlobal:r};return Ek.runKernel(Ix,{x:a},i)}}),aR={fft:aE,ifft:iE,rfft:uE,irfft:oE},iR={hammingWindow:iA,hannWindow:oA,frame:sA,stft:uA},oR={flipLeftRight:cA,grayscaleToRGB:pA,resizeNearestNeighbor:OA,resizeBilinear:FA,rotateWithOffset:hA,cropAndResize:lA,nonMaxSuppression:fA,nonMaxSuppressionAsync:SA,nonMaxSuppressionWithScore:TA,nonMaxSuppressionWithScoreAsync:EA,nonMaxSuppressionPadded:AA,nonMaxSuppressionPaddedAsync:_A,threshold:DA,transform:MA},sR={bandPart:LA,gramSchmidt:zA,qr:WA},uR={absoluteDifference:UA,computeWeightedLoss:VA,cosineDistance:GA,hingeLoss:jA,huberLoss:HA,logLoss:qA,meanSquaredError:KA,sigmoidCrossEntropy:XA,softmaxCrossEntropy:YA},lR={sparseFillEmptyRows:JA,sparseReshape:ZA,sparseSegmentMean:QA,sparseSegmentSum:$A},cR={stringNGrams:eR,stringSplit:tR,stringToHashBucketFast:nR,staticRegexReplace:rR},pR=function(){function e(){}return e.prototype.getClassName=function(){return this.constructor.className},e.fromConfig=function(e,t){return new e(t)},e}(),hR=function(){function e(){this.classNameMap={}}return e.getMap=function(){return null==e.instance&&(e.instance=new e),e.instance},e.register=function(t){e.getMap().classNameMap[t.className]=[t,t.fromConfig]},e}();function dR(e){Hv(null!=e.className,(function(){return"Class being registered does not have the static className property defined."})),Hv("string"==typeof e.className,(function(){return"className is required to be a string, but got type "+typeof e.className})),Hv(e.className.length>0,(function(){return"Class being registered has an empty-string as its className, which is disallowed."})),hR.register(e)}var fR={__proto__:null,Serializable:pR,SerializationMap:hR,registerClass:dR},mR=function(e){function t(){return e.apply(this,arguments)||this}Cv(t,e);var n=t.prototype;return n.minimize=function(e,t,n){void 0===t&&(t=!1);var r=this.computeGradients(e,n),a=r.value,i=r.grads;if(null!=n){var o=n.map((function(e){return{name:e.name,tensor:i[e.name]}}));this.applyGradients(o)}else this.applyGradients(i);return tI(i),t?a:(a.dispose(),null)},n.incrementIterations=function(){this.iterations_=this.iterations+1},n.computeGradients=function(e,t){return xT(e,t)},n.dispose=function(){null!=this.iterations_&&tI(this.iterations_)},n.saveIterations=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==this.iterations_&&(this.iterations_=0),e.abrupt("return",{name:"iter",tensor:KS(this.iterations_,"int32")});case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.getWeights=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("getWeights() is not implemented for this optimizer yet.");case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("setWeights() is not implemented for this optimizer class "+this.getClassName());case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.extractIterations=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t[0].tensor.data();case 2:return this.iterations_=e.sent[0],e.abrupt("return",t.slice(1));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),Tv(t,[{key:"iterations",get:function(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}}]),t}(pR);Object.defineProperty(mR,Symbol.hasInstance,{value:function(e){return null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients}});var vR=function(e){function t(t,n,r){var a;return void 0===r&&(r=null),(a=e.call(this)||this).learningRate=t,a.rho=n,a.epsilon=r,a.accumulatedGrads=[],a.accumulatedUpdates=[],null==r&&(a.epsilon=Ek.backend.epsilon()),a}Cv(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Ek.registeredVariables[n];null==t.accumulatedGrads[r]&&(t.accumulatedGrads[r]={originalName:n+"/accum_grad",variable:eI((function(){return RS(a).variable(false)}))}),null==t.accumulatedUpdates[r]&&(t.accumulatedUpdates[r]={originalName:n+"/accum_var",variable:eI((function(){return RS(a).variable(false)}))});var i=Array.isArray(e)?e[r].tensor:e[n];if(null!=i){var o=t.accumulatedGrads[r].variable,s=t.accumulatedUpdates[r].variable;eI((function(){var e=oI(lI(o,t.rho),lI(YS(i),1-t.rho)),n=lI(uI(XS(oI(s,t.epsilon)),XS(oI(o,t.epsilon))),i),r=oI(lI(s,t.rho),lI(YS(n),1-t.rho));o.assign(e),s.assign(r);var u=oI(lI(n,-t.learningRate),a);a.assign(u)}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedUpdates&&(tI(this.accumulatedGrads.map((function(e){return e.variable}))),tI(this.accumulatedUpdates.map((function(e){return e.variable}))))},n.getWeights=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(this.accumulatedGrads,this.accumulatedUpdates),e.next=3,this.saveIterations();case 3:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(t.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Iv(kv().mark((function e(t){var n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,n=t.length/2,!1,this.accumulatedGrads=t.slice(0,n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(false)}})),this.accumulatedUpdates=t.slice(n,2*n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(false)}}));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}},t.fromConfig=function(e,t){return new e(t.learningRate,t.rho,t.epsilon)},Tv(t,null,[{key:"className",get:function(){return"Adadelta"}}]),t}(mR),gR=function(e){function t(t,n){var r;return void 0===n&&(n=.1),(r=e.call(this)||this).learningRate=t,r.initialAccumulatorValue=n,r.accumulatedGrads=[],r}Cv(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Ek.registeredVariables[n];if(null==t.accumulatedGrads[r]){t.accumulatedGrads[r]={originalName:n+"/accumulator",variable:eI((function(){return nS(a.shape,t.initialAccumulatorValue).variable(false)}))}}var i=Array.isArray(e)?e[r].tensor:e[n];if(null!=i){var o=t.accumulatedGrads[r].variable;eI((function(){var e=oI(o,YS(i));o.assign(e);var n=oI(lI(uI(i,XS(oI(e,Ek.backend.epsilon()))),-t.learningRate),a);a.assign(n)}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedGrads&&tI(this.accumulatedGrads.map((function(e){return e.variable})))},n.getWeights=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.saveIterations();case 2:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(this.accumulatedGrads.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,!1,this.accumulatedGrads=t.map((function(e){return{originalName:e.name,variable:e.tensor.variable(false)}}));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}},t.fromConfig=function(e,t){return new e(t.learningRate,t.initialAccumulatorValue)},Tv(t,null,[{key:"className",get:function(){return"Adagrad"}}]),t}(mR),yR=function(e){function t(t,n,r,a){var i;return void 0===a&&(a=null),(i=e.call(this)||this).learningRate=t,i.beta1=n,i.beta2=r,i.epsilon=a,i.accumulatedFirstMoment=[],i.accumulatedSecondMoment=[],eI((function(){i.accBeta1=KS(n).variable(),i.accBeta2=KS(r).variable()})),null==a&&(i.epsilon=Ek.backend.epsilon()),i}Cv(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this,n=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e);eI((function(){var r=TT(1,t.accBeta1),a=TT(1,t.accBeta2);n.forEach((function(n,i){var o=Ek.registeredVariables[n];null==t.accumulatedFirstMoment[i]&&(t.accumulatedFirstMoment[i]={originalName:n+"/m",variable:eI((function(){return RS(o).variable(false)}))}),null==t.accumulatedSecondMoment[i]&&(t.accumulatedSecondMoment[i]={originalName:n+"/v",variable:eI((function(){return RS(o).variable(false)}))});var s=Array.isArray(e)?e[i].tensor:e[n];if(null!=s){var u=t.accumulatedFirstMoment[i].variable,l=t.accumulatedSecondMoment[i].variable,c=oI(lI(u,t.beta1),lI(s,1-t.beta1)),p=oI(lI(l,t.beta2),lI(YS(s),1-t.beta2)),h=uI(c,r),d=uI(p,a);u.assign(c),l.assign(p);var f=oI(lI(uI(h,oI(XS(d),t.epsilon)),-t.learningRate),o);o.assign(f)}})),t.accBeta1.assign(lI(t.accBeta1,t.beta1)),t.accBeta2.assign(lI(t.accBeta2,t.beta2))})),this.incrementIterations()},n.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&tI(this.accumulatedFirstMoment.map((function(e){return e.variable}))),null!=this.accumulatedSecondMoment&&tI(this.accumulatedSecondMoment.map((function(e){return e.variable})))},n.getWeights=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(this.accumulatedFirstMoment,this.accumulatedSecondMoment),e.next=3,this.saveIterations();case 3:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(t.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Iv(kv().mark((function e(t){var n,r=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,eI((function(){r.accBeta1.assign(qS(r.beta1,r.iterations_+1)),r.accBeta2.assign(qS(r.beta2,r.iterations_+1))})),n=t.length/2,!1,this.accumulatedFirstMoment=t.slice(0,n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(false)}})),this.accumulatedSecondMoment=t.slice(n,2*n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(false)}}));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}},t.fromConfig=function(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)},Tv(t,null,[{key:"className",get:function(){return"Adam"}}]),t}(mR),bR=function(e){function t(t,n,r,a,i){var o;return void 0===a&&(a=null),void 0===i&&(i=0),(o=e.call(this)||this).learningRate=t,o.beta1=n,o.beta2=r,o.epsilon=a,o.decay=i,o.accumulatedFirstMoment=[],o.accumulatedWeightedInfNorm=[],eI((function(){o.iteration=KS(0).variable(),o.accBeta1=KS(n).variable()})),null==a&&(o.epsilon=Ek.backend.epsilon()),o}Cv(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this,n=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e);eI((function(){var r=TT(1,t.accBeta1),a=uI(-t.learningRate,oI(lI(t.iteration,t.decay),1));n.forEach((function(n,i){var o=Ek.registeredVariables[n];null==t.accumulatedFirstMoment[i]&&(t.accumulatedFirstMoment[i]={originalName:n+"/m",variable:RS(o).variable(false)}),null==t.accumulatedWeightedInfNorm[i]&&(t.accumulatedWeightedInfNorm[i]={originalName:n+"/v",variable:RS(o).variable(false)});var s=Array.isArray(e)?e[i].tensor:e[n];if(null!=s){var u=t.accumulatedFirstMoment[i].variable,l=t.accumulatedWeightedInfNorm[i].variable,c=oI(lI(u,t.beta1),lI(s,1-t.beta1)),p=lI(l,t.beta2),h=cI(s),d=BT(p,h);u.assign(c),l.assign(d);var f=oI(lI(uI(a,r),uI(c,oI(d,t.epsilon))),o);o.assign(f)}})),t.iteration.assign(oI(t.iteration,1)),t.accBeta1.assign(lI(t.accBeta1,t.beta1))})),this.incrementIterations()},n.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&tI(this.accumulatedFirstMoment.map((function(e){return e.variable}))),null!=this.accumulatedWeightedInfNorm&&tI(this.accumulatedWeightedInfNorm.map((function(e){return e.variable})))},n.getWeights=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("getWeights() is not implemented for Adamax yet.");case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("setWeights() is not implemented for Adamax yet.");case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}},t.fromConfig=function(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)},Tv(t,null,[{key:"className",get:function(){return"Adamax"}}]),t}(mR),xR=function(e){function t(t){var n;return(n=e.call(this)||this).learningRate=t,n.setLearningRate(t),n}Cv(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Array.isArray(e)?e[r].tensor:e[n];if(null!=a){var i=Ek.registeredVariables[n];eI((function(){var e=oI(lI(t.c,a),i);i.assign(e)}))}})),this.incrementIterations()},n.setLearningRate=function(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=nI(KS(-e))},n.dispose=function(){this.c.dispose()},n.getWeights=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.saveIterations();case 2:return e.t0=e.sent,e.abrupt("return",[e.t0]);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:if(0===(t=e.sent).length){e.next=5;break}throw new Error("SGD optimizer does not have settable weights.");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate}},t.fromConfig=function(e,t){return new e(t.learningRate)},Tv(t,null,[{key:"className",get:function(){return"SGD"}}]),t}(mR),wR=function(e){function t(t,n,r){var a;return void 0===r&&(r=!1),(a=e.call(this,t)||this).learningRate=t,a.momentum=n,a.useNesterov=r,a.accumulations=[],a.m=KS(a.momentum),a}Cv(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Ek.registeredVariables[n];if(null==t.accumulations[r]){t.accumulations[r]={originalName:n+"/momentum",variable:eI((function(){return RS(a).variable(false)}))}}var i=t.accumulations[r].variable,o=Array.isArray(e)?e[r].tensor:e[n];null!=o&&eI((function(){var e,n=oI(lI(t.m,i),o);e=t.useNesterov?oI(lI(t.c,oI(o,lI(n,t.m))),a):oI(lI(t.c,n),a),i.assign(n),a.assign(e)}))})),this.incrementIterations()},n.dispose=function(){this.m.dispose(),null!=this.accumulations&&tI(this.accumulations.map((function(e){return e.variable})))},n.setMomentum=function(e){this.momentum=e},n.getWeights=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.saveIterations();case 2:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(this.accumulations.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,!1,this.accumulations=t.map((function(e){return{originalName:e.name,variable:e.tensor.variable(false)}}));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}},t.fromConfig=function(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)},Tv(t,null,[{key:"className",get:function(){return"Momentum"}}]),t}(xR),kR=function(e){function t(t,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=e.call(this)||this).learningRate=t,o.decay=n,o.momentum=r,o.epsilon=a,o.accumulatedMeanSquares=[],o.accumulatedMoments=[],o.accumulatedMeanGrads=[],o.centered=i,null==a&&(o.epsilon=Ek.backend.epsilon()),null==t)throw new Error("learningRate for RMSPropOptimizer must be defined.");return o}Cv(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Ek.registeredVariables[n],i=!1;null==t.accumulatedMeanSquares[r]&&(t.accumulatedMeanSquares[r]={originalName:n+"/rms",variable:eI((function(){return RS(a).variable(i)}))}),null==t.accumulatedMoments[r]&&(t.accumulatedMoments[r]={originalName:n+"/momentum",variable:eI((function(){return RS(a).variable(i)}))}),null==t.accumulatedMeanGrads[r]&&t.centered&&(t.accumulatedMeanGrads[r]={originalName:n+"/mg",variable:eI((function(){return RS(a).variable(i)}))});var o=Array.isArray(e)?e[r].tensor:e[n];if(null!=o){var s=t.accumulatedMeanSquares[r].variable,u=t.accumulatedMoments[r].variable;eI((function(){var e=oI(lI(s,t.decay),lI(YS(o),1-t.decay));if(t.centered){var n=t.accumulatedMeanGrads[r].variable,i=oI(lI(n,t.decay),lI(o,1-t.decay)),l=uI(lI(o,t.learningRate),XS(TT(e,oI(YS(i),t.epsilon)))),c=oI(lI(u,t.momentum),l);s.assign(e),n.assign(i),u.assign(c);var p=TT(a,c);a.assign(p)}else{var h=oI(lI(s,t.decay),lI(YS(o),1-t.decay)),d=oI(lI(u,t.momentum),uI(lI(o,t.learningRate),XS(oI(h,t.epsilon))));s.assign(h),u.assign(d);var f=TT(a,d);a.assign(f)}}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedMeanSquares&&tI(this.accumulatedMeanSquares.map((function(e){return e.variable}))),null!=this.accumulatedMeanGrads&&this.centered&&tI(this.accumulatedMeanGrads.map((function(e){return e.variable}))),null!=this.accumulatedMoments&&tI(this.accumulatedMoments.map((function(e){return e.variable})))},n.getWeights=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(this.accumulatedMeanSquares,this.accumulatedMoments),this.centered&&t.push.apply(t,this.accumulatedMeanGrads),e.next=4,this.saveIterations();case 4:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(t.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Iv(kv().mark((function e(t){var n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,n=this.centered?t.length/3:t.length/2,r=!1,this.accumulatedMeanSquares=t.slice(0,n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(r)}})),this.accumulatedMoments=t.slice(n,2*n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(r)}})),this.centered&&(this.accumulatedMeanGrads=t.slice(2*n,3*n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(r)}})));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}},t.fromConfig=function(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)},Tv(t,null,[{key:"className",get:function(){return"RMSProp"}}]),t}(mR),NR=[vR,gR,yR,bR,wR,kR,xR];function IR(e){return new Promise((function(e){return setTimeout(e)})).then(e)}var SR=function(){function e(t){if(!Fg().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(e.URL_SCHEME)&&(t=t.slice(e.URL_SCHEME.length)),null!=t&&0!==t.length||(t="model"),this.modelJsonFileName=t+".json",this.weightDataFileName=t+".weights.bin"}return e.prototype.save=function(){var e=Iv(kv().mark((function e(t){var n,r,a,i,o,s;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof document){e.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([t.weightData],{type:"application/octet-stream"})),!(t.modelTopology instanceof ArrayBuffer)){e.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:t.weightSpecs}],a=tN(t,r),i=window.URL.createObjectURL(new Blob([JSON.stringify(a)],{type:"application/json"})),(o=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor).download=this.modelJsonFileName,o.href=i,e.next=15,IR((function(){return o.dispatchEvent(new MouseEvent("click"))}));case 15:if(null==t.weightData){e.next=21;break}return(s=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor).download=this.weightDataFileName,s.href=n,e.next=21,IR((function(){return s.dispatchEvent(new MouseEvent("click"))}));case 21:return e.abrupt("return",{modelArtifactsInfo:iN(t)});case 22:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();SR.URL_SCHEME="downloads://";var TR=function(){function e(e){if(null==e||e.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+e);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}var t=e.prototype;return t.load=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){var r=new FileReader;r.onload=function(r){var a=JSON.parse(r.target.result),i=a.modelTopology;if(null!=i)if(null!=a.weightsManifest)if(0!==t.weightsFiles.length){var o=rN(a,(function(e){return t.loadWeights(e)}));e(o)}else e({modelTopology:i});else n(new Error("weightManifest field is missing from file "+t.jsonFile.name));else n(new Error("modelTopology field is missing from file "+t.jsonFile.name))},r.onerror=function(e){return n("Failed to read model topology and weights manifest JSON from file '"+t.jsonFile.name+"'. BrowserFiles supports loading Keras-style tf.Model artifacts only.")},r.readAsText(t.jsonFile)})));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),t.loadWeights=function(e){for(var t,n=this,r=[],a=[],i=Lv(e);!(t=i()).done;){var o=t.value;r.push.apply(r,o.weights),a.push.apply(a,o.paths)}var s=this.checkManifestAndWeightFiles(e),u=a.map((function(e){return n.loadWeightsFile(e,s[e])}));return Promise.all(u).then((function(e){return[r,$k(e)]}))},t.loadWeightsFile=function(e,t){return new Promise((function(n,r){var a=new FileReader;a.onload=function(e){var t=e.target.result;n(t)},a.onerror=function(t){return r("Failed to weights data from file of path '"+e+"'.")},a.readAsArrayBuffer(t)}))},t.checkManifestAndWeightFiles=function(e){for(var t,n=this,r=[],a=this.weightsFiles.map((function(e){return eN(e.name)})),i={},o=Lv(e);!(t=o()).done;){t.value.paths.forEach((function(e){var t=eN(e);if(-1!==r.indexOf(t))throw new Error("Duplicate file basename found in weights manifest: '"+t+"'");if(r.push(t),-1===a.indexOf(t))throw new Error("Weight file with basename '"+t+"' is not provided.");i[e]=n.weightsFiles[a.indexOf(t)]}))}if(r.length!==this.weightsFiles.length)throw new Error("Mismatch in the number of files in weights manifest ("+r.length+") and the number of weight files provided ("+this.weightsFiles.length+").");return i},e}();function CR(e,t,n,r){!function(e){Hv(null!=e&&Array.isArray(e)&&e.length>0,(function(){return"promises must be a none empty array"}))}(e),function(e,t){Hv(e>=0&&e<=1,(function(){return"Progress fraction must be in range [0, 1], but got startFraction "+e})),Hv(t>=0&&t<=1,(function(){return"Progress fraction must be in range [0, 1], but got endFraction "+t})),Hv(t>=e,(function(){return"startFraction must be no more than endFraction, but got startFraction "+e+" and endFraction "+t}))}(n=null==n?0:n,r=null==r?1:r);var a=0;return Promise.all(e.map((function(i){return i.then((function(i){var o=n+ ++a/e.length*(r-n);return t(o),i})),i})))}function ER(e,t){return AR.apply(this,arguments)}function AR(){return(AR=Iv(kv().mark((function e(t,n){var r,a,i,o,s,u,l,c,p;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n&&(n={}),r=null==n.fetchFunc?Fg().platform.fetch:n.fetchFunc,a=t.map((function(e){return r(e,n.requestInit,{isBinary:!0})})),i=0,o=.5,null!=n.onProgress){e.next=11;break}return e.next=8,Promise.all(a);case 8:e.t0=e.sent,e.next=14;break;case 11:return e.next=13,CR(a,n.onProgress,i,o);case 13:e.t0=e.sent;case 14:if(s=e.t0,u=s.map((function(e){return e.arrayBuffer()})),l=.5,c=1,null!=n.onProgress){e.next=24;break}return e.next=21,Promise.all(u);case 21:e.t1=e.sent,e.next=27;break;case 24:return e.next=26,CR(u,n.onProgress,l,c);case 26:e.t1=e.sent;case 27:return p=e.t1,e.abrupt("return",p);case 29:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function RR(e,t,n,r){return _R.apply(this,arguments)}function _R(){return _R=Iv(kv().mark((function e(t,n,r,a){var i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n=""),i=FR((function(e){return ER(e,{requestInit:a})})),e.abrupt("return",i(t,n,r));case 4:case"end":return e.stop()}}),e)}))),_R.apply(this,arguments)}function FR(e){return function(){var t=Iv(kv().mark((function t(n,r,a){var i,o,s,u,l,c,p,h,d,f;return kv().wrap((function(t){for(;;)switch(t.prev=t.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(e,t){var n=0;e.weights.forEach((function(e){var r="quantization"in e?e.quantization.dtype:e.dtype,l=jk[r]*Xv(e.shape),c=function(){i[t]=!0,null==o[t]&&(o[t]=[]),o[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=a?a.forEach((function(t,n){t===e.name&&(c(),s[n]=!0)})):c(),u.push(e.name),n+=l}))})),s.every((function(e){return e}))){t.next=9;break}throw l=a.filter((function(e,t){return!s[t]})),new Error("Could not find weights in manifest with names: "+l.join(", ")+". \nManifest JSON has weights with names: "+u.join(", ")+".");case 9:return c=i.reduce((function(e,t,n){return t&&e.push(n),e}),[]),p=[],c.forEach((function(e){n[e].paths.forEach((function(e){var t=r+(r.endsWith("/")?"":"/")+e;p.push(t)}))})),t.next=14,e(p);case 14:return h=t.sent,d={},f=0,c.forEach((function(e){for(var t=n[e].paths.length,r=0,a=0;a<t;a++)r+=h[f+a].byteLength;for(var i=new ArrayBuffer(r),s=new Uint8Array(i),u=0,l=0;l<t;l++){var c=new Uint8Array(h[f+l]);s.set(c,u),u+=c.byteLength}o[e].forEach((function(e){var t=Kk(i.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(var n in t)d[n]=t[n]})),f+=t})),t.abrupt("return",d);case 19:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()}uN.registerSaveRouter((function(e){return Fg().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(SR.URL_SCHEME)?function(e){void 0===e&&(e="model");return new SR(e)}(e.slice(SR.URL_SCHEME.length)):null}));var OR=function(){function e(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?(Hv("function"==typeof t.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=t.fetchFunc):this.fetch=Fg().platform.fetch,Hv(null!=e&&e.length>0,(function(){return"URL path for http must not be null, undefined or empty."})),Array.isArray(e)&&Hv(2===e.length,(function(){return"URL paths for http must have a length of 2, (actual length is "+e.length+")."})),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}var t=e.prototype;return t.save=function(){var e=Iv(kv().mark((function e(t){var n,r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.modelTopology instanceof ArrayBuffer)){e.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:t.weightSpecs}],a=tN(t,r),n.body.append("model.json",new Blob([JSON.stringify(a)],{type:"application/json"}),"model.json"),null!=t.weightData&&n.body.append("model.weights.bin",new Blob([t.weightData],{type:"application/octet-stream"}),"model.weights.bin"),e.next=10,this.fetch(this.path,n);case 10:if(!(i=e.sent).ok){e.next=15;break}return e.abrupt("return",{modelArtifactsInfo:iN(t),responses:[i]});case 15:throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+i.status+".");case 16:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.load=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.fetch(this.path,this.requestInit);case 2:if((t=e.sent).ok){e.next=5;break}throw new Error("Request to "+this.path+" failed with status code "+t.status+". Please verify this URL points to the model JSON of the model to load.");case 5:return e.prev=5,e.next=8,t.json();case 8:n=e.sent,e.next=16;break;case 11:throw e.prev=11,e.t0=e.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,null!=a||null!=i){e.next=20;break}throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");case 20:return e.abrupt("return",rN(n,(function(e){return o.loadWeights(e)})));case 21:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(){return e.apply(this,arguments)}}(),t.loadWeights=function(){var e=Iv(kv().mark((function e(t){var n,r,a,i,o,s,u,l,c,p,h,d,f,m,v;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=Array.isArray(this.path)?this.path[1]:this.path,r=DR(n),a=r[0],i=r[1],o=this.weightPathPrefix||a,s=oN(t),u=[],l=[],c=Lv(t);!(p=c()).done;)for(h=p.value,d=Lv(h.paths);!(f=d()).done;)m=f.value,null!=this.weightUrlConverter?l.push(this.weightUrlConverter(m)):u.push(o+m+i);if(!this.weightUrlConverter){e.next=14;break}return e.t0=u.push,e.t1=u,e.next=12,Promise.all(l);case 12:e.t2=e.sent,e.t0.apply.call(e.t0,e.t1,e.t2);case 14:return e.next=16,ER(u,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});case 16:return v=e.sent,e.abrupt("return",[s,$k(v)]);case 18:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();function DR(e){var t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}function MR(e){return null!=e.match(OR.URL_SCHEME_REGEX)}OR.URL_SCHEME_REGEX=/^https?:\/\//;var LR=function(e,t){if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;return(Array.isArray(e)?e.every((function(e){return MR(e)})):MR(e))?zR(e,t):null};function zR(e,t){return new OR(e,t)}function PR(e,t){return zR(e,t)}uN.registerSaveRouter(LR),uN.registerLoadRouter(LR);var BR=function(){function e(e){this.modelArtifacts=e}return e.prototype.load=function(){return this.modelArtifacts},e}(),WR=function(){function e(e){this.saveHandler=e}return e.prototype.save=function(e){return this.saveHandler(e)},e}(),VR=function(e){e.load&&(this.load=function(){return Promise.resolve(e.load())}),e.save&&(this.save=function(t){return Promise.resolve(e.save(t))})};function UR(e,t,n,r){if(1===arguments.length){var a=null!=e.modelTopology||null!=e.weightSpecs;return a?new BR(e):(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 BR({modelTopology:e}))}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 BR({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r})}var GR={__proto__:null,browserFiles:function(e){return new TR(e)},browserHTTPRequest:PR,concatenateArrayBuffers:$k,decodeWeights:Kk,encodeWeights:Hk,fromMemory:function(e,t,n,r){var a=arguments;return new VR(UR.apply(void 0,a))},fromMemorySync:UR,getLoadHandlers:cN,getModelArtifactsForJSON:rN,getModelArtifactsForJSONSync:nN,getModelArtifactsInfoForJSON:iN,getSaveHandlers:lN,getWeightSpecs:oN,http:zR,isHTTPScheme:MR,loadWeights:RR,registerLoadRouter:function(e){return uN.registerLoadRouter(e)},registerSaveRouter:function(e){return uN.registerSaveRouter(e)},weightsLoaderFactory:FR,withSaveHandler:function(e){return new WR(e)},withSaveHandlerSync:function(e){return new WR(e)},copyModel:function(e,t){return VN.apply(this,arguments)},listModels:function(){return BN.apply(this,arguments)},moveModel:function(e,t){return UN.apply(this,arguments)},removeModel:function(e){return WN.apply(this,arguments)}};var jR,HR={__proto__:null,confusionMatrix:Wk({confusionMatrix_:function(e,t,n){var r=zk(e,"labels","confusionMatrix"),a=zk(t,"predictions","confusionMatrix");Hv(null==n||n>0&&Number.isInteger(n),(function(){return"If provided, numClasses must be a positive integer, but got "+n})),Hv(1===r.rank,(function(){return"Expected the rank of labels to be 1, but got "+r.rank})),Hv(1===a.rank,(function(){return"Expected the rank of predictions to be 1, but got "+a.rank})),Hv(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."})),Hv(n>0&&Number.isInteger(n),(function(){return"numClasses is required to be a positive integer, but got "+n}));var i=ZT(XN(r,"int32"),n),o=ZT(XN(a,"int32"),n),s=PE(i),u=UI(s,o);return XN(u,"int32")}})};function qR(e,t){if(void 0===t&&(t=3),t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,r=!1,a=!1,i=!1,o=!1,s=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)i=!0;else if(null!=e.getContext)o=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))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 "+e.constructor.name);s=!0}if(null!=Yx(Vx,Ek.backendName)){var u={pixels:e},l={numChannels:t};return Ek.runKernel(Vx,u,l)}var c,p,h=a?[e.videoWidth,e.videoHeight]:[e.width,e.height],d=h[0],f=h[1];if(o)c=e.getContext("2d").getImageData(0,0,d,f).data;else if(r||n)c=e.data;else if(i||a||s){if(null==jR)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");jR=new OffscreenCanvas(1,1).getContext("2d")}else jR=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});jR.canvas.width=d,jR.canvas.height=f,jR.drawImage(e,0,0,d,f),c=jR.getImageData(0,0,d,f).data}if(4===t)p=new Int32Array(c);else{var m=d*f;p=new Int32Array(m*t);for(var v=0;v<m;v++)for(var g=0;g<t;++g)p[v*t+g]=c[4*v+g]}return gE(p,[f,d,t],"int32")}function KR(e){return"undefined"!=typeof window&&"undefined"!=typeof ImageBitmap&&window.hasOwnProperty("createImageBitmap")&&!(e instanceof ImageBitmap)&&function(e){return null!=e&&0!==e.width&&0!==e.height}(e)&&!function(e){return null!=e&&e.data instanceof Uint8Array}(e)}function XR(){return(XR=Iv(kv().mark((function e(t,n){var r,a;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n=3),r=null,!Fg().getBool("WRAP_TO_IMAGEBITMAP")||!KR(t)){e.next=15;break}return e.prev=3,e.next=6,createImageBitmap(t,{premultiplyAlpha:"none"});case 6:a=e.sent,e.next=12;break;case 9:e.prev=9,e.t0=e.catch(3),a=null;case 12:r=null!=a&&a.width===t.width&&a.height===t.height?a:t,e.next=16;break;case 15:r=t;case 16:return e.abrupt("return",qR(r,n));case 17:case"end":return e.stop()}}),e,null,[[3,9]])})))).apply(this,arguments)}function YR(){return YR=Iv(kv().mark((function e(t,n){var r,a,i,o,s,u,l,c,p,h,d,f,m,v,g,y;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=zk(t,"img","toPixels"),t instanceof ak||(r=XN(a=r,"int32"),a.dispose()),2===r.rank||3===r.rank){e.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)){e.next=8;break}throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+u);case 8:if("float32"===r.dtype||"int32"===r.dtype){e.next=10;break}throw new Error("Unsupported type for toPixels: "+r.dtype+". Please use float32 or int32 tensors.");case 10:return e.next=12,r.data();case 12:l=e.sent,c="float32"===r.dtype?255:1,p=new Uint8ClampedArray(s*o*4),h=0;case 16:if(!(h<o*s)){e.next=41;break}d=[0,0,0,255],f=0;case 19:if(!(f<u)){e.next=33;break}if(m=l[h*u+f],"float32"!==r.dtype){e.next=26;break}if(!(m<0||m>1)){e.next=24;break}throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered "+m+".");case 24:e.next=29;break;case 26:if("int32"!==r.dtype){e.next=29;break}if(!(m<0||m>255)){e.next=29;break}throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered "+m+".");case 29:1===u?(d[0]=m*c,d[1]=m*c,d[2]=m*c):d[f]=m*c;case 30:f++,e.next=19;break;case 33:p[(v=4*h)+0]=Math.round(d[0]),p[v+1]=Math.round(d[1]),p[v+2]=Math.round(d[2]),p[v+3]=Math.round(d[3]);case 38:++h,e.next=16;break;case 41:return null!=n&&(n.width=s,n.height=o,g=n.getContext("2d"),y=new ImageData(p,s,o),g.putImageData(y,0,0)),r!==t&&r.dispose(),e.abrupt("return",p);case 44:case"end":return e.stop()}}),e)}))),YR.apply(this,arguments)}var JR=Wk({fromPixels_:qR}),ZR={__proto__:null,fromPixelsAsync:function(e,t){return XR.apply(this,arguments)},toPixels:function(e,t){return YR.apply(this,arguments)},fromPixels:JR};function QR(e,t){var n=e.shape.length,r=t.shape.length;if(n<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher, but the rank was "+n+".");if(r<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher, but the rank was "+r+".");if("int32"!==t.dtype)throw new Error("tf.gatherND() expects the indices to be int32 type, but the dtype was "+t.dtype+".");if(t.shape[r-1]>n)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+t.shape[r-1]+" vs. "+n);if(0===Xv(e.shape))throw new Error("Requested more than 0 entries, but input is empty. Input shape: "+e.shape+".");for(var a=t.shape,i=a[a.length-1],o=1,s=0;s<a.length-1;++s)o*=a[s];var u=e.shape,l=a.slice();l.pop();for(var c=1,p=i;p<n;++p)c*=u[p],l.push(u[p]);var h=[].concat(vg(e.shape).map((function(e){return e/c})),[1]).slice(0,i);return[l,o,c,h]}var $R={__proto__:null,prepareAndValidate:QR};function e_(e,t,n){var r=e.shape.length;Hv(r===t.length,(function(){return"Error in slice"+r+"D: Length of begin "+t+" must match the rank of the array ("+r+")."})),Hv(r===n.length,(function(){return"Error in slice"+r+"D: Length of size "+n+" must match the rank of the array ("+r+")."}));for(var a=function(a){Hv(t[a]+n[a]<=e.shape[a],(function(){return"Error in slice"+r+"D: begin["+a+"] + size["+a+"] ("+(t[a]+n[a])+") would overflow input.shape["+a+"] ("+e.shape[a]+")"}))},i=0;i<r;++i)a(i)}function t_(e,t,n){for(var r=[],a=0;a<e.length;a++)r[a]=Math.ceil((t[a]-e[a])/n[a]);return r}function n_(e,t,n,r){for(var a=[].concat(e),i=a.length;i<r.length;i++)a.push(1);for(var o=0;o<n;o++)0===o?a[t]=1:(a.splice(t,0,1),a.pop());return a}function r_(e,t,n){return n<=e?n:n-(t-1)}function a_(e,t){for(var n=[],r=0;r<e;r++)n.push(t+r);return n}function i_(e,t,n,r,a){for(var i=[].concat(a),o=a_(n,t),s=0;s<i.length;s++)if(o.indexOf(s)>-1)i[s]=0;else{var u=r_(t,n,s),l=r[u];e&1<<u&&(l=0),i[s]=l}return i}function o_(e,t,n,r,a){for(var i=[].concat(a),o=a_(n,t),s=0;s<i.length;s++)if(o.indexOf(s)>-1)i[s]=Number.MAX_SAFE_INTEGER;else{var u=r_(t,n,s),l=r[u];e&1<<u&&(l=Number.MAX_SAFE_INTEGER),i[s]=l}for(var c=0;c<i.length;c++){var p=a[c];i[c]<0&&(i[c]+=p),i[c]=Vv(0,i[c],a[c])}return i}function s_(e,t,n){var r=e[t];return(n&1<<t||null==r)&&(r=1),r}function u_(e,t,n,r,a,i){var o=t[a],s=n[a]||1;(e&1<<a||i&1<<a||null==o)&&(o=s>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);var u=r[a];return o<0&&(o+=u),o=Vv(0,o,u-1)}function l_(e,t,n,r,a,i){var o=t[a],s=n[a]||1;(e&1<<a||i&1<<a||null==o)&&(o=s>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);var u=r[a];return o<0&&(o+=u),o=s>0?Vv(0,o,u):Vv(-1,o,u-1)}function c_(e,t,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(t[i]>0||n[i]!==e[i])return!1;return!0}function p_(e,t){for(var n=e.length>0?e[e.length-1]:1,r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function h_(e,t,n){var r,a,i=e.shape.length;return(r="number"==typeof t?[t].concat(new Array(i-1).fill(0)):t.length<i?t.concat(new Array(i-t.length).fill(0)):t.slice()).forEach((function(e){Hv(-1!==e,(function(){return"slice() does not support negative begin indexing."}))})),a=(a=null==n?new Array(i).fill(-1):"number"==typeof n?[n].concat(new Array(i-1).fill(-1)):n.length<i?n.concat(new Array(i-n.length).fill(-1)):n).map((function(t,n){return t>=0?t:(Hv(-1===t,(function(){return"Negative size values should be exactly -1 but got "+t+" for the slice() size at index "+n+"."})),e.shape[n]-r[n])})),[r,a]}function d_(e,t,n,r,a,i,o,s,u){var l;if(null==r?(l=new Array(t.length)).fill(1):l=r,null!=o&&0!=(o&o-1))throw new Error("Multiple ellipses in slice is not allowed.");for(var c=!1,p={dims:l.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:l.slice(),beginMask:a,endMask:i,ellipsisMask:o,newAxisMask:s,shrinkAxisMask:u},h=0;h<p.dims;h++)c&&0!=(1<<h&s)&&p.numAddAxisAfterEllipsis++,1<<h&o&&(c=!0);c||(p.ellipsisMask|=1<<p.dims,p.dims++);var d={dims:e.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};!function(e,t){t.beginMask=0,t.endMask=0,t.shrinkAxisMask=0;var n=0;t.beginValid=null!=e.begin,t.endValid=null!=e.end,t.begin=new Array(t.dims),t.end=new Array(t.dims),t.strides=new Array(t.dims),t.finalShapeGatherIndices=[],t.finalShapeGatherIndicesSparse=[],t.inputShapeGatherIndicesSparse=new Array(t.dims);for(var r=0;r<e.dims;r++)if(1<<r&e.ellipsisMask)for(var a=Math.min(t.dims-(e.dims-r)+1+e.numAddAxisAfterEllipsis,t.dims);n<a;n++)t.begin[n]=0,t.end[n]=0,t.strides[n]=1,t.beginMask|=1<<n,t.endMask|=1<<n,t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(-1),t.inputShapeGatherIndicesSparse[n]=r;else if(1<<r&e.newAxisMask)t.finalShapeGatherIndices.push(-2),t.finalShapeGatherIndicesSparse.push(-1);else{if(n===t.begin.length)throw Error("Index out of range using input dim "+n+"; input has only "+t.dims+" dims, "+t.begin.length+".");null!=e.begin&&(t.begin[n]=e.begin[r]),null!=e.end&&(t.end[n]=e.end[r]),t.strides[n]=e.strides[r],e.beginMask&1<<r&&(t.beginMask|=1<<n),e.endMask&1<<r&&(t.endMask|=1<<n),e.shrinkAxisMask&1<<r?(t.finalShapeGatherIndices.push(-1),t.finalShapeGatherIndicesSparse.push(-1),t.shrinkAxisMask|=1<<n):(t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(r)),t.inputShapeGatherIndicesSparse[n]=r,n++}}(p,d);for(var f=!0,m=!0,v=!0,g=[],y=[],b=0;b<e.length;++b){if(0===d.strides[b])throw Error("strides["+b+"] must be non-zero");var x=!!(d.shrinkAxisMask&1<<b),w=e[b];if(-1!==w){var k=[d.beginMask&1<<b,d.endMask&1<<b],N=[d.strides[b]>0?0:-1,d.strides[b]>0?w:w-1];if(x&&d.strides[b]<=0)throw Error("only stride 1 allowed on non-range indexing.");v=v&&1===d.strides[b];var I=!!(d.beginMask&1<<b&&d.endMask&1<<b);if(d.beginValid&&d.endValid){if(x){var S=d.begin[b]<0?w+d.begin[b]:d.begin[b];if(d.begin[b]=S,d.end[b]=d.begin[b]+1,S<0||S>=w)throw Error("slice index "+d.begin[b]+" of dimension "+b+" out of bounds.")}else d.begin[b]=f_(d.begin[b],0,d.strides[b],w,k,N),d.end[b]=f_(d.end[b],1,d.strides[b],w,k,N);var T=1===d.strides[b]&&0===d.begin[b]&&d.end[b]===w;f=f&&T,m=m&&(0===b&&1===d.strides[b]||T)}else f=f&&1===d.strides[b]&&I,m=m&&(0===b&&1===d.strides[b]||I);var C=void 0,E=!1;if(d.beginValid&&d.endValid?(C=d.end[b]-d.begin[b],E=!0):x?(C=1,E=!0):I&&w>=0&&(C=d.strides[b]<0?-w:w,E=!0),E){var A=void 0;A=0===C||C<0!=d.strides[b]<0?0:Math.trunc(C/d.strides[b])+(C%d.strides[b]!=0?1:0),g.push(A)}else g.push(-1)}else g.push(x?1:-1)}for(var R=0;R<d.finalShapeGatherIndices.length;++R){var _=d.finalShapeGatherIndices[R];_>=0?y.push(g[_]):-2===_&&y.push(1)}var F=y.filter((function(e,t){return-2!==d.finalShapeGatherIndices[t]}));return{finalShapeSparse:F,finalShape:y,isIdentity:f,sliceDim0:m,isSimpleSlice:v,begin:d.begin,end:d.end,strides:d.strides}}function f_(e,t,n,r,a,i){if(a[t])return n>0?i[t]:i[t+1&1];var o=e<0?r+e:e;return o<i[0]?i[0]:o>i[1]?i[1]:o}var m_,v_={__proto__:null,assertParamsValid:e_,maskToAxes:function(e){for(var t=[],n=0;e>0;)1&e&&t.push(n),e/=2,n++;return t},computeOutShape:t_,stridesWithElidedDims:n_,getNormalizedAxes:function(e,t,n,r,a,i,o,s,u){var l=e.length,c=new Array(l),p=new Array(l),h=new Array(l);if(t.length&&n>0){var d=t[0],f=n+1;c=i_(o,d,f,r,e),p=o_(s,d,f,a,e),h=n_(i,d,f,e)}else for(var m=0;m<l;m++)c[m]=u_(o,r,i,e,m,u),p[m]=l_(s,a,i,e,m,u),h[m]=s_(i,m,u);return{begin:c,end:p,strides:h}},startIndicesWithElidedDims:i_,stopIndicesWithElidedDims:o_,stridesForAxis:s_,startForAxis:u_,stopForAxis:l_,isSliceContinous:c_,computeFlatOffset:p_,parseSliceParams:h_,sliceInfo:d_},g_="4.3.0",y_=function(){function e(){}return e.sgd=function(e){return new xR(e)},e.momentum=function(e,t,n){return void 0===n&&(n=!1),new wR(e,t,n)},e.rmsprop=function(e,t,n,r,a){return void 0===t&&(t=.9),void 0===n&&(n=0),void 0===r&&(r=null),void 0===a&&(a=!1),new kR(e,t,n,r,a)},e.adam=function(e,t,n,r){return void 0===e&&(e=.001),void 0===t&&(t=.9),void 0===n&&(n=.999),void 0===r&&(r=null),new yR(e,t,n,r)},e.adadelta=function(e,t,n){return void 0===e&&(e=.001),void 0===t&&(t=.95),void 0===n&&(n=null),new vR(e,t,n)},e.adamax=function(e,t,n,r,a){return void 0===e&&(e=.002),void 0===t&&(t=.9),void 0===n&&(n=.999),void 0===r&&(r=null),void 0===a&&(a=0),new bR(e,t,n,r,a)},e.adagrad=function(e,t){return void 0===t&&(t=.1),new gR(e,t)},e}(),b_=y_,x_="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:function(e){return e()};function w_(){return new Promise((function(e){return x_((function(){return e()}))}))}function k_(e,t){var n=e[0].length;e.forEach((function(e,t){Hv(e.length===n,(function(){return"Error in concat"+n+"D: rank of tensors["+t+"] must be the same as the rank of the rest ("+n+")"}))})),Hv(t>=0&&t<n,(function(){return"Error in concat"+n+"D: axis must be between 0 and "+(n-1)+"."}));var r=e[0];e.forEach((function(e,a){for(var i=0;i<n;i++)Hv(i===t||e[i]===r[i],(function(){return"Error in concat"+n+"D: Shape of tensors["+a+"] ("+e+") does not match the shape of the rest ("+r+") along the non-concatenated axis "+a+"."}))}))}function N_(e,t){for(var n=e[0].slice(),r=1;r<e.length;r++)n[t]+=e[r][t];return n}function I_(e,t,n){var r=new Array;if(null==n&&null==t)return r;if(null==t)for(;r.length<e+n.length;)r.push(-1);else r=t.slice();if(null==n)return r;if(e+n.length!==r.length)throw new Error("rt input.shape and shape="+t+" are incompatible: rt input.rank = "+(e+n.length)+", but shape.rank = "+r.length);for(var a=1;a<n.length;++a){var i=n[a],o=r[r.length-n.length+a],s=r[o];if(i>=0)if(s>=0){if(s!==i)throw new Error("rt input.shape and shape="+t+" are incompatible: rt input.shape["+(a+e)+"] = "+i+" but shape["+(a+e)+"] = "+s)}else r[o]=i}return r}function S_(e){for(var t,n={FIRST_DIM_SIZE:m_.FIRST_DIM_SIZE,VALUE_ROWIDS:m_.VALUE_ROWIDS,ROW_LENGTHS:m_.ROW_LENGTHS,ROW_SPLITS:m_.ROW_SPLITS,ROW_LIMITS:m_.ROW_LIMITS,ROW_STARTS:m_.ROW_STARTS},r=[],a=Lv(e);!(t=a()).done;){var i=t.value;if(!(i in n))break;r.push(n[i])}return r}function T_(e){return 0===e.length?0:e[0]===m_.FIRST_DIM_SIZE?e.length-1:e.length}function C_(e,t){if(null!=e&&null!=t){var n=e.length,r=t.length;if(n>=r)throw new Error("defaultValue.shape="+e+" and ragged tensor flatValues.shape="+t+", are incompatible: defaultValue.rank = "+n+" must be less than ragged tensor input flatValues.rank = "+r+")");for(var a=0;a<Math.min(n,r-1);++a){var i=e[a],o=t[a+1];if(i>=0&&o>=0&&1!==i&&i!==o)throw new Error("defaultValue.shape="+e+", and ragged tensor input flatValues.shape="+t+" are incompatible: defaultValue.shape["+(a-e.length)+"] = "+i+" but ragged tensor input.flatValues.shape["+(a-e.length)+"] = "+o)}}}!function(e){e[e.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",e[e.VALUE_ROWIDS=1]="VALUE_ROWIDS",e[e.ROW_LENGTHS=2]="ROW_LENGTHS",e[e.ROW_SPLITS=3]="ROW_SPLITS",e[e.ROW_LIMITS=4]="ROW_LIMITS",e[e.ROW_STARTS=5]="ROW_STARTS"}(m_||(m_={}));function E_(e){return e<=30?e:mg(e,Math.floor(Math.sqrt(e)))}function A_(e,t,n){return[n*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}function R_(e,t,n,r){void 0===r&&(r=!0);var a=[];if(r)(a=a.concat(t.slice(0))).push(e[0]/n),a=a.concat(e.slice(1));else{a=a.concat(e[0]);for(var i=t.length,o=0;o<i;++o)a=a.concat([e[o+1]/t[o],t[o]]);a=a.concat(e.slice(i+1))}return a}function __(e,t,n){void 0===n&&(n=!0);var r=[];if(n){r.push(t);for(var a=t+1;a<e;++a)a<=2*t?(r.push(a),r.push(a-(t+1))):r.push(a)}else{for(var i=[],o=[],s=1;s<e;++s)s>=2*t+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 F_(e,t,n,r){void 0===r&&(r=!0);var a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(var i=1;i<e.length;++i)i<=t.length?r?a.push(t[i-1]*e[i]):a.push(e[i]/t[i-1]):a.push(e[i]);return a}function O_(e,t){for(var n=[0],r=0;r<t;++r)n.push(e[r][0]);return n}function D_(e,t,n){for(var r=e.slice(0,1),a=0;a<n;++a)r.push(e[a+1]-t[a][0]-t[a][1]);return r}var M_=1.7580993408473768,L_=1.0507009873554805,z_=.3275911,P_=.254829592,B_=-.284496736,W_=1.421413741,V_=-1.453152027,U_=1.061405429;function G_(e,t){if(e.length!==t.length)throw new Error("Cannot merge real and imag arrays of different lengths. real:"+e.length+", imag: "+t.length+".");for(var n=new Float32Array(2*e.length),r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}function j_(e){for(var t=new Float32Array(e.length/2),n=new Float32Array(e.length/2),r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}}function H_(e){for(var t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t),a=0;a<e.length;a+=4)n[Math.floor(a/4)]=e[a],r[Math.floor(a/4)]=e[a+1];return{real:n,imag:r}}function q_(e){for(var t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t),a=2;a<e.length;a+=4)n[Math.floor(a/4)]=e[a],r[Math.floor(a/4)]=e[a+1];return{real:n,imag:r}}function K_(e,t){return{real:e[2*t],imag:e[2*t+1]}}function X_(e,t,n,r){e[2*r]=t,e[2*r+1]=n}function Y_(e,t){for(var n=new Float32Array(e/2),r=new Float32Array(e/2),a=0;a<Math.ceil(e/2);a++){var i=(t?2:-2)*Math.PI*(a/e);n[a]=Math.cos(i),r[a]=Math.sin(i)}return{real:n,imag:r}}function J_(e,t,n){var r=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(r),imag:Math.sin(r)}}var Z_="->",Q_=/->/g;function $_(e,t){var n=((e=e.replace(/\s/g,"")).length-e.replace(Q_,"").length)/Z_.length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error('Equation must contain exactly one arrow ("->").');var r=e.split(Z_),a=r[0],i=r[1];Hv(-1===a.indexOf("..."),(function(){return'The ellipsis notation ("...") is not supported yet.'}));var o=a.split(","),s=o.length;if(t!==s)throw new Error("Expected "+s+" input tensors, received "+t);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");for(var u=[],l=function(e){var t=i[e];if(!o.some((function(e){return-1!==e.indexOf(t)})))throw new Error("Output subscripts contain the label "+t+" not present in the input subscripts.");-1===u.indexOf(t)&&u.push(t)},c=0;c<i.length;++c)l(c);for(var p=0;p<a.length;++p){var h=a[p];-1===u.indexOf(h)&&","!==h&&u.push(h)}for(var d=new Array(o.length),f=0;f<s;++f){if(new Set(o[f].split("")).size!==o[f].length)throw new Error("Found duplicate axes in input component "+o[f]+". Support for duplicate axes in input is not implemented yet.");d[f]=[];for(var m=0;m<o[f].length;++m)d[f].push(u.indexOf(o[f][m]))}for(var v=u.length,g=[],y=i.length;y<v;++y)g.push(y);return{allDims:u,summedDims:g,idDims:d}}function eF(e,t){var n=new Array(e);n.fill(-1);for(var r=0;r<t.length;++r)n[t[r]]=r;for(var a=[],i=0;i<e;++i)-1===n[i]&&a.push(i);return{permutationIndices:n=n.filter((function(e){return-1!==e})),expandDims:a}}function tF(e,t,n){for(var r=new Array(e),a=function(e){for(var a=n[e].shape,i=function(n){void 0===r[t[e][n]]?r[t[e][n]]=a[n]:Hv(r[t[e][n]]===a[n],(function(){return"Expected dimension "+r[t[e][n]]+" at axis "+n+" of input shaped "+JSON.stringify(a)+", but got dimension "+a[n]}))},o=0;o<t[e].length;++o)i(o)},i=0;i<n.length;++i)a(i)}function nF(e,t){var n,r=e,a=[];0===e.length&&r.push(-1),n=e.length+1;for(var i=0;i<n;++i)a.push([]);for(var o=[],s=0;s<r.length;++s)for(var u,l=Lv(aF(t,r[s]));!(u=l()).done;){var c=u.value;-1===o.indexOf(c)&&(a[s].push(c),o.push(c))}return{path:r,steps:a}}function rF(e){return e.every((function(e,t){return e===t}))}function aF(e,t){for(var n=[],r=0;r<e.length;++r)0!==e[r].length&&-1===e[r].indexOf(t)&&-1!==t||n.push(r);return n}function iF(e,t,n){void 0===n&&(n=0);var r=[];if("number"==typeof t)Hv(e.shape[n]%t==0,(function(){return"Number of splits must evenly divide the axis."})),r=new Array(t).fill(e.shape[n]/t);else{var a=t.reduce((function(e,t){return-1===t&&(e+=1),e}),0);Hv(a<=1,(function(){return"There should be only one negative value in split array."}));var i=t.indexOf(-1);if(-1!==i){var o=t.reduce((function(e,t){return t>0?e+t:e}));t[i]=e.shape[n]-o}Hv(e.shape[n]===t.reduce((function(e,t){return e+t})),(function(){return"The sum of sizes must match the size of the axis dimension."})),r=t}return r}function oF(e){return"Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = "+e}function sF(e,t){return"indices("+e+", 0) is invalid: "+t+" < 0"}function uF(e,t,n){return"indices("+e+", 0) is invalid: "+t+" >= "+n}function lF(e,t){return"only one output dimension may be -1, not both "+e+" and "+t}function cF(e,t){return"size "+e+" must be non-negative, not "+t}function pF(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function hF(e,t){return"Input to reshape is a SparseTensor with "+Xv(e)+"\n dense values, but the requested shape requires a multiple of "+Xv(t)+". inputShape="+e+" outputShape= "+t}function dF(e,t){return"Input to reshape is a tensor with "+Xv(e)+" dense values, but the requested shape has "+Xv(t)+". inputShape="+e+" outputShape="+t}function fF(){return"segment ids must be >= 0"}function mF(){return"segment ids are not increasing"}function vF(e,t){return"Segment id "+e+" out of range [0, "+t+"), possibly because segmentIds input is not sorted."}function gF(e,t,n){return"Bad: indices["+e+"] == "+t+" out of range [0, "+n+")"}function yF(e,t){var n,r=!1;for(e<=30?(n=e,r=!0):n=mg(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=mg(e,n+1);return n}function bF(e,t,n){for(var r=[],a=e.length,i=0;i<a;i++)i!==t?r.push(e[i]):r.push(n);return r}function xF(e,t,n,r){var a=t.shape.length,i=e.shape.length;if(0!==r&&(r<-a||r>a))throw new Error("Expect batchDims in the range of [-"+a+", "+a+"], but got "+r);if(r<0&&(r+=a),r>i)throw new Error("batchDims ("+r+") must be less than rank(x) (\n "+i+").");if(n<r)throw new Error("batchDims ("+r+") must be less than or equal to axis ("+n+").");for(var o=0;o<r;++o)if(e.shape[o]!==t.shape[o])throw new Error("x.shape["+o+"]: "+e.shape[o]+" should be equal to indices.shape["+o+"]: "+t.shape[o]+".");for(var s=e.shape[n],u=[],l=1,c=1,p=1,h=0;h<r;++h)u.push(e.shape[h]),l*=e.shape[h];for(var d=r;d<n;d++)u.push(e.shape[d]),c*=e.shape[d];for(var f=r;f<a;f++)u.push(t.shape[f]);for(var m=n+1;m<i;m++)u.push(e.shape[m]),p*=e.shape[m];return{batchSize:l,sliceSize:p,outerSize:c,dimSize:s,outputShape:u}}function wF(e){try{return e.map((function(e){return jw(e)}))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8, error: "+e)}}function kF(e){return e.map((function(e){return Gw(e)}))}var NF={__proto__:null,slice_util:v_,segment_util:{__proto__:null,segOpComputeOptimalWindowSize:yF,computeOutShape:bF,collectGatherOpShapeInfo:xF},fromUint8ToStringArray:wF,fromStringArrayToUint8:kF,upcastType:dk,axesAreInnerMostDims:LS,combineLocations:zS,computeOutAndReduceShapes:PS,expandShapeToKeepDim:BS,assertAxesAreInnerMostDims:WS,getAxesPermutation:VS,getUndoAxesPermutation:US,getInnerMostAxes:GS,getBroadcastDims:IS,getReductionAxes:SS,assertAndGetBroadcastShape:TS,assertParamsConsistent:k_,computeOutShape:N_,computeDilation2DInfo:NI,computePool2DInfo:II,computePool3DInfo:SI,computeConv2DInfo:TI,computeConv3DInfo:CI,computeDefaultPad:EI,tupleValuesAreOne:OI,eitherStridesOrDilationsAreOne:DI,stridesOrDilationsArePositive:MI,convertConv2DDataFormat:LI,checkPadOnDimRoundingMode:zI,getFusedDyActivation:YE,getFusedBiasGradient:JE,applyActivation:ZE,shouldFuse:QE,get RowPartitionType(){return m_},combineRaggedTensorToTensorShapes:I_,getRowPartitionTypesHelper:S_,getRaggedRank:T_,validateDefaultValueShape:C_,PARALLELIZE_THRESHOLD:30,computeOptimalWindowSize:E_,getImageCenter:A_,getReshaped:R_,getPermuted:__,getReshapedPermuted:F_,getSliceBeginCoords:O_,getSliceSize:D_,prepareAndValidate:QR,validateUpdateShape:wE,validateInput:kE,calculateShapes:NE,SELU_SCALEALPHA:M_,SELU_SCALE:L_,ERF_P:z_,ERF_A1:P_,ERF_A2:B_,ERF_A3:W_,ERF_A4:V_,ERF_A5:U_,warn:qx,log:function(){var e;Fg().getBool("IS_TEST")||Fg().getBool("PROD")||(e=console).log.apply(e,arguments)},mergeRealAndImagArrays:G_,splitRealAndImagArrays:j_,complexWithEvenIndex:H_,complexWithOddIndex:q_,getComplexWithIndex:K_,assignToTypedArray:X_,exponents:Y_,exponent:J_,decodeEinsumEquation:$_,getEinsumPermutation:eF,checkEinsumDimSizes:tF,getEinsumComputePath:nF,isIdentityPermutation:rF,prepareSplitSize:iF,getSparseFillEmptyRowsIndicesDenseShapeMismatch:oF,getSparseFillEmptyRowsNegativeIndexErrorMessage:sF,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:uF,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:lF,getSparseReshapeNegativeOutputDimErrorMessage:cF,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:pF,getSparseReshapeInputOutputMultipleErrorMessage:hF,getSparseReshapeInputOutputMismatchErrorMessage:dF,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:fF,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:mF,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:vF,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:gF},IF={__proto__:null,nonMaxSuppressionV3Impl:gA,nonMaxSuppressionV4Impl:yA,nonMaxSuppressionV5Impl:bA,whereImpl:OE};!function(){for(var e,t=Lv(NR);!(e=t()).done;){dR(e.value)}}();var SF={kernelName:Mg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(e,hE(XN(n,"float32"),-1))}}}},TF={kernelName:Lg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){var t=YS(XN(n,"float32")),r=XS(TT(KS(1),t));return NT(uI(e,r))}}}},CF={kernelName:zg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){var t=XS(TT(YS(XN(n,"float32")),1));return uI(e,t)}}}},EF={kernelName:Pg,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=TS(n.shape,r.shape);return{a:function(){var t=e,r=SS(n.shape,a);return r.length>0&&(t=JS(t,r)),PI(t,n.shape)},b:function(){var t=e,n=SS(r.shape,a);return n.length>0&&(t=JS(t,n)),PI(t,r.shape)}}}},AF={kernelName:Bg,saveAllInputs:!0,gradFunc:function(e,t){var n={};return t.forEach((function(t,r){n[r]=function(){return e.clone()}})),n}},RF={kernelName:Ug,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return RS(n)}}}},_F={kernelName:Gg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return RS(n)}}}},FF={kernelName:jg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return uI(e,XS(TT(KS(1),YS(XN(n,"float32")))))}}}},OF={kernelName:Hg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){var t=XS(oI(KS(1),YS(XN(n,"float32"))));return uI(e,t)}}}},DF={kernelName:Xg,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=TS(n.shape,r.shape);return{a:function(){var t=oI(YS(n),YS(r)),i=lI(e,uI(r,t)),o=SS(n.shape,a);return o.length>0&&(i=JS(i,o)),PI(i,n.shape)},b:function(){var t=oI(YS(n),YS(r)),i=NT(lI(e,uI(n,t))),o=SS(r.shape,a);return o.length>0&&(i=JS(i,o)),PI(i,r.shape)}}}},MF={kernelName:qg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return uI(e,oI(YS(XN(n,"float32")),1))}}}},LF={kernelName:Kg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return uI(e,TT(KS(1),YS(XN(n,"float32"))))}}}};var zF=Wk({avgPool3dGrad_:function(e,t,n,r,a,i){var o=zk(e,"dy","avgPool3dGrad"),s=zk(t,"input","avgPool3dGrad"),u=o,l=s,c=!1;4===s.rank&&(c=!0,u=PI(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),l=PI(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),Hv(5===u.rank,(function(){return"Error in avgPool3dGrad: dy must be rank 5 but got rank "+u.rank+"."})),Hv(5===l.rank,(function(){return"Error in avgPool3dGrad: input must be rank 5 but got rank "+l.rank+"."})),zI("avgPool3dGrad",a,i);var p={dy:u,input:l},h={filterSize:n,strides:r,pad:a,dimRoundingMode:i},d=Ek.runKernel(Qg,p,h);return c?PI(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),PF={kernelName:Zg,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.filterSize,i=n.strides,o=n.pad,s=n.dimRoundingMode;return{x:function(){return zF(e,r,a,i,o,s)}}}};var BF=Wk({avgPoolGrad_:function(e,t,n,r,a){var i=zk(e,"dy","avgPoolGrad"),o=zk(t,"input","avgPoolGrad");Hv(o.rank===i.rank,(function(){return"Rank of input ("+o.rank+") does not match rank of dy ("+i.rank+")"}));var s=o,u=i,l=!1;3===o.rank&&(l=!0,s=PI(o,[1,o.shape[0],o.shape[1],o.shape[2]]),u=PI(i,[1,i.shape[0],i.shape[1],i.shape[2]])),Hv(4===u.rank,(function(){return"Error in avgPoolGrad: dy must be rank 4 but got rank "+u.rank+"."})),Hv(4===s.rank,(function(){return"Error in avgPoolGrad: input must be rank 4 but got rank "+s.rank+"."}));var c={dy:u,input:s},p={filterSize:n,strides:r,pad:a},h=Ek.runKernel(Jg,c,p);return l?PI(h,[h.shape[1],h.shape[2],h.shape[3]]):h}}),WF={kernelName:Yg,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.filterSize,i=n.strides,o=n.pad;return{x:function(){return BF(e,r,a,i,o)}}}},VF={kernelName:$g,inputsToSave:["a","b"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.transposeA,o=n.transposeB;return i||o?!i&&o?{a:function(){return UI(e,a,!1,!1)},b:function(){return UI(e,r,!0,!1)}}:i&&!o?{a:function(){return UI(a,e,!1,!0)},b:function(){return UI(r,e,!1,!1)}}:{a:function(){return UI(a,e,!0,!0)},b:function(){return UI(e,r,!0,!0)}}:{a:function(){return UI(e,a,!1,!0)},b:function(){return UI(r,e,!0,!1)}}}},UF={kernelName:ey,gradFunc:function(e,t,n){var r=n.blockShape,a=n.crops;return{x:function(){return iC(e,r,a)}}}},GF={kernelName:ny,gradFunc:function(e,t,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=[],l=0;l<o.length;l++)o[l]>1&&u.push(l);return{x:function(){return JS(e,u,!0)}}}},jF={kernelName:ay,gradFunc:function(e){return{x:function(){return e.clone()}}}},HF={kernelName:iy,gradFunc:function(e){return{x:function(){return RS(e)}}}},qF={kernelName:oy,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.clipValueMin,i=n.clipValueMax;return{x:function(){return AS(AT(uT(r,a),mT(r,i)),e,RS(e))}}}},KF={kernelName:uy,inputsToSave:["x"],gradFunc:SF.gradFunc},XF={kernelName:ly,saveAllInputs:!0,gradFunc:function(e,t,n){var r=t.map((function(e){return e.shape})),a=tg(n.axis,t[0].shape)[0],i=r.map((function(e){return e[a]}));return sE(e,i,a).map((function(e){return function(){return e}}))}},YF={kernelName:cy,inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.dilations,o=n.strides,s=n.pad,u=n.dataFormat;return Hv(OI(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 cS(r.shape,e,a,o,s,u)},filter:function(){return XE(r,e,a.shape,o,s,u)}}}},JF={kernelName:hy,inputsToSave:["dy","filter"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.strides,o=n.pad,s=n.dataFormat,u=n.dimRoundingMode;return{dy:function(){return uS(e,a,i,o,s,1,u)},filter:function(){return XE(e,r,a.shape,i,o,s,u)}}}};var ZF=Wk({conv3DBackpropFilter_:function(e,t,n,r,a){var i=e;4===e.rank&&(i=PI(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));var o=t;4===o.rank&&(o=PI(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),Hv(5===i.rank,(function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+i.shape+"."})),Hv(5===o.rank,(function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+o.shape+"."})),Hv(5===n.length,(function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+n+"."})),Hv(i.shape[4]===n[3],(function(){return"Error in conv3dDerFilter: depth of input "+i.shape[4]+") must match input depth in filter ("+n[3]+"."})),Hv(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,dy:o},u={strides:r,pad:a,filterShape:n};return Ek.runKernel(fy,s,u)}}),QF={kernelName:dy,inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=n.dilations,a=n.strides,i=n.pad;Hv(OI(r),(function(){return"Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+r+"'"}));var o=t[0],s=t[1];return{x:function(){return dS(o.shape,e,s,a,i)},filter:function(){return ZF(o,e,s.shape,a,i)}}}},$F={kernelName:vy,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(NT(ZC(XN(n,"float32"))),e)}}}},eO={kernelName:gy,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(QC(XN(n,"float32")),e)}}}},tO={kernelName:by,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.axis,i=n.exclusive,o=n.reverse;return{x:function(){var t=VS([a],r.rank),n=yS(e,a,i,!o);return null!=t&&(n=PE(n,t)),n}}}},nO={kernelName:Ny,inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=n.dilations,a=n.strides,i=n.pad,o=n.dimRoundingMode,s=null==r?[1,1]:r;Hv(OI(s),(function(){return"Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '"+s+"'"}));var u=t[0],l=t[1];return Hv(4===u.rank,(function(){return"Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank "+u.rank+"."})),Hv(4===l.rank,(function(){return"Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank "+l.rank+"."})),Hv(u.shape[3]===l.shape[2],(function(){return"Error in gradient of depthwiseConv2d: number of input channels ("+u.shape[3]+") must match the inChannels dimension in filter "+l.shape[2]+"."})),Hv(DI(a,s),(function(){return"Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides "+a+" and dilations '"+s+"'."})),zI("depthwiseConv2d",i,o),{x:function(){return tA(u.shape,e,l,a,i,s,o)},filter:function(){return eA(u,e,l.shape,a,i,s,o)}}}},rO={kernelName:Cy,inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i={x:r,filter:a,dy:e},o={x:r,filter:a,dy:e};return{x:function(){return Ek.runKernel(Ey,i,n)},filter:function(){return Ek.runKernel(Ay,o,n)}}}},aO={kernelName:Fy,outputsToSave:[!0],gradFunc:function(e,t){var n={dy:e,y:t[0]};return{x:function(){return Ek.runKernel(Oy,n)}}}},iO={kernelName:Dy,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0],r=lI(eT(NT(YS(n))),2/Math.sqrt(Math.PI));return{x:function(){return lI(e,r)}}}},oO={kernelName:Ly,outputsToSave:[!0],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(e,n)}}}},sO={kernelName:zy,inputsToSave:["input"],gradFunc:function(e,t){var n=t[0];return{input:function(){return PI(e,n.shape)}}}},uO={kernelName:Py,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(e,eT(n))}}}},lO={kernelName:Uy,gradFunc:function(e){return{x:function(){return RS(e)}}}},cO={kernelName:Gy,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=TS(n.shape,r.shape);return{a:function(){var t=uI(e,XN(r,"float32")),i=SS(n.shape,a);return i.length>0?PI(JS(t,i),n.shape):t},b:function(){var t=lI(e,XN(n,"float32")),i=SS(r.shape,a);i.length>0&&(t=PI(JS(t,i),r.shape));var o=YS(r);return NT(uI(t,XN(o,"float32")))}}}},pO={kernelName:jy,inputsToSave:["x","mean","variance","scale"],gradFunc:function(e,t,n){var r=n.varianceEpsilon,a=t[0],i=t[1],o=t[2],s=t[3],u=null==s?KS(1):s,l=SS(i.shape,a.shape),c=[];if(1===i.rank){for(var p=0;p<a.shape.length-1;++p)c.push(a.shape[p]);c.push(1)}var h=TT(a,i),d=lI(e,u),f=HC(oI(o,KS(r))),m=lI(lI(lI(f,f),f),KS(-.5));return{x:function(){return 1===i.rank?PI(lI(lI(e,rT(PI(f,[1,1,1,i.shape[0]]),c)),u),a.shape):PI(lI(lI(e,f),u),a.shape)},mean:function(){var e=lI(lI(f,KS(-1)),d);return 1===i.rank&&(e=JS(e,l)),PI(e,i.shape)},variance:function(){var e=lI(lI(m,h),d);return 1===i.rank&&(e=JS(e,l)),PI(e,i.shape)},scale:function(){var t=lI(h,f),n=lI(e,t);return 1===i.rank&&(n=JS(n,l)),PI(n,i.shape)},offset:function(){var t=e;return 1===i.rank&&(t=JS(t,l)),PI(t,i.shape)}}}},hO={kernelName:Hy,inputsToSave:["x","indices"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.axis,o=tg(i,r.shape)[0];return{x:function(){var t=r.shape,n=a.size,s=t.slice(0,o),u=s.length,l=t.slice(i,t.length).slice(1),c=l.length,p=dO(0,u),h=dO(u+1,u+1+c),d=fO([s,[n],l]),f=PI(e,d),m=PI(a,[n]),v=fO([[u],p,h]),g=PE(f,v),y=AE(g,m,r.shape[o]),b=US(v);return y=PE(y,b)},indices:function(){return a}}}};function dO(e,t){for(var n=[],r=e;r<t;++r)n.push(r);return n}function fO(e){for(var t=[],n=0;n<e.length;++n)for(var r=0;r<e[n].length;++r)t.push(e[n][r]);return t}var mO={kernelName:Xy,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1];return{a:function(){return RS(n)},b:function(){return RS(r)}}}},vO={kernelName:Yy,gradFunc:function(e){return{x:function(){return XN(e,"float32")}}}},gO={kernelName:Qy,gradFunc:function(e){return{x:function(){return RS(e)}}}},yO={kernelName:$y,gradFunc:function(e){return{x:function(){return RS(e)}}}},bO={kernelName:eb,gradFunc:function(e){return{x:function(){return RS(e)}}}},xO={kernelName:tb,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.alpha,i=sT(r,0);return{x:function(){return AS(i,e,lI(e,a))}}}},wO={kernelName:ob,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return uI(e,oI(n,1))}}}},kO={kernelName:ib,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return uI(e,XN(n,"float32"))}}}},NO={kernelName:cb,inputsToSave:[],outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=n.axis;return{logits:function(){var t=eT(r);return TT(e,lI(JS(e,a,!0),t))}}}};var IO=Wk({localResponseNormalizationBackprop_:function(e,t,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:e,y:t,dy:n},u={depthRadius:r,bias:a,alpha:i,beta:o};return Ek.runKernel(hb,s,u)}}),SO={kernelName:pb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.depthRadius,o=n.bias,s=n.alpha,u=n.beta;return{x:function(){return IO(r,a,e,i,o,s,u)}}}};function TO(e,t,n,r){return t.rank<n.rank&&(t=PI(t,BS(t.shape,r))),e.rank<n.rank&&(e=PI(e,BS(e.shape,r))),{x:function(){return lI(e,XN(ES(n,t),e.dtype))}}}var CO={kernelName:db,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=n.reductionIndices,a=t[0],i=TO(e,t[1],a,tg(r,a.shape));return{x:function(){return i.x()}}}},EO={kernelName:fb,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1];return{a:function(){return lI(e,XN(uT(n,r),"float32"))},b:function(){return lI(e,XN(fT(n,r),"float32"))}}}};var AO=Wk({maxPool3dGrad_:function(e,t,n,r,a,i,o){var s=zk(e,"dy","maxPool3dGrad"),u=zk(t,"input","maxPool3dGrad"),l=zk(n,"output","maxPool3dGrad"),c=s,p=u,h=l,d=!1;4===u.rank&&(d=!0,c=PI(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]]),p=PI(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]]),h=PI(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]])),Hv(5===c.rank,(function(){return"Error in maxPool3dGrad: dy must be rank 5 but got rank "+c.rank+"."})),Hv(5===p.rank,(function(){return"Error in maxPool3dGrad: input must be rank 5 but got rank "+p.rank+"."})),Hv(5===h.rank,(function(){return"Error in maxPool3dGrad: output must be rank 5 but got rank "+h.rank+"."})),zI("maxPool3dGrad",i,o);var f={dy:c,input:p,output:h},m={filterSize:r,strides:a,pad:i,dimRoundingMode:o},v=Ek.runKernel(yb,f,m);return d?PI(v,[v.shape[1],v.shape[2],v.shape[3],v.shape[4]]):v}}),RO={kernelName:gb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.filterSize,o=n.strides,s=n.pad,u=n.dimRoundingMode;return{x:function(){return AO(e,r,a,i,o,s,u)}}}};var _O=Wk({maxPoolGrad_:function(e,t,n,r,a,i,o){var s=zk(e,"dy","maxPoolGrad"),u=zk(t,"input","maxPoolGrad"),l=zk(n,"output","maxPoolGrad");Hv(u.rank===s.rank,(function(){return"Rank of input ("+u.rank+") does not match rank of dy ("+s.rank+")"})),Hv(4===s.rank,(function(){return"Error in maxPoolGrad: dy must be rank 4 but got rank "+s.rank+"."})),Hv(4===u.rank,(function(){return"Error in maxPoolGrad: input must be rank 4 but got rank "+u.rank+"."})),zI("maxPoolGrad",i,o);var c={dy:s,input:u,output:l},p={filterSize:r,strides:a,pad:i,dimRoundingMode:o};return Ek.runKernel(vb,c,p)}}),FO={kernelName:mb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.filterSize,o=n.strides,s=n.pad;return{x:function(){return _O(e,r,a,i,o,s)}}}},OO={kernelName:Nb,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.paddings.map((function(e){return e[0]}));return{x:function(){return jI(e,a,r.shape)}}}},DO={kernelName:Mb,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.paddings.map((function(e){return e[0]}));return{x:function(){return jI(e,a,r.shape)}}}},MO={kernelName:Lb,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:function(e,t){var n=t[0],r=t[1],a=t[2],i=n,o=r,s=TS(i.shape,o.shape);return{a:function(){var t=XN(o,"float32"),n=lI(e,lI(t,qS(i,TT(t,KS(1))))),r=SS(i.shape,s);return r.length>0&&(n=JS(n,r)),PI(n,i.shape)},b:function(){var t=sT(i,0),n=AS(t,yT(i),RS(i)),r=lI(e,lI(a,n)),u=SS(o.shape,s);return u.length>0&&(r=JS(r,u)),PI(r,o.shape)}}}};function LO(e,t,n){var r=e.shape.length,a=r-n.length,i=VS(n,r),o=e;null!=i&&(o=PE(e,i));var s=o.shape.slice(),u=s.splice(r-n.length,n.length).reduce((function(e,t){return e*t}),1);s.push(u);var l=function(e,t,n){var r=e.shape.slice();r[n]=1;var a=PI(t,r),i=gS(e,n,!0,!1),o=gS(e,n,!0,!0),s=lI(i,o);return lI(a,s)}(o.reshape(s),t,a);if(l=l.reshape(o.shape),null!=i){var c=US(i);l=PE(l,c)}return l}var zO={kernelName:ix,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){var t=sT(n,KS(0)),r=KS(M_),a=KS(L_),i=lI(e,a),o=lI(lI(e,r),eT(XN(n,"float32")));return AS(t,i,o)}}}},PO={kernelName:fx,gradFunc:function(e,t,n){var r=n.blockShape,a=n.paddings;return{x:function(){return KI(e,r,a)}}}},BO={kernelName:mx,gradFunc:function(e,t,n){var r=n.axis;return{x:function(){return VI(e,r)}}}},WO={kernelName:Fx,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.reps;return{x:function(){var t=RS(r);if(1===r.rank)for(var n=0;n<a[0];++n)t=oI(t,jI(e,[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)t=oI(t,jI(e,[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 l=0;l<a[2];++l)t=oI(t,jI(e,[s*r.shape[0],u*r.shape[1],l*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 c=0;c<a[0];++c)for(var p=0;p<a[1];++p)for(var h=0;h<a[2];++h)for(var d=0;d<a[3];++d)t=oI(t,jI(e,[c*r.shape[0],p*r.shape[1],h*r.shape[2],d*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]))}return t}}}};for(var VO=0,UO=[SF,TF,CF,EF,AF,RF,_F,FF,OF,DF,MF,LF,PF,WF,VF,UF,GF,jF,HF,qF,KF,XF,JF,YF,QF,$F,eO,tO,nO,rO,{kernelName:Ry,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=TS(n.shape,r.shape);return{a:function(){var t=uI(e,XN(r,"float32")),i=SS(n.shape,a);return i.length>0?PI(JS(t,i),n.shape):t},b:function(){var t=lI(e,XN(n,"float32")),i=SS(r.shape,a);i.length>0&&(t=PI(JS(t,i),r.shape));var o=YS(r);return NT(uI(t,XN(o,"float32")))}}}},aO,iO,oO,sO,uO,cO,lO,pO,hO,mO,vO,gO,yO,bO,xO,wO,kO,NO,SO,CO,CO,EO,RO,FO,{kernelName:xb,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=tg(n.axis,r.shape),i=Xv(PS(r.shape,a)[1]);return{x:function(){var t=r.shape.slice();a.forEach((function(e){t[e]=1}));var n=PI(e,t);return uI(lI(n,UT(r.shape,"float32")),i)}}}},{kernelName:wb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=n.axis,a=t[0],i=TO(e,t[1],a,tg(r,a.shape));return{x:function(){return i.x()}}}},{kernelName:kb,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1];return{a:function(){return lI(e,XN(mT(n,r),"float32"))},b:function(){return lI(e,XN(sT(n,r),"float32"))}}}},OO,{kernelName:Ib,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=TS(n.shape,r.shape);return{a:function(){var t=SS(n.shape,a);return t.length>0?PI(JS(e,t),n.shape):e},b:function(){var t=lI(e,NT(iT(uI(n,r)))),i=SS(r.shape,a);return i.length>0?PI(JS(t,i),r.shape):t}}}},{kernelName:Tb,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=TS(n.shape,r.shape);return{a:function(){var t=lI(e,XN(r,"float32")),i=SS(n.shape,a);return i.length>0?PI(JS(t,i),n.shape):t},b:function(){var t=lI(e,XN(n,"float32")),i=SS(r.shape,a);return i.length>0?PI(JS(t,i),r.shape):t}}}},{kernelName:Cb,gradFunc:function(e){return{x:function(){return NT(e)}}}},{kernelName:Ob,inputsToSave:["indices"],gradFunc:function(e,t){var n=t[0];return{indices:function(){return VT(n.shape,"float32")}}}},{kernelName:Fb,gradFunc:function(e){return{x:function(){return RS(e)}}}},{kernelName:Db,saveAllInputs:!0,gradFunc:function(e,t,n){var r=n.axis;return RE(e,r).map((function(e){return function(){return e}}))}},DO,DO,MO,{kernelName:zb,inputsToSave:["x","alpha"],gradFunc:function(e,t){var n=t[0],r=t[1],a=sT(n,0);return{x:function(){return AS(a,e,lI(e,r))},alpha:function(){var t=AS(a,RS(e),lI(e,n)),i=SS(r.shape,e.shape);return i.length>0&&(t=JS(t,i)),PI(t,r.shape)}}}},{kernelName:Pb,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.axis,i=[];return i=null==a?r.shape.map((function(e,t){return t})):"number"==typeof a?[a]:a,{x:function(){return LO(r,e,i)}}}},{kernelName:jb,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return uI(e,NT(YS(n)))}}}},{kernelName:Zb,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0],r=lI(mT(n,6),hE(n));return{x:function(){return lI(e,XN(r,"float32"))}}}},{kernelName:Hb,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(e,XN(hE(n),"float32"))}}}},{kernelName:qb,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return PI(e,n.shape)}}}},{kernelName:Yb,inputsToSave:["images"],gradFunc:function(e,t,n){var r={dy:e,images:t[0]};return{images:function(){return Ek.runKernel(Jb,r,n)}}}},{kernelName:Kb,inputsToSave:["images"],gradFunc:function(e,t,n){var r={dy:e,images:t[0]};return{images:function(){return Ek.runKernel(Xb,r,n)}}}},{kernelName:Qb,gradFunc:function(e,t,n){var r=tg(n.dims,e.shape);return{x:function(){return BC(e,r)}}}},{kernelName:$b,gradFunc:function(e){return{x:function(){return RS(e)}}}},{kernelName:ex,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return NT(uI(e,lI(qS(n,1.5),2)))}}}},{kernelName:ax,inputsToSave:["condition"],gradFunc:function(e,t){var n=t[0];return{condition:function(){return XN(RS(n),"float32")},t:function(){return lI(e,XN(n,e.dtype))},e:function(){return lI(e,XN(RT(n),e.dtype))}}}},zO,{kernelName:cx,outputsToSave:[!0],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(e,lI(n,TT(KS(1),n)))}}}},{kernelName:lx,gradFunc:function(e){return{x:function(){return RS(e)}}}},{kernelName:sx,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(mS(XN(n,"float32")),e)}}}},{kernelName:ux,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(vS(XN(n,"float32")),e)}}}},{kernelName:ox,inputsToSave:["x"],gradFunc:function(e,t,n){for(var r=t[0],a=n.begin,i=n.size,o=r.shape,s=h_(r,a,i),u=s[0],l=s[1],c=[],p=0;p<e.rank;p++)c.push([u[p],o[p]-u[p]-l[p]]);return{x:function(){return eC(e,c)}}}},{kernelName:vx,outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=n.dim,i=lI(e,r);return{logits:function(){return TT(i,lI(JS(i,[a],true),r))}}}},{kernelName:px,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(e,GI(n))}}}},PO,PO,BO,BO,{kernelName:hx,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return uI(e,lI(XS(XN(n,"float32")),2))}}}},{kernelName:kx,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=KS(2);return{a:function(){return lI(e,lI(a,TT(n,r)))},b:function(){return lI(e,lI(a,TT(r,n)))}}}},{kernelName:Nx,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(e,lI(XN(n,"float32"),2))}}}},{kernelName:Wx,gradFunc:function(e){return{x:function(){return RS(e)}}}},{kernelName:Ax,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=TS(n.shape,r.shape);return{a:function(){var t=e,r=SS(n.shape,a);return r.length>0&&(t=JS(t,r)),PI(t,n.shape)},b:function(){var t=e,n=SS(r.shape,a);return n.length>0&&(t=JS(t,n)),PI(NT(t),r.shape)}}}},{kernelName:dx,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=r.shape.slice();tg(n.axis,r.shape).forEach((function(e){a[e]=1}));var i=PI(e,a),o=lI(i,UT(r.shape,"float32"));return{x:function(){return o}}}},{kernelName:Rx,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return uI(e,YS(mS(n)))}}}},{kernelName:_x,outputsToSave:[!0],gradFunc:function(e,t){var n=t[0];return{x:function(){return lI(TT(KS(1),YS(n)),e)}}}},WO,{kernelName:Mx,gradFunc:function(e,t,n){var r=US(n.perm);return{x:function(){return PE(e,r)}}}},{kernelName:zx,gradFunc:function(e,t,n){var r=n.axis;return{value:function(){return pE(e,r)}}}},{kernelName:Px,inputsToSave:["segmentIds"],gradFunc:function(e,t){var n=t[0];return{x:function(){return function(e,t){for(var n=BT(t,RS(t)),r=oT(e,n),a=uT(t,KS(0,"int32")),i=r.rank-a.rank,o=0;o<i;++o)a=tT(a,o+1);a=AT(a,UT(r.shape,"bool"));var s=RS(r);return AS(a,r,s)}(e,n)}}}},{kernelName:Bx,gradFunc:function(e){return{x:function(){return RS(e)}}}}];VO<UO.length;VO++){$x(UO[VO])}ik().prototype.abs=function(){return this.throwIfDisposed(),cI(this)},ik().prototype.acos=function(){return this.throwIfDisposed(),pI(this)},ik().prototype.acosh=function(){return this.throwIfDisposed(),hI(this)},ik().prototype.add=function(e){return this.throwIfDisposed(),oI(this,e)},ik().prototype.all=function(e,t){return this.throwIfDisposed(),fI(this,e,t)},ik().prototype.any=function(e,t){return this.throwIfDisposed(),mI(this,e,t)},ik().prototype.argMax=function(e){return this.throwIfDisposed(),vI(this,e)},ik().prototype.argMin=function(e){return this.throwIfDisposed(),gI(this,e)},ik().prototype.asScalar=function(){return this.throwIfDisposed(),Hv(1===this.size,(function(){return"The array must have only 1 element."})),PI(this,[])},ik().prototype.asType=function(e){return this.throwIfDisposed(),XN(this,e)},ik().prototype.as1D=function(){return this.throwIfDisposed(),PI(this,[this.size])},ik().prototype.as2D=function(e,t){return this.throwIfDisposed(),PI(this,[e,t])},ik().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),PI(this,[e,t,n])},ik().prototype.as4D=function(e,t,n,r){return this.throwIfDisposed(),PI(this,[e,t,n,r])},ik().prototype.as5D=function(e,t,n,r,a){return this.throwIfDisposed(),PI(this,[e,t,n,r,a])},ik().prototype.asin=function(){return this.throwIfDisposed(),yI(this)},ik().prototype.asinh=function(){return this.throwIfDisposed(),bI(this)},ik().prototype.atan=function(){return this.throwIfDisposed(),xI(this)},ik().prototype.atan2=function(e){return this.throwIfDisposed(),wI(this,e)},ik().prototype.atanh=function(){return this.throwIfDisposed(),kI(this)},ik().prototype.avgPool=function(e,t,n,r){return this.throwIfDisposed(),BI(this,e,t,n,r)},ik().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),KI(this,e,t)},ik().prototype.batchNorm=function(e,t,n,r,a){return this.throwIfDisposed(),XI(this,e,t,n,r,a)},ik().prototype.broadcastTo=function(e){return this.throwIfDisposed(),eS(this,e)},ik().prototype.cast=function(e){return this.throwIfDisposed(),XN(this,e)},ik().prototype.ceil=function(){return this.throwIfDisposed(),tS(this)},ik().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),rS(this,e,t)},ik().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof ak&&(e=[e]),VI([this].concat(e),t)},ik().prototype.conv1d=function(e,t,n,r,a,i){return this.throwIfDisposed(),lS(this,e,t,n,r,a,i)},ik().prototype.conv2dTranspose=function(e,t,n,r,a){return this.throwIfDisposed(),pS(this,e,t,n,r,a)},ik().prototype.conv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),uS(this,e,t,n,r,a,i)},ik().prototype.cos=function(){return this.throwIfDisposed(),mS(this)},ik().prototype.cosh=function(){return this.throwIfDisposed(),vS(this)},ik().prototype.cumprod=function(e,t,n){return this.throwIfDisposed(),gS(this,e,t,n)},ik().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),yS(this,e,t,n)},ik().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),xS(this,e,t)},ik().prototype.depthwiseConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),wS(this,e,t,n,r,a,i)},ik().prototype.dilation2d=function(e,t,n,r,a){return this.throwIfDisposed(),NS(this,e,t,n,r,a)},ik().prototype.divNoNan=function(e){return this.throwIfDisposed(),_S(this,e)},ik().prototype.div=function(e){return this.throwIfDisposed(),uI(this,e)},ik().prototype.dot=function(e){return this.throwIfDisposed(),FS(this,e)},ik().prototype.elu=function(){return this.throwIfDisposed(),DS(this)},ik().prototype.equal=function(e){return this.throwIfDisposed(),ES(this,e)},ik().prototype.erf=function(){return this.throwIfDisposed(),MS(this)},ik().prototype.euclideanNorm=function(e,t){return this.throwIfDisposed(),$S(this,e,t)},ik().prototype.exp=function(){return this.throwIfDisposed(),eT(this)},ik().prototype.expandDims=function(e){return this.throwIfDisposed(),tT(this,e)},ik().prototype.expm1=function(){return this.throwIfDisposed(),nT(this)},ik().prototype.fft=function(){return this.throwIfDisposed(),aE(this)},ik().prototype.flatten=function(){return this.throwIfDisposed(),PI(this,[this.size])},ik().prototype.floor=function(){return this.throwIfDisposed(),iT(this)},ik().prototype.floorDiv=function(e){return this.throwIfDisposed(),sI(this,e)},ik().prototype.gather=function(e,t,n){return this.throwIfDisposed(),oT(this,e,t,n)},ik().prototype.greaterEqual=function(e){return this.throwIfDisposed(),uT(this,e)},ik().prototype.greater=function(e){return this.throwIfDisposed(),sT(this,e)},ik().prototype.ifft=function(){return this.throwIfDisposed(),iE(this)},ik().prototype.irfft=function(){return this.throwIfDisposed(),oE(this)},ik().prototype.isFinite=function(){return this.throwIfDisposed(),cT(this)},ik().prototype.isInf=function(){return this.throwIfDisposed(),pT(this)},ik().prototype.isNaN=function(){return this.throwIfDisposed(),hT(this)},ik().prototype.leakyRelu=function(e){return this.throwIfDisposed(),dT(this,e)},ik().prototype.lessEqual=function(e){return this.throwIfDisposed(),mT(this,e)},ik().prototype.less=function(e){return this.throwIfDisposed(),fT(this,e)},ik().prototype.localResponseNormalization=function(e,t,n,r){return this.throwIfDisposed(),gT(this,e,t,n,r)},ik().prototype.logSigmoid=function(){return this.throwIfDisposed(),ST(this)},ik().prototype.logSoftmax=function(e){return this.throwIfDisposed(),CT(this,e)},ik().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),ET(this,e,t)},ik().prototype.log=function(){return this.throwIfDisposed(),yT(this)},ik().prototype.log1p=function(){return this.throwIfDisposed(),bT(this)},ik().prototype.logicalAnd=function(e){return this.throwIfDisposed(),AT(this,e)},ik().prototype.logicalNot=function(){return this.throwIfDisposed(),RT(this)},ik().prototype.logicalOr=function(e){return this.throwIfDisposed(),_T(this,e)},ik().prototype.logicalXor=function(e){return this.throwIfDisposed(),FT(this,e)},ik().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),UI(this,e,t,n)},ik().prototype.maxPool=function(e,t,n,r){return this.throwIfDisposed(),LT(this,e,t,n,r)},ik().prototype.max=function(e,t){return this.throwIfDisposed(),jS(this,e,t)},ik().prototype.maximum=function(e){return this.throwIfDisposed(),BT(this,e)},ik().prototype.mean=function(e,t){return this.throwIfDisposed(),WT(this,e,t)},ik().prototype.min=function(e,t){return this.throwIfDisposed(),HS(this,e,t)},ik().prototype.minimum=function(e){return this.throwIfDisposed(),jT(this,e)},ik().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),HT(this,e,t)},ik().prototype.mod=function(e){return this.throwIfDisposed(),qT(this,e)},ik().prototype.mul=function(e){return this.throwIfDisposed(),lI(this,e)},ik().prototype.neg=function(){return this.throwIfDisposed(),NT(this)},ik().prototype.norm=function(e,t,n){return this.throwIfDisposed(),QS(this,e,t,n)},ik().prototype.notEqual=function(e){return this.throwIfDisposed(),JT(this,e)},ik().prototype.oneHot=function(e,t,n){return void 0===t&&(t=1),void 0===n&&(n=0),this.throwIfDisposed(),ZT(this,e,t,n)},ik().prototype.onesLike=function(){return this.throwIfDisposed(),QT(this)},ik().prototype.pad=function(e,t){return this.throwIfDisposed(),eC(this,e,t)},ik().prototype.pool=function(e,t,n,r,a,i){return this.throwIfDisposed(),oC(this,e,t,n,r,a,i)},ik().prototype.pow=function(e){return this.throwIfDisposed(),qS(this,e)},ik().prototype.prelu=function(e){return this.throwIfDisposed(),sC(this,e)},ik().prototype.prod=function(e,t){return this.throwIfDisposed(),uC(this,e,t)},ik().prototype.reciprocal=function(){return this.throwIfDisposed(),LC(this)},ik().prototype.relu=function(){return this.throwIfDisposed(),zC(this)},ik().prototype.relu6=function(){return this.throwIfDisposed(),PC(this)},ik().prototype.reshapeAs=function(e){return this.throwIfDisposed(),PI(this,e.shape)},ik().prototype.reshape=function(e){return this.throwIfDisposed(),PI(this,e)},ik().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),FA(this,e,t,n)},ik().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),OA(this,e,t,n)},ik().prototype.reverse=function(e){return this.throwIfDisposed(),BC(this,e)},ik().prototype.rfft=function(){return this.throwIfDisposed(),uE(this)},ik().prototype.round=function(){return this.throwIfDisposed(),jC(this)},ik().prototype.rsqrt=function(){return this.throwIfDisposed(),HC(this)},ik().prototype.selu=function(){return this.throwIfDisposed(),qC(this)},ik().prototype.separableConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),KC(this,e,t,n,r,a,i)},ik().prototype.sigmoid=function(){return this.throwIfDisposed(),GI(this)},ik().prototype.sign=function(){return this.throwIfDisposed(),JC(this)},ik().prototype.sin=function(){return this.throwIfDisposed(),ZC(this)},ik().prototype.sinh=function(){return this.throwIfDisposed(),QC(this)},ik().prototype.slice=function(e,t){return this.throwIfDisposed(),jI(this,e,t)},ik().prototype.softmax=function(e){return this.throwIfDisposed(),rE(this,e)},ik().prototype.softplus=function(){return this.throwIfDisposed(),IT(this)},ik().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),iC(this,e,t)},ik().prototype.split=function(e,t){return this.throwIfDisposed(),sE(this,e,t)},ik().prototype.sqrt=function(){return this.throwIfDisposed(),XS(this)},ik().prototype.square=function(){return this.throwIfDisposed(),YS(this)},ik().prototype.squaredDifference=function(e){return this.throwIfDisposed(),lE(this,e)},ik().prototype.squeeze=function(e){return this.throwIfDisposed(),cE(this,e)},ik().prototype.stack=function(e,t){this.throwIfDisposed();var n=e instanceof ak?[this,e]:[this].concat(e);return pE(n,t)},ik().prototype.step=function(e){return this.throwIfDisposed(),hE(this,e)},ik().prototype.stridedSlice=function(e,t,n,r,a,i,o,s){return this.throwIfDisposed(),dE(this,e,t,n,r,a,i,o,s)},ik().prototype.sub=function(e){return this.throwIfDisposed(),TT(this,e)},ik().prototype.sum=function(e,t){return this.throwIfDisposed(),JS(this,e,t)},ik().prototype.tan=function(){return this.throwIfDisposed(),fE(this)},ik().prototype.tanh=function(){return this.throwIfDisposed(),HI(this)},ik().prototype.tile=function(e){return this.throwIfDisposed(),rT(this,e)},ik().prototype.toBool=function(){return this.throwIfDisposed(),XN(this,"bool")},ik().prototype.toFloat=function(){return this.throwIfDisposed(),XN(this,"float32")},ik().prototype.toInt=function(){return this.throwIfDisposed(),XN(this,"int32")},ik().prototype.topk=function(e,t){return this.throwIfDisposed(),TE(this,e,t)},ik().prototype.transpose=function(e){return this.throwIfDisposed(),PE(this,e)},ik().prototype.unique=function(e){return this.throwIfDisposed(),EE(this,e)},ik().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),AE(this,e,t)},ik().prototype.unstack=function(e){return this.throwIfDisposed(),RE(this,e)},ik().prototype.where=function(e,t){return this.throwIfDisposed(),AS(e,this,t)},ik().prototype.zerosLike=function(){return this.throwIfDisposed(),RS(this)};var GO=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Ov(r),t.prototype),r}return Cv(t,e),t}(Fv(Error)),jO=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Ov(r),t.prototype),r}return Cv(t,e),t}(Fv(Error)),HO=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Ov(r),t.prototype),r}return Cv(t,e),t}(Fv(Error)),qO=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Ov(r),t.prototype),r}return Cv(t,e),t}(Fv(Error)),KO=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Ov(r),t.prototype),r}return Cv(t,e),t}(Fv(Error)),XO=(Error,function(){function e(e){this.maxEntries=e||100,this.cache=new Map}var t=e.prototype;return t.get=function(e){var t;return this.cache.has(e)&&(t=this.cache.get(e),this.cache.delete(e),this.cache.set(e,t)),t},t.put=function(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxEntries){var n=this.cache.keys().next().value;this.cache.delete(n)}this.cache.set(e,t)},t.getMaxEntries=function(){return this.maxEntries},t.setMaxEntries=function(e){if(e<0)throw new Error("The maxEntries of LRU caches must be at least 0, but got "+e+".");if(this.maxEntries>e)for(var t=0;t<this.maxEntries-e;t++){var n=this.cache.keys().next().value;this.cache.delete(n)}this.maxEntries=e},e}());function YO(e,t){if(Array.isArray(e)){for(var n=[],r=0;r<t;r++)n=n.concat(e);return n}var a=new Array(t);return a.fill(e),a}function JO(e,t){if(!e)throw new KO(t)}function ZO(e,t){for(var n,r=0,a=Lv(e);!(n=a()).done;){n.value===t&&r++}return r}function QO(e){return 1===e.length?e[0]:e}function $O(e){return Array.isArray(e)?e:[e]}function eD(e){var t=e.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return"_"!==t[0]?t:"private"+t}function tD(e){return e.length<=1||-1===e.indexOf("_")?e:e.replace(/[_]+(\w|$)/g,(function(e,t){return t.toUpperCase()}))}var nD={};function rD(e){if(null==e)return null;var t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function aD(e){if(null!=e&&"object"==typeof e)if(Array.isArray(e))e.forEach((function(e){return aD(e)}));else for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t],a=e[r];null!=a&&"object"==typeof a&&(Array.isArray(a)||"ndarray"!==a.type||"number"!=typeof a.value?aD(a):e[r]=a.value)}}function iD(e,t,n,r,a){if(void 0===t&&(t={}),void 0===n&&(n={}),void 0===r&&(r="object"),void 0===a&&(a=!1),"string"==typeof e){var i,o=e;if(o in n)i=n[o];else if(o in nD)i=nD[o];else if(null==(i=t[o]))throw new HO("Unknown "+r+": "+e+". 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=e;if(null==s.className||null==s.config)throw new HO(r+": Improper config format: "+JSON.stringify(s)+".\n'className' and 'config' must set.");var u,l,c=s.className;if(c in n){var p=n[c];u=p[0],l=p[1]}else if(c in nD){var h=nD.className;u=h[0],l=h[1]}else if(c in t){var d=t[c];u=d[0],l=d[1]}if(null==u)throw new HO("Unknown "+r+": "+c+". 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!=l){for(var f={},m=0,v=Object.keys(nD);m<v.length;m++){var g=v[m];f[g]=nD[g]}for(var y=0,b=Object.keys(n);y<b.length;y++){var x=b[y];f[x]=n[x]}s.config.customObjects=f;for(var w=Object.assign({},nD),k=0,N=Object.keys(n);k<N.length;k++){var I=N[k];nD[I]=n[I]}aD(s.config);var S=l(u,s.config,n,a);return nD=Object.assign({},w),S}for(var T=Object.assign({},nD),C=0,E=Object.keys(n);C<E.length;C++){var A=E[C];nD[A]=n[A]}var R=new u(s.config);return nD=Object.assign({},T),R}function oD(e,t){return-1*function(e,t){return e<t?-1:e>t?1:0}(e,t)}function sD(e){if(null==e)return e;for(var t,n=[],r=Lv(e);!(t=r()).done;){var a=t.value;-1===n.indexOf(a)&&n.push(a)}return n}function uD(e){if(null==e)throw new HO("Invalid value in obj: "+JSON.stringify(e));for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function lD(e,t,n){if(null!=n&&e.indexOf(n)<0)throw new HO(n+" is not a valid "+t+". Valid values are "+e+" or null/undefined.")}function cD(e,t,n,r){return void 0===n&&(n=0),void 0===r&&(r=1/0),JO(n>=0),JO(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every((function(e){return typeof e===t}))}function pD(e,t){Array.isArray(e)?(Hv(e.length>0,(function(){return t+" is unexpectedly an empty array."})),e.forEach((function(e,n){return pD(e,"element "+(n+1)+" of "+t)}))):Hv(Number.isInteger(e)&&e>0,(function(){return"Expected "+t+" to be a positive integer, but got "+hD(e)+"."}))}function hD(e){return null===e?"null":Array.isArray(e)?"["+e.map((function(e){return hD(e)})).join(",")+"]":"string"==typeof e?'"'+e+'"':""+e}function dD(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}var fD=0;function mD(){return fD++}var vD={};function gD(e){return void 0===e&&(e=""),e in vD||(vD[e]=0),vD[e]+=1,e+vD[e].toString()}var yD=["channelsFirst","channelsLast"],bD=["nearest","bilinear"],xD=["valid","same","causal"],wD=["max","avg"],kD=["sum","mul","concat","ave"],ND=new Map;function ID(e){lD(yD,"DataFormat",e)}function SD(e){lD(xD,"PaddingMode",e)}function TD(e){lD(wD,"PoolMode",e)}var CD=[];function ED(e,t){CD.push(e);try{var n=t();return CD.pop(),n}catch(e){throw CD.pop(),e}}function AD(e){if(!OD(e))throw new Error("Not a valid tensor name: '"+e+"'");return(0===CD.length?"":CD.join("/")+"/")+e}function RD(e){if(!OD(e))throw new Error("Not a valid tensor name: '"+e+"'");ND.has(e)||ND.set(e,0);var t=ND.get(e);if(ND.set(e,ND.get(e)+1),t>0){var n=e+"_"+t;return ND.set(n,1),n}return e}var _D,FD=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function OD(e){return!!e.match(FD)}function DD(e,t,n){null==t&&(t=0),null==n&&(n=e.length);for(var r=1,a=t;a<n;++a)r*=e[a];return r}function MD(e){if(0===e.length)return Number.NaN;for(var t=Number.POSITIVE_INFINITY,n=0;n<e.length;n++){var r=e[n];r<t&&(t=r)}return t}function LD(e){if(0===e.length)return Number.NaN;for(var t=Number.NEGATIVE_INFINITY,n=0;n<e.length;n++){var r=e[n];r>t&&(t=r)}return t}function zD(e,t){if(t<e)throw new HO("end ("+t+") < begin ("+e+") is forbidden.");for(var n=[],r=e;r<t;++r)n.push(r);return n}function PD(){return null==_D&&(_D=iI().epsilon()),_D}function BD(e,t){return XN(e,t)}function WD(e,t){void 0===t&&(t=-1);var n=e.shape.slice();return t<0&&(t=n.length+t+1),n.splice(t,0,1),PI(e,n)}function VD(e,t,n){return eI((function(){switch(e.rank){case 1:return $C(e,t,n);case 2:return eE(e,[t,0],[n,e.shape[1]]);case 3:return tE(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return nE(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return jI(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return jI(e,[t,0,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new HO("sliceAlongFirstAxis() received an unsupported tensor rank: "+e.rank)}}))}function UD(e,t,n){return eI((function(){switch(e.rank){case 1:return $C(e,t,n);case 2:return eE(e,[0,t],[e.shape[0],n]);case 3:return tE(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return nE(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new HO("sliceAlongLastAxis() received an unsupported tensor rank: "+e.rank)}}))}function GD(e,t,n,r){return eI((function(){switch(e.rank){case 1:return $C(e,t,n);case 2:switch(r){case 1:return VD(e,t,n);case 2:return UD(e,t,n);default:throw new HO("The axis is not within the rank of the tensor "+r)}case 3:switch(r){case 1:return VD(e,t,n);case 2:return tE(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return UD(e,t,n);default:throw new HO("The axis is not within the rank of the tensor "+r)}case 4:switch(r){case 1:return VD(e,t,n);case 2:return nE(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return nE(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return UD(e,t,n);default:throw new HO("The axis is not within the rank of the tensor "+r)}default:throw new HO("sliceAlongLastAxis() received an unsupported tensor rank: "+e.rank)}}))}function jD(e,t){var n;return void 0===t&&(t=-1),t<0&&(t=0!==(n=e[0].rank)?n:0),t===e[0].rank&&(t=-1),VI(e,t)}function HD(e,t){switch(e.rank){case 1:return aS([e,t]);case 2:return iS([e,t],0);case 3:return oS([e,t],0);case 4:return sS([e,t],0);default:throw new HO("concatAlongFirstAxis() received an unsupported tensor rank: "+e.rank)}}function qD(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new HO("The length of input n ("+t.length+") does not match the number of dimensions in input x ("+e.rank+")");return rT(e,t)}function KD(e,t,n,r,a){return void 0===t&&(t=0),void 0===n&&(n=1),_C(e,t,n,r,a)}function XD(e,t,n,r){if(e.rank<2||t.rank<2)throw new qO("dot requires both inputs to be rank >= 2 but got x shape = "+e.shape+" and y shape = "+t.shape);if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new qO("If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = "+e.shape+" and y shape = "+t.shape);if(2===e.rank&&2===t.rank){return rA({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?ZD(e.rank,r,"channelsLast"):null,activation:n})}var a=e.shape.slice(),i=a.pop();e=PI(e,[-1,i]);var o=t.shape.slice(),s=o.pop(),u=o.pop(),l=[].concat(o,[s]),c=Array.from({length:t.rank},(function(e,n){return 0===n?t.rank-2:n<=t.rank-2?n-1:n}));t=PI(PE(t,c),[u,-1]);var p=[].concat(a,l);return PI(rA({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?ZD(e.rank,r,"channelsLast"):null,activation:n}),p)}function YD(e,t,n){return eI((function(){return t=Array.isArray(t)?mE(t,"int32"):XN(t,"int32"),oT(e,t,n)}))}function JD(e){return lI(e,e)}function ZD(e,t,n){var r=t.shape;if(1!==t.rank&&t.rank!==e)throw new HO("Unexpected bias dimensions: "+t.rank+"; expected it to be 1 or "+e);if(5===e){if("channelsFirst"===n)return 1===r.length?PI(t,[1,r[0],1,1,1]):PI(t,[1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?PI(t,[1,1,1,1,r[0]]):PI(t,[1].concat(r))}else if(4===e){if("channelsFirst"===n)return 1===r.length?PI(t,[1,r[0],1,1]):PI(t,[1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?PI(t,[1,1,1,r[0]]):PI(t,[1].concat(r))}else if(3===e){if("channelsFirst"===n)return 1===r.length?PI(t,[1,r[0],1]):PI(t,[1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?PI(t,[1,1,r[0]]):PI(t,[1].concat(r))}else if(e<3)return t;throw new HO("Unsupported input rank by biasAdd: "+t.rank)}function QD(e,t,n){return eI((function(){return null==n&&(n="channelsLast"),ID(n),oI(e,ZD(e.rank,t,n))}))}function $D(e,t,n,r){return eI((function(){return GE(e,t,n,r)}))}function eM(e,t,n){return void 0===n&&(n=!1),n?e():t()}var tM=["fanIn","fanOut","fanAvg"],nM=["normal","uniform","truncatedNormal"];var rM=function(e){function t(){return e.apply(this,arguments)||this}Cv(t,e);var n=t.prototype;return n.fromConfigUsesCustomObjects=function(){return!1},n.getConfig=function(){return{}},t}(pR),aM=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e,t){return VT(e,t)},t}(rM);aM.className="Zeros",dR(aM);var iM=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e,t){return UT(e,t)},t}(rM);iM.className="Ones",dR(iM);var oM=function(e){function t(t){var n;if(n=e.call(this)||this,"object"!=typeof t)throw new HO("Expected argument of type ConstantConfig but got "+t);if(void 0===t.value)throw new HO("config must have value set but got "+t);return n.value=t.value,n}Cv(t,e);var n=t.prototype;return n.apply=function(e,t){var n=this;return eI((function(){return lI(KS(n.value),UT(e,t))}))},n.getConfig=function(){return{value:this.value}},t}(rM);oM.className="Constant",dR(oM);var sM=function(e){function t(t){var n;return(n=e.call(this)||this).DEFAULT_MINVAL=-.05,n.DEFAULT_MAXVAL=.05,n.minval=t.minval||n.DEFAULT_MINVAL,n.maxval=t.maxval||n.DEFAULT_MAXVAL,n.seed=t.seed,n}Cv(t,e);var n=t.prototype;return n.apply=function(e,t){return OC(e,this.minval,this.maxval,t,this.seed)},n.getConfig=function(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}},t}(rM);sM.className="RandomUniform",dR(sM);var uM=function(e){function t(t){var n;return(n=e.call(this)||this).DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=t.mean||n.DEFAULT_MEAN,n.stddev=t.stddev||n.DEFAULT_STDDEV,n.seed=t.seed,n}Cv(t,e);var n=t.prototype;return n.apply=function(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new qO("randomNormal does not support dType "+t+".");return KD(e,this.mean,this.stddev,t,this.seed)},n.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},t}(rM);uM.className="RandomNormal",dR(uM);var lM=function(e){function t(t){var n;return(n=e.call(this)||this).DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=t.mean||n.DEFAULT_MEAN,n.stddev=t.stddev||n.DEFAULT_STDDEV,n.seed=t.seed,n}Cv(t,e);var n=t.prototype;return n.apply=function(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new qO("truncatedNormal does not support dType "+t+".");return CE(e,this.mean,this.stddev,t,this.seed)},n.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},t}(rM);lM.className="TruncatedNormal",dR(lM);var cM=function(e){function t(t){var n;return(n=e.call(this)||this).gain=null!=t.gain?t.gain:1,n}Cv(t,e);var n=t.prototype;return n.apply=function(e,t){var n=this;return eI((function(){if(2!==e.length||e[0]!==e[1])throw new HO("Identity matrix initializer can only be used for 2D square matrices.");return lI(n.gain,aT(e[0]))}))},n.getConfig=function(){return{gain:this.gain}},t}(rM);cM.className="Identity",dR(cM);var pM=function(e){function t(t){var n,r;if(n=e.call(this)||this,t.scale<0)throw new HO("scale must be a positive float. Got: "+t.scale);return n.scale=null==t.scale?1:t.scale,n.mode=null==t.mode?"fanIn":t.mode,r=n.mode,lD(tM,"FanMode",r),n.distribution=null==t.distribution?"normal":t.distribution,function(e){lD(nM,"Distribution",e)}(n.distribution),n.seed=t.seed,n}Cv(t,e);var n=t.prototype;return n.apply=function(e,t){var n=function(e,t){var n,r;if(void 0===t&&(t="channelsLast"),ID(t),2===e.length)n=e[0],r=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){var a=DD(e,2);n=e[1]*a,r=e[0]*a}else if("channelsLast"===t){var i=DD(e,0,e.length-2);n=e[e.length-2]*i,r=e[e.length-1]*i}}else{var o=DD(e);n=Math.sqrt(o),r=Math.sqrt(o)}return[n,r]}(e),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"!==(t=t||"float32")&&"int32"!==t)throw new qO(this.getClassName()+" does not support dType "+t+".");return CE(e,0,o,t,this.seed)}var s=Math.sqrt(3*i);return OC(e,-s,s,t,this.seed)},n.getConfig=function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}},t}(rM);pM.className="VarianceScaling",dR(pM);var hM=function(e){function t(t){return e.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:null==t?null:t.seed})||this}return Cv(t,e),t.prototype.getClassName=function(){return pM.className},t}(pM);hM.className="GlorotUniform",dR(hM);var dM=function(e){function t(t){return e.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:null==t?null:t.seed})||this}return Cv(t,e),t.prototype.getClassName=function(){return pM.className},t}(pM);dM.className="GlorotNormal",dR(dM);var fM=function(e){function t(t){return e.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})||this}return Cv(t,e),t.prototype.getClassName=function(){return pM.className},t}(pM);fM.className="HeNormal",dR(fM);var mM=function(e){function t(t){return e.call(this,{scale:2,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})||this}return Cv(t,e),t.prototype.getClassName=function(){return pM.className},t}(pM);mM.className="HeUniform",dR(mM);var vM=function(e){function t(t){return e.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})||this}return Cv(t,e),t.prototype.getClassName=function(){return pM.className},t}(pM);vM.className="LeCunNormal",dR(vM);var gM=function(e){function t(t){return e.call(this,{scale:1,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})||this}return Cv(t,e),t.prototype.getClassName=function(){return pM.className},t}(pM);gM.className="LeCunUniform",dR(gM);var yM=function(e){function t(t){var n;return(n=e.call(this)||this).DEFAULT_GAIN=1,n.ELEMENTS_WARN_SLOW=2e3,n.gain=null==t.gain?n.DEFAULT_GAIN:t.gain,n.seed=t.seed,n}Cv(t,e);var n=t.prototype;return n.apply=function(e,t){var n=this;return eI((function(){if(e.length<2)throw new qO("Shape must be at least 2D.");if("int32"!==t&&"float32"!==t&&void 0!==t)throw new TypeError("Unsupported data type "+t+".");var r=Xv(e.slice(0,-1)),a=e[e.length-1],i=r*a;i>n.ELEMENTS_WARN_SLOW&&console.warn("Orthogonal initializer is being called on a matrix with more than "+n.ELEMENTS_WARN_SLOW+" ("+i+") elements: Slowness may result.");var o=KD([Math.max(a,r),Math.min(a,r)],0,1,t,n.seed),s=sR.qr(o,!1),u=s[0],l=s[1].flatten().stridedSlice([0],[Math.min(a,r)*Math.min(a,r)],[Math.min(a,r)+1]);return u=lI(u,l.sign()),r<a&&(u=u.transpose()),lI(KS(n.gain),u.reshape(e))}))},n.getConfig=function(){return{gain:this.gain,seed:this.seed}},t}(rM);yM.className="Orthogonal",dR(yM);var bM={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 xM(e,t){return void 0===t&&(t={}),iD(e,hR.getMap().classNameMap,t,"initializer")}function wM(e){return rD(e)}function kM(e){if("string"==typeof e){var t=e in bM?bM[e]:e;if("GlorotNormal"===t)return new dM;if("GlorotUniform"===t)return new hM;if("HeNormal"===t)return new fM;if("HeUniform"===t)return new mM;if("LeCunNormal"===t)return new vM;if("LeCunUniform"===t)return new gM;var n={};return n.className=t,n.config={},xM(n)}return e instanceof rM?e:xM(e)}function NM(e){return Array.isArray(e)&&Array.isArray(e[0])}function IM(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function SM(e){var t;if(Array.isArray(e)){if(1!==e.length)throw new HO("Expected Tensor length to be 1; got "+e.length);t=e[0]}else t=e;return t}function TM(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(1===e.length)return e[0];throw new HO("Expected exactly 1 Shape; got "+e.length)}return e}function CM(e){for(var t,n=0,r=Lv(e);!(t=r()).done;){var a=t.value;0===a.shape.length?n+=1:n+=a.shape.reduce((function(e,t){return e*t}))}return n}var EM="Variable",AM=function(){function e(e,t,n,r,a){void 0===t&&(t="float32"),void 0===n&&(n=EM),void 0===r&&(r=!0),void 0===a&&(a=null),this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=mD(),n=null==n?EM:n,this.originalName=AD(n),this.name=RD(this.originalName),this.trainable_=r,this.constraint=a,this.val=FE(e,this.trainable_,this.name,this.dtype)}var t=e.prototype;return t.read=function(){return this.assertNotDisposed(),this.val},t.write=function(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this},t.dispose=function(){this.assertNotDisposed(),this.val.dispose()},t.assertNotDisposed=function(){if(this.val.isDisposed)throw new Error("LayersVariable "+this.name+" is already disposed.")},Tv(e,[{key:"trainable",get:function(){return this.trainable_},set:function(e){this.trainable_=e,this.val.trainable=e}}]),e}();function RM(e){return e.map((function(e){return e.read()}))}function _M(e){e.forEach((function(e){e[0].write(e[1])}))}var FM=function(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}},OM=function(e,t,n,r,a,i,o){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=r,this.callArgs=a,this.outputTensorIndex=o,this.id=mD(),null!=i&&(this.originalName=AD(i),this.name=RD(this.originalName)),this.rank=t.length},DM=0,MM=function(){function e(e,t){this.callArgs=t,this.id=DM++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(var n,r=Lv(e.inboundLayers);!(n=r()).done;){var a=n.value;null!=a&&a.outboundNodes.push(this)}e.outboundLayer.inboundNodes.push(this)}return e.prototype.getConfig=function(){for(var e,t=[],n=Lv(this.inboundLayers);!(e=n()).done;){var r=e.value;null!=r?t.push(r.name):t.push(null)}return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:t,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}},e}(),LM=0,zM=function(e){function t(t){var n;void 0===t&&(t={}),(n=e.call(this)||this)._callHook=null,n._addedWeightNames=[],n._stateful=!1,n.id=LM++,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=t.name;if(!r){var a=n.getClassName();r=eD(a)+"_"+gD(a)}if(n.name=r,n.trainable_=null==t.trainable||t.trainable,null!=t.inputShape||null!=t.batchInputShape){var i;if(null!=t.batchInputShape)i=t.batchInputShape;else if(null!=t.inputShape){var o=null;null!=t.batchSize&&(o=t.batchSize),i=[o].concat(t.inputShape)}n.batchInputShape=i;var s=t.dtype;null==s&&(s=t.inputDType),null==s&&(s="float32"),n.dtype=s}return null!=t.weights?n.initialWeights=t.weights:n.initialWeights=null,n._refCount=null,n.fastWeightInitDuringBuild=!1,n}Cv(t,e),t.nodeKey=function(e,t){return e.name+"_ib-"+t.toString()};var n=t.prototype;return n.getNodeAtIndex=function(e,t){if(0===this.inboundNodes.length)throw new jO("The layer has never been called and thus has no defined "+t+".");if(this.inboundNodes.length<=e)throw new HO("Asked to get "+t+" at node "+e+", but the layer has only "+this.inboundNodes.length+" inbound nodes.");return this.inboundNodes[e]},n.getInputAt=function(e){return QO(this.getNodeAtIndex(e,"input").inputTensors)},n.getOutputAt=function(e){return QO(this.getNodeAtIndex(e,"output").outputTensors)},n.calculateLosses=function(){return this.losses.map((function(e){return e()}))},n.resetStates=function(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")},n.assertInputCompatibility=function(e){if(e=$O(e),null!=this.inputSpec&&0!==this.inputSpec.length){var t=$O(this.inputSpec);if(e.length!==t.length)throw new HO("Layer "+this.name+" expects "+t.length+" inputs, but it received "+e.length+" input tensors. Input received: "+e);for(var n=0;n<e.length;n++){var r=e[n],a=t[n];if(null!=a){var i=r.rank;if(null!=a.ndim&&i!==a.ndim)throw new HO("Input "+n+" is incompatible with layer "+this.name+": expected ndim="+a.ndim+", found ndim="+i);if(null!=a.maxNDim&&i>a.maxNDim)throw new HO("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 HO("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 HO("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),l=a.axes[s],c=u>=0?o[u]:o[o.length+u];if(null!=l&&-1===[l,null].indexOf(c))throw new HO("Input "+n+" is incompatible with layer "+this.name+": expected axis "+u+" of input shape to have value "+l+" but got shape "+o+".")}}if(null!=a.shape)for(var p=0;p<a.shape.length;++p){var h=a.shape[p],d=r.shape[p];if(null!=h&&null!=d&&h!==d)throw new HO("Input "+n+" is incompatible with layer "+this.name+": expected shape="+a.shape+", found shape="+r.shape+".")}}}}},n.call=function(e,t){return e},n.invokeCallHook=function(e,t){null!=this._callHook&&this._callHook(e,t)},n.setCallHook=function(e){this._callHook=e},n.clearCallHook=function(){this._callHook=null},n.apply=function(e,t){var n=this;t=t||{},this.assertNotDisposed();for(var r,a=$O(e),i=!0,o=Lv(a);!(r=o()).done;){if(!(r.value instanceof OM)){i=!1;break}}for(var s,u=!0,l=Lv(a);!(s=l()).done;){if(s.value instanceof OM){u=!1;break}}if(i===u)throw new HO("Arguments to apply() must be all SymbolicTensors or all Tensors");return ED(this.name,(function(){if(!n.built){n.assertInputCompatibility(e);for(var r,i=[],o=Lv($O(e));!(r=o()).done;){var s=r.value;i.push(s.shape)}n.build(QO(i)),n.built=!0,n.initialWeights&&n.setWeights(n.initialWeights),null===n._refCount&&u&&(n._refCount=1)}if(n.assertInputCompatibility(e),u){for(var l,c=n.call(e,t),p=[],h=Lv($O(c));!(l=h()).done;){var d=l.value;-1!==a.indexOf(d)&&(d=d.clone()),p.push(d)}if(c=QO(p),null!=n.activityRegularizer)throw new qO("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return c}var f,m=function(e){e=$O(e);for(var t,n=[],r=Lv(e);!(t=r()).done;){var a=t.value;n.push(a.shape)}return QO(n)}(e),v=n.computeOutputShape(m),g="float32";if(n.warnOnIncompatibleInputShape(Array.isArray(e)?m[0]:m),f=null!=v&&v.length>0&&Array.isArray(v[0])?v.map((function(r,a){return new OM(g,r,n,$O(e),t,n.name,a)})):new OM(g,v,n,$O(e),t,n.name),n.addInboundNode(e,f,null,null,m,v,t),n._refCount++,null!=n.activityRegularizer)throw new qO("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return f}))},n.warnOnIncompatibleInputShape=function(e){if(null!=this.batchInputShape)if(e.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+JSON.stringify(e)+") does not match that of the batchInputShape ("+JSON.stringify(this.batchInputShape)+") of the layer "+this.name);else{var t=!1;this.batchInputShape.forEach((function(n,r){null!=n&&null!=e[r]&&e[r]!==n&&(t=!0)})),t&&console.warn("The shape of the input tensor ("+JSON.stringify(e)+") does not match the expectation of layer "+this.name+": "+JSON.stringify(this.batchInputShape))}},n.countParams=function(){if(!this.built)throw new jO("You tried to call countParams() on "+this.name+", but the layer is not built yet. Build it first by calling build(batchInputShape).");return CM(this.weights)},n.build=function(e){this.built=!0},n.getWeights=function(e){return void 0===e&&(e=!1),RM(e?this.trainableWeights:this.weights)},n.setWeights=function(e){var t=this;eI((function(){var n=t.weights;if(n.length!==e.length)throw new HO('You called setWeights(weights) on layer "'+t.name+'" with a weight list of length '+e.length+", but the layer was expecting "+n.length+" weights. Provided weights: "+e+"...");if(0!==n.length){for(var r=[],a=RM(n),i=0;i<a.length;++i){var o=a[i],s=n[i],u=e[i];if(!Yv(o.shape,u.shape))throw new HO("Layer weight shape "+o.shape+" not compatible with provided weight shape "+u.shape);r.push([s,u])}_M(r)}}))},n.addWeight=function(e,t,n,r,a,i,o,s){if(-1!==this._addedWeightNames.indexOf(e))throw new HO("Duplicate weight name "+e+" for layer "+this.name);this._addedWeightNames.push(e),null==n&&(n="float32"),this.fastWeightInitDuringBuild&&(r=null!=s?s():kM("zeros"));var u=r.apply(t,n),l=new AM(u,n,e,i,o);return u.dispose(),null!=a&&this.addLoss((function(){return a.apply(l.read())})),null==i&&(i=!0),i?this._trainableWeights.push(l):this._nonTrainableWeights.push(l),l},n.setFastWeightInitDuringBuild=function(e){this.fastWeightInitDuringBuild=e},n.addLoss=function(e){var t;null==e||Array.isArray(e)&&0===e.length||(e=$O(e),void 0!==this._losses&&null!==this._losses&&(t=this.losses).push.apply(t,e))},n.computeOutputShape=function(e){return e},n.computeMask=function(e,t){var n=this;if(!this.supportsMasking){if(null!=t){if(!Array.isArray(t))throw new TypeError("Layer "+this.name+" does not support masking, but was passed an inputMask.");t.forEach((function(e){if(null!=e)throw new TypeError("Layer "+n.name+" does not support masking, but was passed an inputMask.")}))}return null}return t},n.addInboundNode=function(e,t,n,r,a,i,o){void 0===o&&(o=null);var s=$O(e);t=$O(t),n=$O(n),r=$O(r),a=IM(a),i=IM(i);for(var u,l=[],c=[],p=[],h=Lv(s);!(u=h()).done;){var d=u.value;l.push(d.sourceLayer),c.push(d.nodeIndex),p.push(d.tensorIndex)}new MM({outboundLayer:this,inboundLayers:l,nodeIndices:c,tensorIndices:p,inputTensors:s,outputTensors:t,inputMasks:n,outputMasks:r,inputShapes:a,outputShapes:i},o);for(var f=0;f<t.length;f++)t[f].sourceLayer=this,t[f].nodeIndex=this.inboundNodes.length-1,t[f].tensorIndex=f},n.getConfig=function(){var e={name:this.name,trainable:this.trainable};return null!=this.batchInputShape&&(e.batchInputShape=this.batchInputShape),null!=this.dtype&&(e.dtype=this.dtype),e},n.disposeWeights=function(){return this.weights.forEach((function(e){return e.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 e=0;return 0==--this._refCount&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}},Tv(t,[{key:"input",get:function(){if(this.inboundNodes.length>1)throw new GO("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 GO("Layer "+this.name+" is not connected, no input to return.");return QO(this.getNodeAtIndex(0,"input").inputTensors)}},{key:"output",get:function(){if(0===this.inboundNodes.length)throw new GO("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new GO("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return QO(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(e){this._built=e}},{key:"trainable",get:function(){return this.trainable_},set:function(e){this._trainableWeights.forEach((function(t){return t.trainable=e})),this.trainable_=e}},{key:"trainableWeights",get:function(){return this.trainable_?this._trainableWeights.filter((function(e){return e.trainable})):[]},set:function(e){this._trainableWeights=e}},{key:"nonTrainableWeights",get:function(){return this.trainable?this._trainableWeights.filter((function(e){return!e.trainable})).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)},set:function(e){this._nonTrainableWeights=e}},{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 GO("The layer "+this.name+" has never been called and thus has no defined output shape.");for(var e,t=[],n=Lv(this.inboundNodes);!(e=n()).done;){var r=e.value,a=JSON.stringify(r.outputShapes);-1===t.indexOf(a)&&t.push(a)}if(1===t.length){var i=this.inboundNodes[0].outputShapes;return Array.isArray(i)&&Array.isArray(i[0])&&1===i.length?i[0]:i}throw new GO("The layer "+this.name+' has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.')}}]),t}(pR);function PM(e,t,n){if((null==t||null!=n&&n>0)&&(t=e.sourceLayer,n=e.nodeIndex),0===t.inboundNodes.length)return[e];var r=t.inboundNodes[n];if(0===r.inboundLayers.length)return r.inputTensors;for(var a=[],i=0;i<r.inboundLayers.length;i++)for(var o,s=Lv(PM(r.inputTensors[i],r.inboundLayers[i],r.nodeIndices[i]));!(o=s()).done;){var u=o.value;-1===a.indexOf(u)&&a.push(u)}return a}var BM=function(e){function t(t){var n;if(n=e.call(this,{dtype:t.dtype,name:null!=t.name?t.name:gD("input").toString()})||this,null==t.batchSize&&(t.batchSize=null),null==t.sparse&&(t.sparse=!1),n.trainable=!1,n.built=!0,n.sparse=t.sparse,null!=t.inputShape&&null!=t.batchInputShape)throw new HO("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");var r=t.batchInputShape;if(null==r){if(null==t.inputShape)throw new HO("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");r=[t.batchSize].concat(t.inputShape)}else if(null!=t.batchSize)throw new HO("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");var a=t.dtype||"float32";n.batchInputShape=r,n.dtype=a,n.inputSpec=[{shape:r}];var i=new OM(n.dtype,n.batchInputShape,Ov(n),[],{},n.name);return i.nodeIndex=0,i.tensorIndex=0,new MM({outboundLayer:Ov(n),inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[i],outputTensors:[i],inputMasks:[null],outputMasks:[null],inputShapes:[r],outputShapes:[r]}),n}Cv(t,e);var n=t.prototype;return n.apply=function(e,t){throw new HO("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}},t}(zM);function WM(e){if(null==e.batchShape&&null==e.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!=e.batchShape&&null!=e.shape)throw new HO("Please provide either a `shape` or `batchShape` argument to Input, but not both.");var t=e.batchShape;null!=e.shape&&null==t&&(t=[null].concat(e.shape));var n=e.dtype;return null==n&&(n="float32"),new BM({batchInputShape:t,name:e.name,dtype:n,sparse:e.sparse}).inboundNodes[0].outputTensors[0]}BM.className="InputLayer",dR(BM);var VM=function(){function e(t){if(this.id2Value={},this.id2Mask={},this.name2Id={},t instanceof e)for(var n in t.id2Value)this.id2Value[n]=t.id2Value[n],n in t.id2Mask&&(this.id2Mask[n]=t.id2Mask[n]);else{if(null==t)return;for(var r,a=Lv(t);!(r=a()).done;){var i=r.value;this.add(i.key,i.value)}}}var t=e.prototype;return t.add=function(e,t,n){if(null!=this.id2Value[e.id])throw new HO("Duplicate key: name="+e.name+", id="+e.id);return this.id2Value[e.id]=function(e,t){if(null==e.dtype||e.dtype===t.dtype)return t;try{return XN(t,e.dtype)}catch(n){throw new HO("The dtype of the feed ("+t.dtype+") can not be cast to the dtype of the key '"+e.name+"' ("+e.dtype+").")}}(e,t),this.name2Id[e.name]=e.id,null!=n&&(this.id2Mask[e.id]=n),this},t.addFeed=function(e){this.add(e.key,e.value)},t.hasKey=function(e){return null!=this.id2Value[e.id]},t.names=function(){return Object.keys(this.name2Id)},t.getValue=function(e){if(e instanceof OM){if(null==this.id2Value[e.id])throw new HO("Nonexistent key: "+e.name);return this.id2Value[e.id]}var t=this.name2Id[e];if(null==t)throw new HO("Feed dict has no SymbolicTensor name: "+e);return this.id2Value[t]},t.getMask=function(e){if(e instanceof OM){if(null==this.id2Value[e.id])throw new HO("Nonexistent key: "+e.name);return this.id2Mask[e.id]}var t=this.name2Id[e];if(null==t)throw new HO("Feed dict has no SymbolicTensor name: "+e);return this.id2Mask[t]},t.disposeMasks=function(){null!=this.id2Mask&&tI(this.id2Mask)},e}(),UM=new XO,GM=new XO;function jM(e,t,n,r){for(var a,i=null!=n&&n.training,o=Array.isArray(e),s=o?e:[e],u=s.map((function(e){return e.name})),l=[],c=t.names(),p=Lv(u);!(a=p()).done;){var h=a.value;-1!==c.indexOf(h)?l.push(t.getValue(h)):l.push(null)}null!=r&&(r.maxNumTensors=-1/0,r.minNumTensors=1/0);var d,f=u.join(",")+"|"+t.names().sort().join(","),m=UM.get(f);if(null==m){var v=function(e,t){Hv(null!=e&&e.length>0,(function(){return"Expected at least one fetch, got none"}));var n=[],r={};if(1===e.length){var a=qM(e[0],t);n=a.sorted,r=a.recipientMap}else for(var i,o=new Set,s=Lv(e);!(i=s()).done;){for(var u,l=qM(i.value,t),c=l.sorted,p=l.recipientMap,h=Lv(c);!(u=h()).done;){var d=u.value;o.has(d.name)||(n.push(d),o.add(d.name))}var f=function(e){null==r[e]&&(r[e]=new Set),p[e].forEach((function(t){return r[e].add(t)}))};for(var m in p)f(m)}return{sorted:n,recipientCounts:HM(r)}}(s,t);m=v.sorted,d=v.recipientCounts,UM.put(f,m),GM.put(f,d)}d={},i||Object.assign(d,GM.get(f));for(var g=new VM(t),y=0;y<m.length;++y){if(null!=r){var b=$N().numTensors;b>r.maxNumTensors&&(r.maxNumTensors=b),b<r.minNumTensors&&(r.minNumTensors=b)}var x=m[y],w=x.sourceLayer;if(!(w instanceof BM)){for(var k,N=[],I=[],S=[],T=!1,C=Lv(x.inputs);!(k=C()).done;){var E=k.value,A=g.getValue(E),R=g.getMask(E);N.push(A),I.push(R),null!=R&&(T=!0),i||(d[E.name]--,0!==d[E.name]||t.hasKey(E)||-1!==u.indexOf(E.name)||A.isDisposed||!0===E.sourceLayer.stateful||S.push(A))}T&&((n=n||{}).mask=I[0]);var _=$O(w.apply(N,n)),F=null;w.supportsMasking&&(F=w.computeMask(N,I));for(var O=KM(x),D=Array.isArray(O)?O:[O],M=0;M<D.length;++M){g.hasKey(D[M])||g.add(D[M],_[M],Array.isArray(F)?F[0]:F);var L=u.indexOf(D[M].name);-1!==L&&(l[L]=_[M])}i||tI(S)}}return g.disposeMasks(),o?l:l[0]}function HM(e){var t={};for(var n in e)t[n]=e[n].size;return t}function qM(e,t){for(var n,r=new Set,a=[],i={},o=Lv(t.names());!(n=o()).done;){var s=n.value;r.add(s)}var u=[],l=[];for(u.push(e);u.length>0;){var c=u[u.length-1];if(r.has(c.name))u.pop();else{var p=l[l.length-1]===u.length-1;if(0===c.inputs.length||p)u.pop(),a.push(c),r.add(c.name),p&&l.pop();else{l.push(u.length-1);for(var h,d=Lv(c.inputs);!(h=d()).done;){var f=h.value;null==i[f.name]&&(i[f.name]=new Set),i[f.name].add(c.name),r.has(f.name)||u.push(f)}}}}return{sorted:a,recipientMap:i}}function KM(e){var t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{for(var n=null,r=0;r<e.sourceLayer.inboundNodes.length;++r)for(var a,i=Lv(e.sourceLayer.inboundNodes[r].outputTensors);!(a=i()).done;){if(a.value.id===e.id){n=r;break}}t=e.sourceLayer.getOutputAt(n)}return t}function XM(e,t){return eI((function(){return XS(JS(lI(e,e),t,!0))}))}Fg().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",(function(){return 100}),(function(e){null!=UM&&UM.setMaxEntries(e),null!=GM&&GM.setMaxEntries(e)}));var YM=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.getConfig=function(){return{}},t}(pR),JM=function(e){function t(t){var n;return(n=e.call(this)||this).defaultMaxValue=2,n.defaultAxis=0,n.maxValue=null!=t.maxValue?t.maxValue:n.defaultMaxValue,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}Cv(t,e);var n=t.prototype;return n.apply=function(e){var t=this;return eI((function(){var n=XM(e,t.axis),r=rS(n,0,t.maxValue);return lI(e,uI(r,oI(PD(),n)))}))},n.getConfig=function(){return{maxValue:this.maxValue,axis:this.axis}},t}(YM);JM.className="MaxNorm",dR(JM);var ZM=function(e){function t(t){var n;return(n=e.call(this)||this).defaultAxis=0,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}Cv(t,e);var n=t.prototype;return n.apply=function(e){var t=this;return eI((function(){return uI(e,oI(PD(),XM(e,t.axis)))}))},n.getConfig=function(){return{axis:this.axis}},t}(YM);ZM.className="UnitNorm",dR(ZM);var QM=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return zC(e)},t}(YM);QM.className="NonNeg",dR(QM);var $M=function(e){function t(t){var n;return(n=e.call(this)||this).defaultMinValue=0,n.defaultMaxValue=1,n.defaultRate=1,n.defaultAxis=0,n.minValue=null!=t.minValue?t.minValue:n.defaultMinValue,n.maxValue=null!=t.maxValue?t.maxValue:n.defaultMaxValue,n.rate=null!=t.rate?t.rate:n.defaultRate,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}Cv(t,e);var n=t.prototype;return n.apply=function(e){var t=this;return eI((function(){var n=XM(e,t.axis),r=oI(lI(t.rate,rS(n,t.minValue,t.maxValue)),lI(1-t.rate,n));return lI(e,uI(r,oI(PD(),n)))}))},n.getConfig=function(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}},t}(YM);$M.className="MinMaxNorm",dR($M);var eL={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function tL(e){return rD(e)}function nL(e,t){return void 0===t&&(t={}),iD(e,hR.getMap().classNameMap,t,"constraint")}function rL(e){return null==e?null:"string"==typeof e?nL({className:e in eL?eL[e]:e,config:{}}):e instanceof YM?e:nL(e)}var aL={__proto__:null,maxNorm:function(e){return new JM(e)},unitNorm:function(e){return new ZM(e)},nonNeg:function(){return new QM},minMaxNorm:function(e){return new $M(e)}};var iL,oL={__proto__:null,zeros:function(){return new aM},ones:function(){return new iM},constant:function(e){return new oM(e)},randomUniform:function(e){return new sM(e)},randomNormal:function(e){return new uM(e)},truncatedNormal:function(e){return new lM(e)},identity:function(e){return new cM(e)},varianceScaling:function(e){return new pM(e)},glorotUniform:function(e){return new hM(e)},glorotNormal:function(e){return new dM(e)},heNormal:function(e){return new fM(e)},heUniform:function(e){return new mM(e)},leCunNormal:function(e){return new vM(e)},leCunUniform:function(e){return new gM(e)},orthogonal:function(e){return new yM(e)}};function sL(e){return uL.apply(this,arguments)}function uL(){return uL=Iv(kv().mark((function e(t){var n,r,a,i,o,s,u,l;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}return e.abrupt("return");case 2:for(i in n=[],r=[],a=[],t)"number"!=typeof(o=t[i])&&(s=o,n.push(s.data()),r.push(i),a.push(s));if(!(n.length>0)){e.next=12;break}return e.next=9,Promise.all(n);case 9:for(u=e.sent,l=0;l<u.length;++l)t[r[l]]=u[l][0];tI(a);case 12:case"end":return e.stop()}}),e)}))),uL.apply(this,arguments)}function lL(e){if(null!=e)for(var t in e){var n=e[t];"number"!=typeof n&&n.dispose()}}!function(e){e[e.SILENT=0]="SILENT",e[e.VERBOSE=1]="VERBOSE"}(iL||(iL={}));var cL=function(){function e(){this.validationData=null}var t=e.prototype;return t.setParams=function(e){this.params=e},t.onEpochBegin=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.onEpochEnd=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.onBatchBegin=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.onBatchEnd=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.onTrainBegin=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.onTrainEnd=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.setModel=function(e){},e}(),pL=function(){function e(e,t){void 0===t&&(t=10),null==e&&(e=[]),this.callbacks=e,this.queueLength=t}var t=e.prototype;return t.append=function(e){this.callbacks.push(e)},t.setParams=function(e){for(var t,n=Lv(this.callbacks);!(t=n()).done;){t.value.setParams(e)}},t.setModel=function(e){for(var t,n=Lv(this.callbacks);!(t=n()).done;){t.value.setModel(e)}},t.onEpochBegin=function(){var e=Iv(kv().mark((function e(t,n){var r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=Lv(this.callbacks);case 2:if((a=r()).done){e.next=8;break}return i=a.value,e.next=6,i.onEpochBegin(t,n);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.onEpochEnd=function(){var e=Iv(kv().mark((function e(t,n){var r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=Lv(this.callbacks);case 2:if((a=r()).done){e.next=8;break}return i=a.value,e.next=6,i.onEpochEnd(t,n);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.onBatchBegin=function(){var e=Iv(kv().mark((function e(t,n){var r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=Lv(this.callbacks);case 2:if((a=r()).done){e.next=8;break}return i=a.value,e.next=6,i.onBatchBegin(t,n);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.onBatchEnd=function(){var e=Iv(kv().mark((function e(t,n){var r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=Lv(this.callbacks);case 2:if((a=r()).done){e.next=8;break}return i=a.value,e.next=6,i.onBatchEnd(t,n);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.onTrainBegin=function(){var e=Iv(kv().mark((function e(t){var n,r,a;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==t&&(t={}),n=Lv(this.callbacks);case 2:if((r=n()).done){e.next=8;break}return a=r.value,e.next=6,a.onTrainBegin(t);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.onTrainEnd=function(){var e=Iv(kv().mark((function e(t){var n,r,a;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==t&&(t={}),n=Lv(this.callbacks);case 2:if((r=n()).done){e.next=8;break}return a=r.value,e.next=6,a.onTrainEnd(t);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}(),hL=function(e){function t(){return e.call(this)||this}Cv(t,e);var n=t.prototype;return n.onEpochBegin=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.seen=0,this.totals={};case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.onBatchEnd=function(){var e=Iv(kv().mark((function e(t,n){var r,a,i,o=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(i in null==n&&(n={}),r=null==n.size?0:n.size,this.seen+=r,a=function(e){var t=n[e];if("number"==typeof t)o.totals.hasOwnProperty(e)||(o.totals[e]=0),o.totals[e]=o.totals[e]+t*r;else{var a;e in o.totals?a=o.totals[e]:o.totals[e]=0;var i=eI((function(){return oI(o.totals[e],lI(t,r))}));o.totals[e]=i,null!=a&&a.dispose()}},n)a(i);case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onEpochEnd=function(){var e=Iv(kv().mark((function e(t,n){var r,a,i,o=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n){e.next=9;break}r=function(){var e=i.value;if(null==o.totals[e])return"continue";"number"==typeof o.totals[e]?n[e]=o.totals[e]/o.seen:eI((function(){var t=lI(uI(1,o.seen),o.totals[e]);n[e]=t,o.totals[e].dispose(),nI(n[e])}))},a=Lv(this.params.metrics);case 3:if((i=a()).done){e.next=9;break}if("continue"!==r()){e.next=7;break}return e.abrupt("continue",7);case 7:e.next=3;break;case 9:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t}(cL),dL=function(e){function t(){return e.apply(this,arguments)||this}Cv(t,e);var n=t.prototype;return n.onTrainBegin=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.epoch=[],this.history={};case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.onEpochEnd=function(){var e=Iv(kv().mark((function e(t,n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r in null==n&&(n={}),this.epoch.push(t),n)null==this.history[r]&&(this.history[r]=[]),this.history[r].push(n[r]);case 3:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.syncData=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o,s,u,l;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(a in t=[],n=[],r=[],this.history)for(i=this.history[a],o=0;o<i.length;++o)"number"!=typeof i[o]&&(s=i[o],t.push(s.data()),n.push(a),r.push(o));return e.next=6,Promise.all(t);case 6:for(u=e.sent,l=0;l<u.length;++l)this.history[n[l]][r[l]].dispose(),this.history[n[l]][r[l]]=u[l][0];case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(cL),fL=function(e){function t(t,n){var r;if((r=e.call(this)||this).currentEpoch=0,r.nowFunc=t.nowFunc,r.nextFrameFunc=t.nextFrameFunc||w_,r.yieldEvery=n||"auto","auto"===r.yieldEvery&&(r.yieldEvery=125),"never"===r.yieldEvery&&null!=t.onYield)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");return hg(r.yieldEvery)&&(r.maybeWait=function(e,t,n){var r,a=null!=n?n():Vw();return function(){var i=null!=n?n():Vw();return i-a<t?r:(a=i,r=e.apply(void 0,arguments))}}(r.maybeWait.bind(Ov(r)),r.yieldEvery,r.nowFunc)),r.trainBegin=t.onTrainBegin,r.trainEnd=t.onTrainEnd,r.epochBegin=t.onEpochBegin,r.epochEnd=t.onEpochEnd,r.batchBegin=t.onBatchBegin,r.batchEnd=t.onBatchEnd,r.yield=t.onYield,r}Cv(t,e);var n=t.prototype;return n.maybeWait=function(){var e=Iv(kv().mark((function e(t,n,r){var a;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=[],null==this.yield){e.next=5;break}return e.next=4,sL(r);case 4:a.push(this.yield(t,n,r));case 5:return a.push(this.nextFrameFunc()),e.next=8,Promise.all(a);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),n.onEpochBegin=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.currentEpoch=t,null==this.epochBegin){e.next=6;break}return e.next=4,sL(n);case 4:return e.next=6,this.epochBegin(t,n);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onEpochEnd=function(){var e=Iv(kv().mark((function e(t,n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=[],null==this.epochEnd){e.next=5;break}return e.next=4,sL(n);case 4:r.push(this.epochEnd(t,n));case 5:return"epoch"===this.yieldEvery&&r.push(this.nextFrameFunc()),e.next=8,Promise.all(r);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onBatchBegin=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.batchBegin){e.next=5;break}return e.next=3,sL(n);case 3:return e.next=5,this.batchBegin(t,n);case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onBatchEnd=function(){var e=Iv(kv().mark((function e(t,n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=[],null==this.batchEnd){e.next=5;break}return e.next=4,sL(n);case 4:r.push(this.batchEnd(t,n));case 5:return"batch"===this.yieldEvery?r.push(this.nextFrameFunc()):hg(this.yieldEvery)&&r.push(this.maybeWait(this.currentEpoch,t,n)),e.next=8,Promise.all(r);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onTrainBegin=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.trainBegin){e.next=5;break}return e.next=3,sL(t);case 3:return e.next=5,this.trainBegin(t);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.onTrainEnd=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.trainEnd){e.next=5;break}return e.next=3,sL(t);case 3:return e.next=5,this.trainEnd(t);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(cL);function mL(e,t){return null==e&&(e={}),e instanceof cL?[e]:Array.isArray(e)&&e[0]instanceof cL?e:$O(e).map((function(e){return new fL(e,t)}))}var vL=function(){function e(){}return e.registerCallbackConstructor=function(t,n){Hv(t>=0&&Number.isInteger(t),(function(){return"Verbosity level is expected to be an integer >= 0, but got "+t})),e.checkForDuplicate(n),null==e.constructors[t]&&(e.constructors[t]=[]),e.constructors[t].push(n)},e.checkForDuplicate=function(t){for(var n in e.constructors){e.constructors[+n].forEach((function(e){if(e===t)throw new HO("Duplicate callback constructor.")}))}},e.clear=function(){e.constructors={}},e.createCallbacks=function(t){var n=[];for(var r in e.constructors){var a=+r;t>=a&&n.push.apply(n,e.constructors[a])}return n.map((function(e){return new e}))},e}();function gL(e,t,n,r,a,i,o,s,u){var l=new dL,c=[new hL].concat(vL.createCallbacks(t));null!=e&&c.push.apply(c,e),c.push(l);var p=new pL(c);return p.setParams({epochs:n,initialEpoch:r,samples:a,steps:i,batchSize:o,verbose:t,doValidation:s,metrics:u}),{callbackList:p,history:l}}function yL(e,t,n){return void 0===t&&(t={}),void 0===n&&(n=!1),iD(e,hR.getMap().classNameMap,t,"layer",n)}function bL(e,t){return eI((function(){"float32"!==e.dtype&&(e=XN(e,"float32"));var n=JS(JD(e),t,!0),r=nS(n.shape,PD()),a=XS(BT(n,r));return uI(e,a)}))}function xL(e,t){return eI((function(){return WT(JD(TT(t,e)),-1)}))}function wL(e,t){return eI((function(){return WT(cI(TT(t,e)),-1)}))}function kL(e,t){return eI((function(){var n=TT(e,t),r=rS(cI(e),PD(),Number.MAX_VALUE),a=cI(uI(n,r));return lI(100,WT(a,-1))}))}function NL(e,t){return eI((function(){var n=rS(t,PD(),Number.MAX_VALUE),r=yT(oI(1,n)),a=rS(e,PD(),Number.MAX_VALUE),i=yT(oI(1,a));return WT(JD(TT(r,i)),-1)}))}function IL(e,t,n){return void 0===n&&(n=!1),eI((function(){if(n)t=rE(t);else{var r=JS(t,t.shape.length-1,!0);t=uI(t,r)}return t=rS(t,PD(),1-PD()),NT(JS(lI(XN(e,"float32"),yT(t)),t.shape.length-1))}))}function SL(e,t,n){return void 0===n&&(n=!1),eI((function(){var r,a,i=XN(iT((a=[DD((r=e).shape)],PI(r,a))),"int32"),o=(t=rS(t,PD(),1-PD())).shape;return IL(PI(ZT(i,o[o.length-1]),o),t,n)}))}function TL(e,t){return eI((function(){var n;return n=rS(t,PD(),1-PD()),n=yT(uI(n,TT(1,n))),WT(function(e,t){if(!Yv(e.shape,t.shape))throw new HO("logits and labels must have the same shape, but got shapes "+JSON.stringify(e.shape)+" and "+JSON.stringify(t.shape));return eI((function(){var n=zC(t),r=NT(cI(t));return oI(TT(n,lI(t,e)),bT(eT(r)))}))}(e,n),-1)}))}function CL(e,t){return eI((function(){var n=rS(e,PD(),1),r=rS(t,PD(),1);return JS(lI(e,yT(uI(n,r))),-1)}))}function EL(e,t){return eI((function(){var n=bL(e,-1),r=bL(t,-1),a=lI(n,r);return NT(JS(a,-1))}))}vL.constructors={};var AL={meanSquaredError:xL,meanAbsoluteError:wL,meanAbsolutePercentageError:kL,meanSquaredLogarithmicError:NL,squaredHinge:function(e,t){return eI((function(){var n=BT(0,TT(1,lI(e,t)));return WT(JD(n),-1)}))},hinge:function(e,t){return eI((function(){var n=BT(0,TT(1,lI(e,t)));return WT(n,-1)}))},categoricalHinge:function(e,t){return eI((function(){var n=JS(lI(e,t),-1),r=jS(lI(TT(1,e),t),-1);return BT(0,oI(1,TT(r,n)))}))},logcosh:function(e,t){return eI((function(){var n=Math.log(2),r=TT(t,e),a=TT(oI(r,IT(lI(-2,r))),n);return WT(a,-1)}))},categoricalCrossentropy:IL,sparseCategoricalCrossentropy:SL,binaryCrossentropy:TL,kullbackLeiblerDivergence:CL,poisson:function(e,t){return eI((function(){var n=yT(oI(PD(),t));return WT(TT(t,lI(e,n)),-1)}))},cosineProximity:EL};function RL(e){if("string"==typeof e){if(e in AL)return AL[e];var t="Unknown loss "+e;throw e.toLowerCase().includes("softmaxcrossentropy")&&(t="Unknown loss "+e+'. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'),new HO(t)}return e}function _L(e,t){return eI((function(){var n=lI(.5,QT(t)),r=BD(sT(t,n),e.dtype);return WT(ES(e,r),-1)}))}function FL(e,t){return eI((function(){return BD(ES(vI(e,-1),vI(t,-1)),"float32")}))}function OL(e,t){return eI((function(){return XN(JS(AT(ES(e,1),ES(t,1))),"float32")}))}function DL(e,t){return eI((function(){var n=OL(e,t),r=function(e,t){return eI((function(){return XN(JS(AT(ES(e,0),ES(t,1))),"float32")}))}(e,t),a=oI(n,r);return XN(AS(sT(a,0),uI(n,a),0),"float32")}))}function ML(e,t){return eI((function(){var n=OL(e,t),r=function(e,t){return eI((function(){return XN(JS(AT(ES(e,1),ES(t,0))),"float32")}))}(e,t),a=oI(n,r);return XN(AS(sT(a,0),uI(n,a),0),"float32")}))}function LL(e,t){return TL(e,t)}function zL(e,t){return e.rank===t.rank&&(e=cE(e,[e.rank-1])),(t=vI(t,-1)).dtype!==e.dtype&&(t=XN(t,e.dtype)),XN(ES(e,t),"float32")}var PL=IL,BL=SL,WL={binaryAccuracy:_L,categoricalAccuracy:FL,precision:DL,categoricalCrossentropy:PL,sparseCategoricalCrossentropy:BL,mse:xL,MSE:xL,mae:wL,MAE:wL,mape:kL,MAPE:kL,cosine:EL};function VL(e){if("string"==typeof e&&e in WL)return WL[e];if("string"!=typeof e&&null!=e)return e;throw new HO("Unknown metric "+e)}function UL(e){if(JO(null!==e,"Unknown LossOrMetricFn "+e),"string"==typeof e)return e;for(var t,n=0,r=Object.keys(AL);n<r.length;n++){var a=r[n];if(AL[a]===e){t=a;break}}if(void 0!==t)return t;for(var i=0,o=Object.keys(WL);i<o.length;i++){var s=o[i];if(WL[s]===e){t=s;break}}return void 0!==t?t:e.name}var GL=1048576;function jL(e,t,n){if(void 0===n&&(n=!1),null==e||"object"!=typeof e||Object.getPrototypeOf(e)!==Object.prototype||!HL(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){var r=JSON.stringify(e);r.length>GL&&console.warn('User-defined metadata of model "'+t+'" is too large in size (length='+r.length+" when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.")}}function HL(e){if(null===e)return!0;if("object"==typeof e){if(Object.getPrototypeOf(e)===Object.prototype){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if("string"!=typeof r)return!1;if(!HL(e[r]))return!1}return!0}if(Array.isArray(e)){for(var a,i=Lv(e);!(a=i()).done;){if(!HL(a.value))return!1}return!0}return!1}var o=typeof e;return"string"===o||"number"===o||"boolean"===o}function qL(e,t,n,r){void 0===r&&(r=console.log);var a,i=function(e){var t=!0,n=[],r=[];for(var a in e.nodesByDepth)n.push(e.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){t=!1;break}r.push.apply(r,s)}if(t)for(var u,l=Lv(e.layers);!(u=l()).done;){for(var c,p=!1,h=Lv(u.value.inboundNodes);!(c=h()).done;){var d=c.value;if(-1!==r.indexOf(d)){if(p){t=!1;break}p=!0}}if(!t)break}return t}(e),o=["Layer (type)","Input Shape","Output shape","Param #"];if(i?(t=t||90,n=n||[.32,.61,.89,1]):(t=t||115,n=n||[.24,.48,.7,.8,1]),n[n.length-1]<=1&&(n=n.map((function(e){return Math.floor(t*e)}))),!i)for(var s in o.push("Receives inputs"),a=[],e.nodesByDepth){var u;(u=a).push.apply(u,e.nodesByDepth[s])}r("_".repeat(t)),KL(o,n,r),r("=".repeat(t));for(var l=e.layers,c=0;c<l.length;++c)i?XL(l[c],n,r):YL(l[c],n,a,r),r((c===l.length-1?"=":"_").repeat(t));e.checkTrainableWeightsConsistency();var p=function(e){var t;t=null!=e.collectedTrainableWeights?CM(e.collectedTrainableWeights):CM(e.trainableWeights);return t}(e),h=CM(e.nonTrainableWeights);r("Total params: "+(p+h)),r("Trainable params: "+p),r("Non-trainable params: "+h),r("_".repeat(t))}function KL(e,t,n){void 0===n&&(n=console.log);for(var r="",a=0;a<e.length;++a)a>0&&(r=r.slice(0,r.length-1)+" "),r=(r+=e[a]).slice(0,t[a]),r+=" ".repeat(t[a]-r.length);n(r)}function XL(e,t,n){var r,a;try{a=e.inboundNodes.map((function(e){return JSON.stringify(e.inputShapes)})).join(",")}catch(e){a="multiple"}try{r=JSON.stringify(e.outputShape)}catch(e){r="multiple"}KL([e.name+" ("+e.getClassName()+")",a,r,e.countParams().toString()],t,n)}function YL(e,t,n,r){var a,i;try{i=e.inboundNodes.map((function(e){return JSON.stringify(e.inputShapes)})).join(",")}catch(e){i="multiple"}try{a=JSON.stringify(e.outputShape)}catch(e){a="multiple"}for(var o,s=[],u=Lv(e.inboundNodes);!(o=u()).done;){var l=o.value;if(!(null!=n&&n.length>0&&-1===n.indexOf(l)))for(var c=0;c<l.inboundLayers.length;++c){var p=l.inboundLayers[c].name,h=l.nodeIndices[c],d=l.tensorIndices[c];s.push(p+"["+h+"]["+d+"]")}}var f=e.name,m=e.getClassName(),v=0===s.length?"":s[0];KL([f+" ("+m+")",i,a,e.countParams().toString(),v],t,r);for(var g=1;g<s.length;++g)KL(["","","","",s[g]],t,r)}function JL(e,t,n){return("inboundNodes"===e||"outputLayers"===e||"inputLayers"===e)&&0===t&&"string"==typeof n}function ZL(e,t){if(null===e)return null;if("string"==typeof e)return tD(e);if("number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Array){for(var n=[],r=e.length,a=0;a<r;++a){var i=e[a];JL(t,a,i)?n.push(i):n.push(ZL(i,t))}return n}for(var o={},s=0,u=Object.keys(e);s<u.length;s++){var l=u[s],c=e[l];if("name"===l&&"string"==typeof c)o[l]=c;else{var p=tD(l);o[p]=ZL(c,p)}}return o}function QL(e,t){if(null==e)return null;if("string"==typeof e)return eD(e);if("number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Array){for(var n=[],r=e.length,a=0;a<r;++a){var i=e[a];JL(t,a,i)?n.push(i):n.push(QL(i,t))}return n}for(var o={},s=0,u=Object.keys(e);s<u.length;s++){var l=u[s],c=e[l],p=eD(l);o[p]="name"!==l&&"className"!==l||"string"!=typeof c?QL(c,l):c}return o}var $L="4.3.0",ez=function(e){function t(n){var r;if((r=e.call(this,{})||this).containerNodes=new Set,r.name=n.name,null==r.name){var a=r.getClassName().toLowerCase();r.name=gD(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],sD(r.inputs).length!==r.inputs.length)throw new HO("The list of inputs passed to the model is redundant. All inputs should only appear once. Found: "+r.inputs.map((function(e){return e.name})));sD(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(e){return e.name}))),r.inputLayers=[],r.inputLayersNodeIndices=[],r.inputLayersTensorIndices=[],r.outputLayers=[],r.outputLayersNodeIndices=[],r.outputLayersTensorIndices=[],r.layers=[],r.internalContainerRefs=[];for(var i,o=Lv(r.outputs);!(i=o()).done;){var s=i.value,u=s.sourceLayer,l=s.nodeIndex,c=s.tensorIndex;r.outputLayers.push(u),r.outputLayersNodeIndices.push(l),r.outputLayersTensorIndices.push(c)}for(var p,h=Lv(r.inputs);!(p=h()).done;){var d=p.value,f=d.sourceLayer,m=d.nodeIndex,v=d.tensorIndex;JO(0===m,"input layer has >1 nodes"),JO(0===v,"input layer has >1 tensors"),r.inputLayers.push(f),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 BM))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=Lv(r.outputLayers);!(b=x()).done;){var w=b.value;r.outputNames.push(w.name)}r.internalInputShapes=r.inputs.map((function(e){return e.shape})),r.internalOutputShapes=r.outputs.map((function(e){return e.shape}));for(var k,N={},I={},S={},T={},C={},E=[],A=function e(n,a,i,o,s,u){null!=o&&null!=s&&null!=u||(o=n.sourceLayer,s=n.nodeIndex,u=n.tensorIndex);var l=o.inboundNodes[s];if(-1!==i.indexOf(l))throw new jO("The tensor "+n.name+' at layer "'+o.name+'" is part of a cycle.');if(-1===a.indexOf(l)){r.containerNodes.add(t.nodeKey(o,s)),o.id in C||(C[o.id]=Object.keys(C).length),-1===i.indexOf(l)&&i.push(l);for(var c=l.inboundLayers.length,p=0;p<c;p++){e(l.inputTensors[p],a,i,l.inboundLayers[p],l.nodeIndices[p],l.tensorIndices[p])}for(a.push(l);i.indexOf(l)>=0;)i.splice(i.indexOf(l),1);E.push(l)}},R=[],_=[],F=Lv(r.outputs);!(k=F()).done;){A(k.value,R,_)}for(var O,D=Lv(E.slice().reverse());!(O=D()).done;){var M=O.value;I[M.id]=M,M.id in N||(N[M.id]=0);var L=N[M.id],z=null==S[M.outboundLayer.id]?0:S[M.outboundLayer.id];L=Math.max(L,z),S[M.outboundLayer.id]=L,T[M.outboundLayer.id]=M.outboundLayer,N[M.id]=L;for(var P=0;P<M.inboundLayers.length;P++){var B=M.inboundLayers[P],W=M.nodeIndices[P],V=B.inboundNodes[W],U=null==N[V.id]?0:N[V.id];N[V.id]=Math.max(L+1,U),I[V.id]=V}}var G={};for(var j in N){var H=N[j];H in G||(G[H]=[]),G[H].push(I[j])}var q={};for(var K in S){var X=S[K];X in q||(q[X]=[]),q[X].push(T[K])}var Y=Object.keys(q).map((function(e){return parseInt(e,10)})).sort(oD);r.layers=[];for(var J,Z=Lv(Y);!(J=Z()).done;){var Q=q[J.value];Q.sort((function(e,t){var n=C[e.id],r=C[t.id];return n<r?-1:n>r?1:0}));for(var $,ee=Lv(Q);!($=ee()).done;){var te=$.value;te instanceof t&&r.internalContainerRefs.push(te),r.layers.push(te)}}r.layersByDepth=q,Y=Object.keys(G).map((function(e){return parseInt(e,10)})).sort(oD);for(var ne,re=r.inputs.slice(),ae=[],ie=Lv(Y);!(ne=ie()).done;)for(var oe,se=Lv(G[ne.value]);!(oe=se()).done;){var ue=oe.value,le=ue.outboundLayer;if(null!=le){for(var ce,pe=Lv(ue.inputTensors);!(ce=pe()).done;){var he=ce.value;if(-1===re.indexOf(he))throw new jO("Graph disconnected: cannot obtain value for tensor "+he+' at layer "'+le.name+'". The following previous layers were accessed without issue: '+ae)}for(var de,fe=Lv(ue.outputTensors);!(de=fe()).done;){var me=de.value;re.push(me)}ae.push(le.name)}}r.nodesByDepth=G;for(var ve,ge=r.layers.map((function(e){return e.name})),ye=function(){var e=ve.value,t=ge.filter((function(t){return t===e})).length;if(1!==t)throw new jO('The name "'+e+'" is used '+t+" times in the model. All layer names should be unique. Layer names: "+JSON.stringify(ge))},be=Lv(ge);!(ve=be()).done;)ye();return r.outboundNodes=[],r.inboundNodes=[],new MM({outboundLayer:Ov(r),inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:r.inputs,outputTensors:r.outputs,inputMasks:r.inputs.map((function(e){return null})),outputMasks:r.outputs.map((function(e){return null})),inputShapes:r.inputs.map((function(e){return e.shape})),outputShapes:r.outputs.map((function(e){return e.shape}))}),r.built=!0,r._refCount=1,r}Cv(t,e);var n=t.prototype;return n.assertNotDisposed=function(){if(0===this._refCount)throw new Error("Container '"+this.name+"' is already disposed.")},n.dispose=function(){this.assertNotDisposed();var e={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(var t,n=Lv(this.layers);!(t=n()).done;){var r=t.value;e.numDisposedVariables+=r.dispose().numDisposedVariables}for(var a,i=Lv(this.internalContainerRefs);!(a=i()).done;){var o=a.value;e.numDisposedVariables+=o.dispose().numDisposedVariables}}return e.refCountAfterDispose=this._refCount,e},n.loadWeights=function(e,t){void 0===t&&(t=!0);for(var n,r={},a=0,i=Lv(this.layers);!(n=i()).done;)for(var o,s=Lv(n.value.weights);!(o=s()).done;){var u=o.value;if(null!=r[u.originalName])throw new HO("Duplicate weight name: "+u.originalName);r[u.originalName]=u,a++}var l=[];for(var c in e){var p=c;if(null==r[c]){var h=c.split("/");p=h.slice(0,-2).concat([h[h.length-1]]).join("/")}if(null!=r[p])l.push([r[p],e[c]]);else if(t)throw new HO("Provided weight data has no target variable: "+c);delete r[p]}if(t){var d=[];for(var f in r)d.push(f);if(d.length>0)throw new HO(d.length+" of "+a+" weights are not set: "+d)}_M(l)},n.updatedConfig=function(){var e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion="tfjs-layers 4.3.0",t.backend="TensorFlow.js",t},n.toJSON=function(e,t){void 0===t&&(t=!0);var n=QL(this.updatedConfig());return t?JSON.stringify(n):n},n.call=function(e,t){var n=this;return eI((function(){e=$O(e);for(var r=new VM,a=0;a<n.inputs.length;++a)r.add(n.inputs[a],e[a]);return jM(n.outputs,r,t)}))},n.computeMask=function(e,t){var n=this;return eI((function(){var r;return e=$O(e),r=null==t?YO(null,e.length):$O(t),n.runInternalGraph(e,r)[1]}))},n.computeOutputShape=function(e){var t=IM(e);if(t.length!==this.inputLayers.length)throw new HO("Invalid inputShape argument "+e+": model has "+this.inputLayers.length+" tensor inputs.");for(var n={},r=0;r<t.length;r++){var a=this.inputLayers[r],i=t[r];n[a.name+"_0_0"]=i}var o=Object.keys(this.nodesByDepth).map((function(e){return parseInt(e,10)})).sort(oD);if(o.length>1)for(var s,u=Lv(o);!(s=u()).done;)for(var l,c=s.value,p=Lv(this.nodesByDepth[c]);!(l=p()).done;){var h=l.value,d=h.outboundLayer;if(-1===this.inputLayers.map((function(e){return e.id})).indexOf(d.id)){for(var f=[],m=0;m<h.inboundLayers.length;m++){var v=h.inboundLayers[m],g=h.nodeIndices[m],y=h.tensorIndices[m],b=n[v.name+"_"+g+"_"+y];f.push(b)}for(var x=IM(d.computeOutputShape(QO(f))),w=d.inboundNodes.indexOf(h),k=0;k<x.length;k++){n[d.name+"_"+w+"_"+k]=x[k]}}}for(var N=[],I=[],S=0;S<this.outputLayers.length;S++){var T=this.outputLayers[S],C=this.outputLayersNodeIndices[S],E=this.outputLayersTensorIndices[S],A=T.name+"_"+C+"_"+E;I.push(A)}for(var R=0;R<I.length;R++){var _=I[R];JO(_ in n),N.push(n[_])}return QO(N)},n.runInternalGraph=function(e,t){null==t&&(t=YO(null,e.length));for(var n={},r=0;r<this.inputs.length;++r){var a=this.inputs[r],i=e[r],o=t[r];n[a.id]=[i,o]}for(var s,u=Object.keys(this.nodesByDepth).map((function(e){return parseInt(e,10)})).sort(oD),l=Lv(u);!(s=l()).done;)for(var c,p=s.value,h=Lv(this.nodesByDepth[p]);!(c=h()).done;){for(var d,f=c.value,m=f.outboundLayer,v=f.inputTensors,g=f.outputTensors,y=new Array,b=Lv(v);!(d=b()).done;){var x=d.value;x.id in n&&y.push(n[x.id])}if(y.length===v.length){var w={},k=void 0,N=void 0,I=void 0,S=void 0;if(null!=f.callArgs&&(w=f.callArgs),1===y.length){var T=y[0],C=T[0],E=T[1];null==w.mask&&(w.mask=E),I=$O(m.call(C,w)),S=$O(m.computeMask(C,E)),k=[C],N=[E]}else k=y.map((function(e){return e[0]})),N=y.map((function(e){return e[1]})),null==w.mask&&(w.mask=N),I=$O(m.call(k,w)),S=$O(m.computeMask(k,N));if(m.activityRegularizer)throw new qO("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(var A=0;A<g.length;++A){var R=g[A],_=I[A],F=S[A];n[R.id]=[_,F]}}}for(var O,D=[],M=[],L=[],z=Lv(this.outputs);!(O=z()).done;){var P=O.value;JO(P.id in n,"Could not compute output "+P.name+" : "+P.id);var B=n[P.id],W=B[0],V=B[1];L.push(W.shape),D.push(W),M.push(V)}return[D,M,L]},n.buildNodeConversionMap=function(e){for(var n,r,a={},i=Lv(this.layers);!(r=i()).done;){var o=r.value;n=o instanceof t?1:0;for(var s=0;s<o.inboundNodes.length;s++){var u=t.nodeKey(o,s);this.containerNodes.has(u)&&(a[u]=n,n+=1)}}return a},n.getLayer=function(e,t){if(null!=t){if(this.layers.length<=t)throw new HO("Was asked to retrieve layer at index "+t+", but model only has "+this.layers.length+" layer(s).");return this.layers[t]}if(null==e)throw new HO("Provide either a layer name or layer index");for(var n,r=Lv(this.layers);!(n=r()).done;){var a=n.value;if(a.name===e)return a}throw new HO("No such layer: "+e)},n.calculateLosses=function(){var e=this;return eI((function(){for(var n,r=[],a=Lv(e.layers);!(n=a()).done;)for(var i=n.value,o=0;o<i.inboundNodes.length;++o){var s=t.nodeKey(i,o);e.containerNodes.has(s)&&r.push.apply(r,i.calculateLosses())}return r}))},n.getConfig=function(){for(var e,n={name:this.name},r=this.buildNodeConversionMap(this.layers),a=[],i=Lv(this.layers);!(e=i()).done;){for(var o=e.value,s=o.getClassName(),u=o.getConfig(),l=[],c=0;c<o.inboundNodes.length;c++){var p=o.inboundNodes[c],h=t.nodeKey(o,c),d={};if(this.containerNodes.has(h)){if(p.callArgs)try{JSON.stringify(p.callArgs),d=p.callArgs}catch(e){console.warn("Layer "+o.name+" was passed non-serializable keyword arguments: "+p.callArgs+". They will not be included in the serialized model (and thus will be missing at deserialization time)."),d={}}if(p.inboundLayers.length>0){for(var f=[],m=0;m<p.inboundLayers.length;m++){var v=p.inboundLayers[m],g=p.nodeIndices[m],y=p.tensorIndices[m],b=r[t.nodeKey(v,g)];null==b&&(b=0),f.push([v.name,b,y,d])}l.push(f)}}}var x={};x.name=o.name,x.className=s,x.config=u,x.inboundNodes=l,a.push(x)}n.layers=a;for(var w=[],k=0;k<this.inputLayers.length;k++){var N=this.inputLayers[k],I=this.inputLayersNodeIndices[k],S=t.nodeKey(N,I);if(this.containerNodes.has(S)){var T=r[S];null==T&&(T=0);var C=this.inputLayersTensorIndices[k];w.push([N.name,T,C])}}n.inputLayers=w;for(var E=[],A=0;A<this.outputLayers.length;A++){var R=this.outputLayers[A],_=this.outputLayersNodeIndices[A],F=t.nodeKey(R,_);if(this.containerNodes.has(F)){var O=r[F];null==O&&(O=0);var D=this.outputLayersTensorIndices[A];E.push([R.name,O,D])}}return n.outputLayers=E,n},t.fromConfig=function(e,t,n,r){void 0===n&&(n={}),void 0===r&&(r=!1);var a={},i={};function o(e,t){e.name in i?i[e.name].push(t):i[e.name]=[t]}function s(e,t){for(var n,r,i=[],s=Lv(t);!(r=s()).done;){var u=r.value,l=u[0],c=u[1],p=u[2];if(n=null==u[3]?{}:u[3],!(l in a))return void o(e,t);var h=a[l];if(h.inboundNodes.length<=c)return void o(e,t);var d=h.inboundNodes[c];i.push(d.outputTensors[p])}i.length>0&&e.apply(QO(i),n)}function u(e){var n=e.name,i=yL(e,null!=t.customObjects?t.customObjects:{});i.setFastWeightInitDuringBuild(r),a[n]=i,e.inboundNodes.forEach((function(e){if(!(e instanceof Array))throw new HO("Corrupted configuration, expected array for nodeData: "+e);o(i,e)}))}for(var l,c=t.name,p=t.layers,h=Lv(p);!(l=h()).done;){u(l.value)}for(;!uD(i);)for(var d,f=Lv(p);!(d=f()).done;){var m=d.value,v=a[m.name];if(v.name in i){var g=i[v.name];delete i[v.name];for(var y,b=Lv(g);!(y=b()).done;){s(v,y.value)}}}for(var x,w=[],k=[],N=Lv(t.inputLayers);!(x=N()).done;){var I=x.value,S=I[0],T=I[1],C=I[2];JO(S in a);var E=a[S].inboundNodes[T].outputTensors;w.push(E[C])}for(var A,R=Lv(t.outputLayers);!(A=R()).done;){var _=A.value,F=_[0],O=_[1],D=_[2];JO(F in a);var M=a[F].inboundNodes[O].outputTensors;k.push(M[D])}return new e({inputs:w,outputs:k,name:c})},n.resetStates=function(){var e=this;eI((function(){e.layers.forEach((function(e){e.stateful&&e.resetStates()}))}))},Tv(t,[{key:"trainable",get:function(){return this.trainable_},set:function(e){this.layers.forEach((function(t){t._trainableWeights.forEach((function(t){return t.trainable=e}))})),this.trainable_=e}},{key:"trainableWeights",get:function(){if(this._trainableWeights.length>0)throw new HO("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];for(var e,t=[],n=Lv(this.layers);!(e=n()).done;){var r=e.value;t=t.concat(r.trainableWeights)}return t}},{key:"nonTrainableWeights",get:function(){for(var e,t=[],n=Lv(this.layers);!(e=n()).done;){var r=e.value;t.push.apply(t,r.nonTrainableWeights)}if(!this.trainable){for(var a,i=[],o=Lv(this.layers);!(a=o()).done;){var s=a.value;i.push.apply(i,s.trainableWeights)}return i.concat(t)}return t}},{key:"weights",get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)}},{key:"stateful",get:function(){if(this._stateful)throw new HO("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 e,t=Lv(this.layers);!(e=t()).done;){if(e.value.stateful)return!0}return!1}}]),t}(zM);function tz(e,t,n){var r=t.length;if(null==e||Array.isArray(e)&&0===e.length)return t.map((function(e){return null}));if(1===r)return Array.isArray(e)&&1===e.length?e:"object"==typeof e&&t[0]in e?[e[t[0]]]:[e];if(Array.isArray(e)){if(e.length!==r)throw new Error("Provided "+n+" is an array of "+e.length+" element(s), but the model has "+r+" outputs. Make sure a set of weights is provided for each model output.");return e}if("object"==typeof e&&Object.keys(e).length>0&&"object"==typeof e[Object.keys(e)[0]]){var a=[];return t.forEach((function(t){t in e?a.push(e[t]):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 "+t+" keys. Provided "+n+" not understood: "+JSON.stringify(e))}function nz(e,t){return tz(e,t,"classWeight")}function rz(e,t,n,r){return az.apply(this,arguments)}function az(){return(az=Iv(kv().mark((function e(t,n,r,a){var i,o,s;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n&&null==a){e.next=2;break}throw new Error("Support sampleWeight is not implemented yet");case 2:if(null==r){e.next=15;break}return i=eI((function(){if(1===t.shape.length)return YN(t);if(2===t.shape.length){if(t.shape[1]>1){return vI(t,1)}if(1===t.shape[1])return PI(t,[t.shape[0]]);throw new Error("Encountered unexpected last-dimension size ("+t.shape[1]+") during handling of class weights. The size is expected to be >= 1.")}throw new Error("Unexpected rank of target (y) tensor ("+t.rank+") during handling of class weights. The rank is expected to be 1 or 2.")})),e.t0=Array,e.next=7,i.data();case 7:return e.t1=e.sent,o=e.t0.from.call(e.t0,e.t1),tI(i),s=[],o.forEach((function(e){if(null==r[e])throw new Error("classWeight must contain all classes in the training data. The class "+e+" exists in the data but not in classWeight");s.push(r[e])})),e.abrupt("return",mE(s,"float32"));case 15:return e.abrupt("return",null);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function iz(e,t){return lI(e,t)}function oz(e,t){var n,r,a=t;n=a.xs,r=a.ys,Hv(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 "+t}));var i=sz("input",e.inputNames,n),o=sz("output",e.outputNames,r),s=i[0].shape[0];Hv(i.length===e.inputs.length,(function(){return"LayersModel has "+e.inputs.length+" inputs, but the dataset provides "+i.length+" inputs. (Expected input keys: "+JSON.stringify(e.inputNames)+")"})),Hv(o.length===e.outputs.length,(function(){return"LayersModel has "+e.outputs.length+" outputs, but the dataset provides "+o.length+" outputs. (Expected output keys: "+JSON.stringify(e.outputNames)+")"}));for(var u=function(t){Hv(i[t].shape[0]===s,(function(){return"Batch size mismatch: input "+e.inputNames[t]+" has "+i[t].shape[0]+"; expected "+s+" based on input "+e.inputNames[0]+"."}))},l=0;l<i.length;l++)u(l);for(var c=function(t){Hv(o[t].shape[0]===s,(function(){return"Batch size mismatch: output "+e.outputNames[t]+" has "+o[t].shape[0]+"; expected "+s+" based on input "+e.inputNames[0]+"."}))},p=0;p<o.length;p++)c(p);return{xs:i,ys:o}}function sz(e,t,n){if(n instanceof ak)return[n];if(Array.isArray(n))return Hv(n.length===t.length,(function(){return"Received an array of "+n.length+" Tensors, but expected "+t.length+" to match the "+e+" keys "+t+"."})),n;for(var r,a=[],i=Lv(t);!(r=i()).done;){var o=r.value;if(null==n[o])throw new HO("The feature data generated by the dataset lacks the required "+e+" key '"+o+"'.");a.push(n[o])}return a}function uz(e){if(3===e.length)throw new qO("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}function lz(e,t,n){return cz.apply(this,arguments)}function cz(){return cz=Iv(kv().mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,d,f,m,v,g,y,b,x,w,k,N,I,S,T,C,E,A,R,_,F,O,D,M,L;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null!=r.batchesPerEpoch,Hv(null!=t.optimizer,(function(){return"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."})),Hv(null!=r,(function(){return"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."})),Hv(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})),Hv(!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})),Hv(null==r.validationSplit,(function(){return"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."})),!t.isTraining){e.next=8;break}throw new Error("Cannot start training because another fit() call is ongoing.");case 8:return t.isTraining=!0,e.prev=9,(i=null!=r.validationData)&&(hz(r.validationData)?Hv(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=uz(r.validationData),o=u.xs,s=u.ys)),l=t.makeTrainFunction(),c=t.getDedupedMetricsNames(),p=i?c.slice().concat(c.map((function(e){return"val_"+e}))):c.slice(),h=mL(r.callbacks,r.yieldEvery),d=null==r.verbose?1:r.verbose,f=gL(h,d,r.epochs,null,null,pz(n,r),null,i,p),m=f.callbackList,v=f.history,m.setModel(t),t.history=v,e.next=22,m.onTrainBegin();case 22:return t.stopTraining_=!1,g=null==r.initialEpoch?0:r.initialEpoch,e.next=26,n.iterator();case 26:y=e.sent;case 27:if(!(g<r.epochs)){e.next=98;break}return b={},e.next=31,m.onEpochBegin(g);case 31:if(x=0,w=0,a){e.next=37;break}return e.next=36,n.iterator();case 36:y=e.sent;case 37:if(a&&!(x<r.batchesPerEpoch)){e.next=91;break}return e.next=40,y.next();case 40:if(k=e.sent,!a||!k.done){e.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."),e.abrupt("break",91);case 44:if(null==k.value){e.next=73;break}return N=oz(t,k.value),I=N.xs,S=N.ys,(T={}).batch=w,T.size=I[0].shape[0],e.next=51,m.onBatchBegin(w,T);case 51:if(C=[],null==r.classWeight){e.next=64;break}E=nz(r.classWeight,t.outputNames),A=0;case 55:if(!(A<E.length)){e.next=64;break}return e.t0=C,e.next=59,rz(S[A],null,E[A]);case 59:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 61:++A,e.next=55;break;case 64:for(R=I.concat(S).concat(C),_=l(R),tI(R),F=0;F<c.length;++F)O=c[F],D=_[F],T[O]=D,nI(D);return e.next=70,m.onBatchEnd(w,T);case 70:lL(T),w++,x++;case 73:if(!(a?x>=r.batchesPerEpoch:k.done)){e.next=87;break}if(!i){e.next=86;break}if(M=void 0,!hz(r.validationData)){e.next=84;break}return e.t2=$O,e.next=80,t.evaluateDataset(r.validationData,{batches:r.validationBatches});case 80:e.t3=e.sent,M=(0,e.t2)(e.t3),e.next=85;break;case 84:M=$O(t.evaluate(o,s,{batchSize:null==r.validationBatchSize?32:r.validationBatchSize,verbose:0}));case 85:for(L=0;L<t.metricsNames.length;++L)b["val_"+t.metricsNames[L]]=M[L];case 86:return e.abrupt("break",91);case 87:if(!t.stopTraining_){e.next=89;break}return e.abrupt("break",91);case 89:e.next=37;break;case 91:return e.next=93,m.onEpochEnd(g,b);case 93:if(g++,!t.stopTraining_){e.next=96;break}return e.abrupt("break",98);case 96:e.next=27;break;case 98:return e.next=100,m.onTrainEnd();case 100:return e.next=102,t.history.syncData();case 102:return e.abrupt("return",t.history);case 103:return e.prev=103,t.isTraining=!1,e.finish(103);case 106:case"end":return e.stop()}}),e,null,[[9,,103,106]])}))),cz.apply(this,arguments)}function pz(e,t){var n=null;return null!=t.batchesPerEpoch?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}function hz(e){return"function"==typeof e.iterator}function dz(e){return"function"==typeof e.next}function fz(e,t,n){return mz.apply(this,arguments)}function mz(){return mz=Iv(kv().mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null!=(r=r||{}).batches,i=t.testFunction,o=[],!(r.verbose>0)){e.next=6;break}throw new qO("Verbose mode is not implemented yet.");case 6:if(Hv(!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)})),!dz(n)){e.next=11;break}e.t0=n,e.next=14;break;case 11:return e.next=13,n.iterator();case 13:e.t0=e.sent;case 14:s=e.t0,u=0,l=0,c=kv().mark((function e(){var n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.next();case 2:if(n=e.sent,o=eI((function(){return n.value&&function(){var e=oz(t,n.value),r=e.xs,a=e.ys,s=r.concat(a),c=eI((function(){return i(s)}));if(tI(s),0===l)for(var p=0;p<c.length;++p)o.push(KS(0));for(var h=s[0].shape[0],d=function(e){var t=c[e],n=o[e];o[e]=eI((function(){return oI(o[e],lI(h,t))})),l>0&&tI(n)},f=0;f<c.length;++f)d(f);tI(c),u+=h,++l}(),o})),!n.done){e.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."),e.abrupt("return","break");case 7:case"end":return e.stop()}}),e)}));case 18:if(a&&!(l<r.batches)){e.next=25;break}return e.delegateYield(c(),"t1",20);case 20:if("break"!==e.t1){e.next=23;break}return e.abrupt("break",25);case 23:e.next=18;break;case 25:for(p=0;p<o.length;++p)h=o[p],o[p]=uI(o[p],u),tI(h);return e.abrupt("return",QO(o));case 27:case"end":return e.stop()}}),e)}))),mz.apply(this,arguments)}function vz(e){Hv(e>0&&Number.isInteger(e),(function(){return"batchSize is required to be a positive integer, but got "+e}))}function gz(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((function(e){return VD(e,t,n-t)})):VD(e,t,n-t)}function yz(e,t){return eI((function(){return null==e?null:Array.isArray(e)?e.map((function(e){return yz(e,t)})):YD(e,"int32"===t.dtype?t:XN(t,"int32"))}))}function bz(e,t){for(var n=[],r=0,a=null;r<e;)(a=r+t)>=e&&(a=e),n.push([r,a]),r=a;return n}function xz(e){var t=[];e instanceof ak&&(e=[e]);for(var n=0;n<e.length;++n){var r=e[n];if(1===r.rank)t.push(WD(r,1));else{if(0===r.rank)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");t.push(r)}}return t}function wz(e,t){if(null!=e){var n=[];if(t instanceof ak)n.push(t.id);else if(Array.isArray(t))t.forEach((function(e){return n.push(e.id)}));else if(null!=t)for(var r in t){var a=t[r];n.push(a.id)}var i=[];if(e instanceof ak)-1===n.indexOf(e.id)&&i.push(e);else if(Array.isArray(e))e.forEach((function(e){-1===n.indexOf(e.id)&&i.push(e)}));else if(null!=e)for(var o in e){var s=e[o];-1===n.indexOf(s.id)&&i.push(s)}i.forEach((function(e){e.isDisposed||e.dispose()}))}}function kz(e){return Array.isArray(e)}function Nz(e){return!function(e){return e instanceof ak}(e)&&!kz(e)}function Iz(e,t,n,r,a){if(void 0===r&&(r=!0),void 0===a&&(a=""),null==t||0===t.length){if(null!=e){var i=!1;if(kz(e)&&e.length>0)i=!0;else if(Nz(e)){for(var o in e)if(e.hasOwnProperty(o)){i=!0;break}}else i=!0;if(i)throw new HO("Error when checking model "+a+" expected no data, but got "+e)}return[]}if(null==e)return t.map((function(e){return null}));var s;if(Nz(e)){s=[];for(var u,l=Lv(t);!(u=l()).done;){var c=u.value;if(null==e[c])throw new HO('No data provided for "'+c+'". Need data for each key in: '+t);s.push(e[c])}}else if(kz(e)){if(e.length!==t.length)throw new HO("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 "+t.length+" Tensor(s), but instead got the following list of Tensor(s): "+e);s=e}else{if(t.length>1)throw new HO("The model "+a+" expects "+t.length+" Tensor(s), but only received one Tensor. Found: Tensor with shape "+e.shape);s=[e]}if(s=xz(s),null!=n)for(var p=0;p<t.length;++p)if(null!=n[p]){var h=s[p];if(h.shape.length!==n[p].length)throw new HO("Error when checking "+a+": expected "+t[p]+" to have "+n[p].length+" dimension(s). but got array with shape "+h.shape);for(var d=0;d<n[p].length;++d)if(0!==d||r){var f=h.shape[d],m=n[p][d];if(null!=m&&m>=0&&f!==m)throw new HO(a+" expected a batch of elements where each example has shape ["+n[p].slice(1,n[p].length)+"] (i.e.,tensor shape [*,"+n[p].slice(1,n[p].length)+"]) but the "+a+" received an input with "+h.shape[0]+" examples, each with shape ["+h.shape.slice(1,h.shape.length)+"] (tensor shape ["+h.shape+"])")}}return s}function Sz(e,t,n,r,a){var i;if(void 0===r&&(r=!0),void 0===a&&(a=""),Array.isArray(e)){if(e.length!==t.length)throw new HO("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 "+t.length+" Tensor(s), but instead got "+e.length+" Tensors(s).");i=e}else{if(t.length>1)throw new HO("The model expects "+t.length+" "+a+" Tensors, but only received one Tensor. Found: array with shape "+JSON.stringify(e.shape)+".");i=[e]}if(null!=n)for(var o=0;o<t.length;++o)if(null!=n[o]){var s=i[o];if(s.shape.length!==n[o].length)throw new HO("Error when checking "+a+": expected "+t[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 l=s.shape[u],c=n[o][u];if(null!=c&&c!==l)throw new HO("Error when checking "+a+": expected "+t[o]+" to have shape "+JSON.stringify(n[o])+" but got array with shape "+JSON.stringify(s.shape)+".")}}}var Tz=function(e){function t(t){var n;return(n=e.call(this,t)||this).isTraining=!1,n}Cv(t,e);var n=t.prototype;return n.summary=function(e,t,n){if(void 0===n&&(n=console.log),!this.built)throw new HO("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).");qL(this,e,t,n)},n.compile=function(e){var t=this;if(null==e.loss&&(e.loss=[]),this.loss=e.loss,"string"==typeof e.optimizer)this.optimizer_=function(e){var t={Adagrad:function(){return b_.adagrad(.01)},Adadelta:function(){return b_.adadelta(1,.95,PD())},Adam:function(){return b_.adam(.001,.9,.999,PD())},Adamax:function(){return b_.adamax(.002,.9,.999,PD(),0)},RMSProp:function(){return b_.rmsprop(.001,.9,0,PD())},SGD:function(){return b_.sgd(.01)}};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new HO("Unknown Optimizer "+e)}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof mR))throw new HO("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}var n=[];if(Array.isArray(e.loss)||"string"==typeof e.loss||"function"==typeof e.loss)if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new HO("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="+e.loss+".");var r=e.loss;n=r.map((function(e){return RL(e)}))}else{var a=RL(e.loss);this.outputs.forEach((function(e){n.push(a)}))}else{for(var i in e.loss=e.loss,e.loss)if(-1===this.outputNames.indexOf(i))throw new HO('Unknown entry in loss dictionary: "'+i+'". Only expected the following keys: '+this.outputNames);for(var o,s=Lv(this.outputNames);!(o=s()).done;){var u=o.value;null==e.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(RL(e.loss[u]))}}this.lossFunctions=n,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(var l=0;l<this.outputs.length;++l){var c=this.internalOutputShapes[l],p=this.outputNames[l];this.feedOutputNames.push(p),this.feedOutputShapes.push(c),this.feedLossFns.push(this.lossFunctions[l])}var h=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],ED("loss",(function(){for(var e=0;e<t.outputs.length;++e)if(-1===h.indexOf(e)){var n=t.lossFunctions[e];t.outputs.length>1&&(t.metricsTensors.push([n,e]),t.metricsNames.push(t.outputNames[e]+"_loss"))}}));var d=function(e,t){if(null==e||Array.isArray(e)&&0===e.length)return t.map((function(e){return[]}));var n;if("string"==typeof e||"function"==typeof e)n=[e];else{if(!Array.isArray(e)&&"object"!=typeof e)throw new TypeError("Type of metrics argument not understood. Expected an string,function, Array, or Object, found: "+e);n=e}if(Array.isArray(n))return t.map((function(e){return n}));for(var r,a=[],i=Lv(t);!(r=i()).done;){var o=r.value,s=n.hasOwnProperty(o)?n[o]:[];Array.isArray(s)||(s=[s]),a.push(s)}return a}(e.metrics,this.outputNames),f=function(e,n,r){t.outputNames.length>1&&(n=t.outputNames[e]+"_"+n),t.metricsNames.push(n),t.metricsTensors.push([r,e])};ED("metric",(function(){for(var e=function(e){if(-1!==h.indexOf(e))return"continue";!function(n){for(var r,a,i,o,s=Lv(n);!(o=s()).done;){var u=o.value;if("string"==typeof u&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(u)){var l=t.internalOutputShapes[e];1===l[l.length-1]||t.lossFunctions[e]===TL?-1!==["accuracy","acc"].indexOf(u)?a=_L:-1!==["crossentropy","ce"].indexOf(u)&&(a=LL):t.lossFunctions[e]===SL?-1!==["accuracy","acc"].indexOf(u)?a=zL:-1!==["crossentropy","ce"].indexOf(u)&&(a=BL):-1!==["accuracy","acc"].indexOf(u)?a=FL:-1!==["crossentropy","ce"].indexOf(u)&&(a=PL);var c=void 0;-1!==["accuracy","acc"].indexOf(u)?c="acc":-1!==["crossentropy","ce"].indexOf(u)&&(c="ce"),i=a,r=""+c}else{var p=VL(u);i=p,r=""+UL(u)}var h=void 0;ED(r,(function(){h=i})),f(e,r,h)}}(d[e])},n=0;n<t.outputs.length;++n)e(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(e,t,n){void 0===n&&(n={});var r=null==n.batchSize?32:n.batchSize;vz(r);var a=this.standardizeUserDataXY(e,t,!0,r);try{var i=a[0].concat(a[1]);this.makeTestFunction();var o=this.testFunction;return QO(this.testLoop(o,i,r,n.verbose,n.steps))}finally{wz(a[0],e),wz(a[1],t)}},n.evaluateDataset=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.makeTestFunction(),e.abrupt("return",fz(this,t,n));case 2:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.checkNumSamples=function(e,t,n,r){var a;if(void 0===r&&(r="steps"),null!=n){if(a=null,null!=t)throw new HO("If "+r+" is set, batchSize must be null or undefined.Got batchSize = "+t)}else{if(null==e)throw new HO("Either the input data should have a defined shape, or "+r+" shoud be specified.");a=Array.isArray(e)?e[0].shape[0]:e.shape[0]}return a},n.execute=function(e,t){if(Array.isArray(t)&&0===t.length)throw new HO("`outputs` is an empty Array, which is not allowed.");var n=Array.isArray(t),r=n?t:[t],a=this.retrieveSymbolicTensors(r),i=new VM;if(e instanceof ak&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new HO("The number of inputs provided ("+e.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],e[o])}else for(var s,u=Lv(this.inputs);!(s=u()).done;){var l=s.value,c=e[l.name];if(null==c)throw new HO("No value is provided for the model's input "+l.name);i.add(l,c)}var p=jM(a,i);return n?p:p[0]},n.retrieveSymbolicTensors=function(e){for(var t,n=YO(null,e.length),r=e.length,a=Lv(this.layers);!(t=a()).done;){for(var i=t.value,o=Array.isArray(i.output)?i.output:[i.output],s=o.map((function(e){return e.name})),u=0;u<e.length;++u){var l=s.indexOf(e[u]);if(-1!==l&&(n[u]=o[l],r--),0===r)break}if(0===r)break}if(r>0){var c=[];throw n.forEach((function(t,n){null==t&&c.push(e[n])})),new HO("Cannot find SymbolicTensors for output name(s): "+JSON.stringify(c))}return n},n.predictLoop=function(e,t,n){var r=this;return void 0===t&&(t=32),void 0===n&&(n=!1),eI((function(){var a=r.checkNumSamples(e);if(n)throw new qO("Verbose predictLoop() is not implemented yet.");for(var i=bz(a,t),o=r.outputs.map((function(e){return[]})),s=function(t){eI((function(){var n=i[t][0],a=i[t][1],o=gz(e,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 l=new VM(s);return jM(r.outputs,l)})).forEach((function(e,t){return o[t].push(e)}))},u=0;u<i.length;++u)s(u);return QO(o.map((function(e){return VI(e,0)})))}))},n.predict=function(e,t){void 0===t&&(t={});var n=xz(e);Sz(n,this.inputNames,this.feedInputShapes,!1);try{var r=null==t.batchSize?32:t.batchSize;return vz(r),this.predictLoop(n,r)}finally{wz(n,e)}},n.predictOnBatch=function(e){Sz(e,this.inputNames,this.feedInputShapes,!0);var t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)},n.standardizeUserDataXY=function(e,t,n,r){if(void 0===n&&(n=!0),null==this.optimizer_)throw new jO("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]===SL?a.push(o.slice(0,o.length-1).concat([1])):a.push(o)}if(function(e,t,n){var r=sD(e.map((function(e){return e.shape[0]})));r.sort();var a=sD(t.map((function(e){return e.shape[0]})));if(a.sort(),r.length>1)throw new HO("All input Tensors (x) should have the same number of samples. Got array shapes: "+JSON.stringify(e.map((function(e){return e.shape}))));if(a.length>1)throw new HO("All target Tensors (y) should have the same number of samples. Got array shapes: "+JSON.stringify(t.map((function(e){return e.shape}))));if(r.length>0&&a.length>0&&!Yv(r,a))throw new HO("Input Tensors should have the same number of samples as target Tensors. Found "+r[0]+" input sample(s) and "+a[0]+" target sample(s).")}(e=Iz(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=Iz(t,this.feedOutputNames,a,!1,"target")),function(e,t,n){for(var r=[xL,TL,IL],a=0;a<e.length;++a){var i=e[a],o=t[a],s=n[a];if(null!=o){if(o===IL&&1===i.shape[i.shape.length-1])throw new HO("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),l=s.slice(1),c=0;c<u.length;++c){var p=u[c],h=l[c];if(null!=h&&p!==h)throw new HO("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.")}}}}(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&null!=r&&r>0&&e[0].shape[0]%r!=0)throw new HO("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+r+". Found: "+e[0].shape[0]+" sample(s).");return[e,t]},n.standardizeUserData=function(){var e=Iv(kv().mark((function e(t,n,r,a,i,o){var s,u,l,c,p,h;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===i&&(i=!0),s=this.standardizeUserDataXY(t,n,i,o),u=s[0],l=s[1],null==r){e.next=4;break}throw new Error("sample weight is not supported yet.");case 4:if(c=null,null==a){e.next=18;break}p=nz(a,this.outputNames),c=[],h=0;case 9:if(!(h<p.length)){e.next=18;break}return e.t0=c,e.next=13,rz(l[h],null,p[h]);case 13:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 15:++h,e.next=9;break;case 18:return e.abrupt("return",[u,l,c]);case 19:case"end":return e.stop()}}),e,this)})));return function(t,n,r,a,i,o){return e.apply(this,arguments)}}(),n.testLoop=function(e,t,n,r,a){var i=this;return void 0===r&&(r=0),eI((function(){var o=i.checkNumSamples(t,n,a,"steps"),s=[];if(r>0)throw new qO("Verbose mode is not implemented yet.");if(null!=a)throw new qO("steps mode in testLoop() is not implemented yet");for(var u=bz(o,n),l=mE(zD(0,o)),c=0;c<u.length;++c){var p=u[c][0],h=u[c][1],d=VD(l,p,h-p),f=yz(t,d),m=e(f);if(0===c)for(var v=0;v<m.length;++v)s.push(KS(0));for(var g=0;g<m.length;++g){var y=m[g];s[g]=oI(s[g],lI(h-p,y))}}for(var b=0;b<s.length;++b)s[b]=uI(s[b],o);return s}))},n.getDedupedMetricsNames=function(){for(var e=this.metricsNames,t=[],n=0;n<e.length;++n){var r=e[n],a=r;if(ZO(e,r)>1)a+="_"+ZO(e.slice(0,n),r);t.push(a)}return t},n.makeTrainFunction=function(){var e=this;return function(t){var n=[],r=t.slice(0,e.inputs.length),a=t.slice(e.inputs.length,e.inputs.length+e.outputs.length),i=t.slice(e.inputs.length+e.outputs.length,e.inputs.length+2*e.outputs.length),o=[],s=e.collectedTrainableWeights.map((function(e){return e.read()}));return[e.optimizer_.minimize((function(){for(var t=[],s=0;s<e.inputs.length;++s)t.push({key:e.inputs[s],value:r[s]});for(var u,l=new VM(t),c=jM(e.outputs,l,{training:!0}),p=0;p<e.lossFunctions.length;++p){var h=(0,e.lossFunctions[p])(a[p],c[p]);null!=i[p]&&(h=iz(h,i[p]));var d=WT(h);n.push(d),u=0===p?h:oI(u,h)}for(var f=0;f<e.metricsTensors.length;++f){var m=void 0;if(e.outputs.length>1&&f<e.outputs.length)m=n[f];else{var v=e.metricsTensors[f][0],g=e.metricsTensors[f][1];m=WT(v(a[g],c[g]))}nI(m),o.push(m)}return u=WT(u),e.calculateLosses().forEach((function(e){u=oI(u,e)})),u}),!0,s)].concat(o)}},n.makeTestFunction=function(){var e=this;this.testFunction=function(t){return eI((function(){for(var n,r=[],a=t.slice(0,e.inputs.length),i=t.slice(e.inputs.length,e.inputs.length+e.outputs.length),o=[],s=0;s<e.inputs.length;++s)o.push({key:e.inputs[s],value:a[s]});for(var u=new VM(o),l=jM(e.outputs,u),c=0;c<e.lossFunctions.length;++c){var p=e.lossFunctions[c],h=WT(p(i[c],l[c]));n=0===c?h:oI(n,h),r.push(n)}for(var d=0;d<e.metricsTensors.length;++d){var f=e.metricsTensors[d][0],m=e.metricsTensors[d][1],v=WT(f(i[m],l[m]));r.push(v)}return r}))}},n.fit=function(){var e=Iv(kv().mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,d,f,m,v,g,y,b,x,w,k,N,I,S,T;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r={}),!this.isTraining){e.next=3;break}throw new Error("Cannot start training because another fit() call is ongoing.");case 3:return this.isTraining=!0,e.prev=4,vz(d=null==r.batchSize?32:r.batchSize),!1,e.next=10,this.standardizeUserData(t,n,r.sampleWeight,r.classWeight,false,d);case 10:if(f=e.sent,a=f[0],i=f[1],h=f[2],m=!1,!(null!=r.validationData&&r.validationData.length>0)){e.next=36;break}if(m=!0,2!==r.validationData.length){e.next=22;break}u=r.validationData[0],l=r.validationData[1],e.next=27;break;case 22:if(3!==r.validationData.length){e.next=26;break}throw new qO("validationData including sample weights is not supported yet.");case 26:throw new HO("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+r.validationData+" is invalid.");case 27:return!0,e.next=30,this.standardizeUserData(u,l,null,null,true,d);case 30:g=e.sent,c=g[0],p=g[1],v=c.concat(p),e.next=37;break;case 36:null!=r.validationSplit&&r.validationSplit>0&&r.validationSplit<1?(m=!0,y=Math.floor(a[0].shape[0]*(1-r.validationSplit)),b=a[0].shape[0],c=gz(a,y,b),o=a,a=gz(a,0,y),p=gz(i,y,b),s=i,i=gz(i,0,y),v=c.concat(p)):null!=r.validationSteps&&(m=!0);case 37:return x=a.concat(i).concat(h),this.checkTrainableWeightsConsistency(),w=this.makeTrainFunction(),k=this.getDedupedMetricsNames(),m?(this.makeTestFunction(),N=this.testFunction,I=k.slice().concat(k.map((function(e){return"val_"+e})))):(N=null,v=[],I=k.slice()),S=mL(r.callbacks,r.yieldEvery),e.next=45,this.fitLoop(w,x,k,d,r.epochs,r.verbose,S,N,v,r.shuffle,I,r.initialEpoch,null,null);case 45:return T=e.sent,e.abrupt("return",T);case 47:return e.prev=47,this.isTraining=!1,wz(a,t),wz(i,n),wz(o,t),wz(s,n),wz(c,u),wz(p,l),null!=h&&tI(h),e.finish(47);case 57:case"end":return e.stop()}}),e,this,[[4,,47,57]])})));return function(t,n,r){return e.apply(this,arguments)}}(),n.fitLoop=function(){var e=Iv(kv().mark((function e(t,n,r,a,i,o,s,u,l,c,p,h,d,f){var m,v,g,y,b,x,w,k,N=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==a&&(a=32),null==i&&(i=1),null==c&&(c=!0),null==h&&(h=0),m=!1,null!=u&&null!=l&&(m=!0),null==f){e.next=10;break}if(m=!0,null!=d){e.next=10;break}throw new HO("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");case 10:return null!=(v=this.checkNumSamples(n,a,d,"steps_per_epoch"))&&(g=zD(0,v)),null==o&&(o=1),y=gL(s,o,i,h,v,d,a,m,p),b=y.callbackList,x=y.history,b.setModel(this),this.history=x,e.next=18,b.onTrainBegin();case 18:this.stopTraining_=!1,w=kv().mark((function e(i){var o;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.onEpochBegin(i);case 2:if(o={},null==d){e.next=7;break}throw new qO("stepsPerEpoch mode is not implemented yet.");case 7:return e.delegateYield(kv().mark((function e(){var i,s,p,h;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("batch"!==c){e.next=4;break}throw new qO("batch shuffling is not implemneted yet");case 4:c&&Wv(g);case 5:i=mE(g),s=bz(v,a),p=kv().mark((function e(c){var p;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return p={},e.next=3,b.onBatchBegin(c,p);case 3:return eI((function(){var e=s[c][0],h=s[c][1],d=VD(i,e,h-e);p.batch=c,p.size=h-e;for(var f=yz(n,d),v=t(f),g=0;g<r.length;++g){var y=r[g],b=v[g];p[y]=b,nI(b)}if(c===s.length-1&&m)for(var x=N.testLoop(u,l,a),w=0;w<r.length;++w){var k=r[w],I=x[w];nI(I),o["val_"+k]=I}})),e.next=6,b.onBatchEnd(c,p);case 6:if(lL(p),!N.stopTraining_){e.next=9;break}return e.abrupt("return","break");case 9:case"end":return e.stop()}}),e)})),h=0;case 9:if(!(h<s.length)){e.next=17;break}return e.delegateYield(p(h),"t0",11);case 11:if("break"!==e.t0){e.next=14;break}return e.abrupt("break",17);case 14:++h,e.next=9;break;case 17:i.dispose();case 18:case"end":return e.stop()}}),e)}))(),"t0",8);case 8:return e.next=10,b.onEpochEnd(i,o);case 10:if(!N.stopTraining_){e.next=12;break}return e.abrupt("return","break");case 12:case"end":return e.stop()}}),e)})),k=h;case 21:if(!(k<i)){e.next=29;break}return e.delegateYield(w(k),"t0",23);case 23:if("break"!==e.t0){e.next=26;break}return e.abrupt("break",29);case 26:++k,e.next=21;break;case 29:return e.next=31,b.onTrainEnd();case 31:return e.next=33,this.history.syncData();case 33:return e.abrupt("return",this.history);case 34:case"end":return e.stop()}}),e,this)})));return function(t,n,r,a,i,o,s,u,l,c,p,h,d,f){return e.apply(this,arguments)}}(),n.fitDataset=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",lz(this,t,n));case 1:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.trainOnBatch=function(){var e=Iv(kv().mark((function e(t,n){var r,a,i,o,s,u,l,c,p,h;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.standardizeUserData(t,n);case 2:r=e.sent,a=r[0],i=r[1],o=this.makeTrainFunction(),s=o(a.concat(i)),u=[],l=Lv(s);case 9:if((c=l()).done){e.next=17;break}return p=c.value,e.next=13,p.data();case 13:h=e.sent,u.push(h[0]);case 15:e.next=9;break;case 17:return tI(s),wz(r[0],t),wz(r[1],n),e.abrupt("return",QO(u));case 21:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.getNamedWeights=function(e){for(var t=[],n=null!=e&&e.trainableOnly,r=n?this.trainableWeights:this.weights,a=this.getWeights(n),i=0;i<r.length;++i)n&&!r[i].trainable||t.push({name:r[i].originalName,tensor:a[i]});return t},n.dispose=function(){var t=e.prototype.dispose.call(this);if(0===t.refCountAfterDispose&&null!=this.optimizer&&this.isOptimizerOwned){var n=$N().numTensors;this.optimizer_.dispose(),t.numDisposedVariables+=n-$N().numTensors}return t},n.getLossIdentifiers=function(){var e;if("string"==typeof this.loss)e=eD(this.loss);else if(Array.isArray(this.loss)){for(var t,n=Lv(this.loss);!(t=n()).done;){if("string"!=typeof t.value)throw new Error("Serialization of non-string loss is not supported.")}e=this.loss.map((function(e){return eD(e)}))}else{var r=Object.keys(this.loss);e={};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.");e[s]=eD(a[s])}}return e},n.getMetricIdentifiers=function(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[eD(UL(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((function(e){return eD(UL(e))}));var e={};for(var t in this.metrics)e[t]=eD(UL(this.metrics[t]));return e},n.getTrainingConfig=function(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}},n.loadTrainingConfig=function(e){if(null!=e.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=e.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=e.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");var t,n,r=yL(ZL(e.optimizer_config));if("string"==typeof e.loss)t=tD(e.loss);else if(Array.isArray(e.loss))t=e.loss.map((function(e){return tD(e)}));else if(null!=e.loss)for(var a in t={},e.loss)t[a]=tD(e.loss[a]);if(Array.isArray(e.metrics))n=e.metrics.map((function(e){return tD(e)}));else if(null!=e.metrics)for(var i in n={},e.metrics)n[i]=tD(e.metrics[i]);this.compile({loss:t,metrics:n,optimizer:r})},n.save=function(){var e=Iv(kv().mark((function e(t,n){var r,a,i,o,s,u,l,c,p;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=9;break}if(0!==(r=lN(t)).length){e.next=6;break}throw new HO("Cannot find any save handlers for URL '"+t+"'");case 6:if(!(r.length>1)){e.next=8;break}throw new HO("Found more than one ("+r.length+") save handlers for URL '"+t+"'");case 8:t=r[0];case 9:if(null!=t.save){e.next=11;break}throw new HO("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");case 11:return e.next=13,Hk(this.getNamedWeights(n));case 13:if(a=e.sent,!1,null,i=this.toJSON(null,false),o={modelTopology:i,format:"layers-model",generatedBy:"TensorFlow.js tfjs-layers v4.3.0",convertedBy:null},!(null!=n&&n.includeOptimizer)||null==this.optimizer){e.next=34;break}return o.trainingConfig=this.getTrainingConfig(),u="optimizer",e.t0=GR,e.next=25,this.optimizer.getWeights();case 25:return e.t1=e.sent,e.t2=u,e.next=29,e.t0.encodeWeights.call(e.t0,e.t1,e.t2);case 29:l=e.sent,c=l.data,p=l.specs,(s=a.specs).push.apply(s,p),a.data=$k([a.data,c]);case 34:return null!=this.userDefinedMetadata&&(!0,jL(this.userDefinedMetadata,this.name,true),o.userDefinedMetadata=this.userDefinedMetadata),o.weightData=a.data,o.weightSpecs=a.specs,e.abrupt("return",t.save(o));case 38:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.setUserDefinedMetadata=function(e){jL(e,this.name),this.userDefinedMetadata=e},n.getUserDefinedMetadata=function(){return this.userDefinedMetadata},Tv(t,[{key:"stopTraining",get:function(){return this.stopTraining_},set:function(e){this.stopTraining_=e}},{key:"optimizer",get:function(){return this.optimizer_},set:function(e){this.optimizer_!==e&&(this.optimizer_=e,this.isOptimizerOwned=!1)}}]),t}(ez);Tz.className="Model",dR(Tz);var Cz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t}(Tz);function Ez(){return Ez=Iv(kv().mark((function e(t,n){var r,a,i,o,s,u,l,c;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("modelTopology"in t||(t={modelTopology:t}),null!=(r=t.modelTopology).model_config&&(r=r.model_config),a=ZL(r),i=yL(a,n),null==t.weightsManifest){e.next=14;break}return e.next=9,RR(t.weightsManifest,t.pathPrefix,i.weights.map((function(e){return e.originalName})));case 9:for(o=e.sent,s={},u=Lv(i.weights);!(l=u()).done;)c=l.value,s[c.originalName]=o[c.originalName];i.loadWeights(s),tI(o);case 14:return e.abrupt("return",i);case 15:case"end":return e.stop()}}),e)}))),Ez.apply(this,arguments)}function Az(){return(Az=Iv(kv().mark((function e(t,n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n&&(n={}),"string"!=typeof t){e.next=10;break}if(0!==(r=cN(t,n)).length){e.next=7;break}r.push(PR(t,n)),e.next=9;break;case 7:if(!(r.length>1)){e.next=9;break}throw new HO("Found more than one ("+r.length+") load handlers for URL '"+t+"'");case 9:t=r[0];case 10:return e.abrupt("return",Rz(t,void 0,n));case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Rz(e,t,n){return _z.apply(this,arguments)}function _z(){return _z=Iv(kv().mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==r&&(r={}),null!=t.load){e.next=3;break}throw new HO("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");case 3:return e.next=5,t.load();case 5:if(a=e.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=yL(ZL(i),n,s),null!=(l=a.trainingConfig)&&u.loadTrainingConfig(l),null!=a.userDefinedMetadata&&u.setUserDefinedMetadata(a.userDefinedMetadata),null==a.weightData){e.next=24;break}if(null!=a.weightSpecs){e.next=17;break}throw new HO("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");case 17:if(c=Fz(a.weightData,a.weightSpecs),p=c.modelWeights,h=c.optimizerWeights,u.loadWeights(p,o),!(null!=u.optimizer&&h.length>0)){e.next=22;break}return e.next=22,u.optimizer.setWeights(h);case 22:tI(p),tI(h.map((function(e){return e.tensor})));case 24:return e.abrupt("return",u);case 25:case"end":return e.stop()}}),e)}))),_z.apply(this,arguments)}function Fz(e,t){var n=Kk(e,t),r={},a=[];return t.forEach((function(e){"optimizer"===e.group?a.push({name:e.name,tensor:n[e.name]}):r[e.name]=n[e.name]})),{modelWeights:r,optimizerWeights:a}}Cz.className="Functional",dR(Cz);var Oz=function(e){function t(t){var n;if(t=t||{},(n=e.call(this,{inputs:[],outputs:[]})||this).trainable=!0,n.built=!1,n.name=null!=t.name?t.name:gD("sequential_"),null!=t.layers)for(var r,a=Lv(t.layers);!(r=a()).done;){var i=r.value;n.add(i)}return n}Cv(t,e);var n=t.prototype;return n.checkShape=function(e){if(e.inboundNodes[0].outputTensors[0].shape.some((function(e){return e<0})))throw new HO("Negative dimension size caused by adding layer "+e.name+" with input shape ["+e.inboundNodes[0].inputTensors[0].shape+"]")},n.add=function(e){var n,r=e instanceof t||e instanceof Tz;if(r){if(1!==(n=e).outputs.length)throw new HO("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 HO("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===e.inboundNodes.length){if(null==e.batchInputShape)throw new HO("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");var a=WM({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(a)}if(r)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==e.inboundNodes.length)throw new HO("A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer "+e.name+" which has "+e.inboundNodes.length+" pre-existing inbound connections.");if(1!==e.inboundNodes[0].outputTensors.length)throw new HO("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=PM(this.outputs[0])}this.inboundNodes=[],new MM({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:YO(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((function(e){return e.shape})),outputShapes:this.outputs[0].shape})}else{var i=e.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(e),this.outputs=[i],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),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 e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}},n.call=function(e,t){return null==this.model&&this.build(),this.model.call(e,t)},n.build=function(e){if(TM(e),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 Tz({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(),e.prototype.countParams.call(this)},n.summary=function(t,n,r){void 0===r&&(r=console.log),this.built||this.build(),e.prototype.summary.call(this,t,n,r)},n.setWeights=function(e){null==this.model&&this.build(),this.model.setWeights(e)},n.evaluate=function(e,t,n){if(void 0===n&&(n={}),!this.built)throw new jO("The model needs to be compiled before being used.");return this.model.evaluate(e,t,n)},n.evaluateDataset=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.built){e.next=2;break}throw new jO("The model needs to be compiled before being used.");case 2:return e.abrupt("return",this.model.evaluateDataset(t,n));case 3:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.predict=function(e,t){return void 0===t&&(t={}),null==this.model&&this.build(),this.model.predict(e,t)},n.predictOnBatch=function(e){return null==this.model&&this.build(),this.model.predictOnBatch(e)},n.compile=function(e){this.build(),this.model.compile(e),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 e=Iv(kv().mark((function e(t,n,r){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r={}),this.built){e.next=3;break}throw new jO("The model needs to be compiled before being used.");case 3:return e.abrupt("return",this.model.fit(t,n,r));case 4:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),n.fitDataset=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.built){e.next=2;break}throw new jO("The model needs to be compiled before being used.");case 2:return e.abrupt("return",this.model.fitDataset(t,n));case 3:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.trainOnBatch=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.model.trainOnBatch(t,n));case 1:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.fromConfig=function(e,n,r,a){var i;void 0===r&&(r={}),void 0===a&&(a=!1);var o={};if(n instanceof Array){if(null==n[0].className||"Merge"===n[0].className)throw new HO("Legacy serialization format not supported yet.");i=n}else Hv(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 e(o);if(!(s instanceof t))throw new qO("Sequential.fromConfig called on non-Sequential input: "+s);for(var u,l=Lv(i);!(u=l()).done;){var c=yL(u.value,undefined,a);a&&c.setFastWeightInitDuringBuild(!0),s.add(c)}return s},n.getConfig=function(){for(var e,t=[],n=Lv(this.layers);!(e=n()).done;){var r=e.value,a={};a.className=r.getClassName(),a.config=r.getConfig(),t.push(a)}return{name:this.name,layers:t}},Tv(t,[{key:"optimizer",get:function(){return null==this.model?void 0:this.model.optimizer},set:function(e){this.model.optimizer=e}},{key:"stopTraining",get:function(){if(null==this.model)throw new HO("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining},set:function(e){if(null==this.model)throw new HO("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}}]),t}(Tz);function Dz(e){return WM(e)}Oz.className="Sequential",dR(Oz);var Mz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.getConfig=function(){return{}},t}(pR),Lz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e,t){return void 0===t&&(t=1),function(e,t){if(void 0===t&&(t=1),1!==t)throw new qO("Support for alpha values other than 1 ("+t+") is not implemented yet.");return DS(e)}(e,t)},t}(Mz);Lz.className="elu",dR(Lz);var zz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return qC(e)},t}(Mz);zz.className="selu",dR(zz);var Pz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return zC(e)},t}(Mz);Pz.className="relu",dR(Pz);var Bz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return eI((function(){return jT(6,zC(e))}))},t}(Mz);Bz.className="relu6",dR(Bz);var Wz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return e},t}(Mz);Wz.className="linear",dR(Wz);var Vz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return GI(e)},t}(Mz);Vz.className="sigmoid",dR(Vz);var Uz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return function(e){return eI((function(){var t=oI(.5,lI(.2,e));return rS(t,0,1)}))}(e)},t}(Mz);Uz.className="hardSigmoid",dR(Uz);var Gz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return IT(e)},t}(Mz);Gz.className="softplus",dR(Gz);var jz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return function(e){return eI((function(){return uI(e,oI(cI(e),1))}))}(e)},t}(Mz);jz.className="softsign",dR(jz);var Hz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return HI(e)},t}(Mz);Hz.className="tanh",dR(Hz);var qz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e,t){return void 0===t&&(t=-1),rE(e,t)},t}(Mz);qz.className="softmax",dR(qz);var Kz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e,t){return void 0===t&&(t=-1),CT(e,t)},t}(Mz);Kz.className="logSoftmax",dR(Kz);var Xz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e,t){return void 0===t&&(t=1),eI((function(){return lI(GI(lI(e,t)),e)}))},t}(Mz);Xz.className="swish",dR(Xz);var Yz=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e){return eI((function(){return lI(e,HI(IT(e)))}))},t}(Mz);function Jz(e){return e.getClassName()}function Zz(e,t){return void 0===t&&(t={}),iD(e,hR.getMap().classNameMap,t,"activation")}function Qz(e){if(null==e){var t={className:"linear",config:{}};return Zz(t)}if("string"==typeof e){var n={};return n.className=e,n.config={},Zz(n)}return e instanceof Mz?e:Zz(e)}function $z(e){if(null!=e&&"object"!=typeof e)throw new Error("Argument to L1L2 regularizer's constructor is expected to be an object, but received: "+e)}Yz.className="mish",dR(Yz);var eP=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t}(pR),tP=function(e){function t(t){var n;return n=e.call(this)||this,$z(t),n.l1=null==t||null==t.l1?.01:t.l1,n.l2=null==t||null==t.l2?.01:t.l2,n.hasL1=0!==n.l1,n.hasL2=0!==n.l2,n}Cv(t,e);var n=t.prototype;return n.apply=function(e){var t=this;return eI((function(){var n=VT([1]);return t.hasL1&&(n=oI(n,JS(lI(t.l1,cI(e))))),t.hasL2&&(n=oI(n,JS(lI(t.l2,JD(e))))),PI(n,[])}))},n.getConfig=function(){return{l1:this.l1,l2:this.l2}},t.fromConfig=function(e,t){return new e({l1:t.l1,l2:t.l2})},t}(eP);tP.className="L1L2",dR(tP);var nP={l1l2:"L1L2"};function rP(e){return rD(e)}function aP(e,t){return void 0===t&&(t={}),iD(e,hR.getMap().classNameMap,t,"regularizer")}function iP(e){return null==e?null:"string"==typeof e?aP({className:e in nP?nP[e]:e,config:{}}):e instanceof eP?e:aP(e)}var oP=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).supportsMasking=!0,null!=t&&(n.maxValue=t.maxValue),n}Cv(t,e);var n=t.prototype;return n.call=function(e,t){e=SM(e);var n=zC(e);return null!=this.maxValue&&(n=rS(n,0,this.maxValue)),n},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={maxValue:this.maxValue},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);oP.className="ReLU",dR(oP);var sP=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).DEFAULT_ALPHA=.3,null==t&&(t={}),n.alpha=null==t.alpha?n.DEFAULT_ALPHA:t.alpha,n}Cv(t,e);var n=t.prototype;return n.call=function(e,t){var n=SM(e);return dT(n,this.alpha)},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={alpha:this.alpha},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);sP.className="LeakyReLU",dR(sP);var uP=function(e){function t(t){var n;if((n=e.call(this,null==t?{}:t)||this).DEFAULT_ALPHA_INITIALIZER="zeros",null==t&&(t={}),n.supportsMasking=!0,n.alphaInitializer=kM(t.alphaInitializer||n.DEFAULT_ALPHA_INITIALIZER),n.alphaRegularizer=iP(t.alphaRegularizer),n.alphaConstraint=rL(t.alphaConstraint),null==t.sharedAxes)n.sharedAxes=null;else if(Array.isArray(t.sharedAxes))n.sharedAxes=t.sharedAxes;else{if("number"!=typeof t.sharedAxes)throw new HO("Expected sharedAxes to be a number or an array of numbers, but got "+t.sharedAxes);n.sharedAxes=[t.sharedAxes]}return n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t=(e=TM(e)).slice(1);if(null!=this.sharedAxes)for(var n,r=Lv(this.sharedAxes);!(n=r()).done;){t[n.value-1]=1}this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);var a={};if(null!=this.sharedAxes)for(var i=1;i<e.length;++i)a[i]=e[i];this.inputSpec=[new FM({ndim:e.length,axes:a})],this.built=!0},n.call=function(e,t){return e=SM(e),sC(e,this.alpha.read())},n.getConfig=function(){var t={alphaInitializer:wM(this.alphaInitializer),alphaRegularizer:rP(this.alphaRegularizer),alphaConstraint:tL(this.alphaConstraint),sharedAxes:this.sharedAxes},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);uP.className="PReLU",dR(uP);var lP=function(e){function t(t){var n;if((n=e.call(this,null==t?{}:t)||this).DEFAULT_ALPHA=1,null==t&&(t={}),null!=t.alpha&&t.alpha!==n.DEFAULT_ALPHA)throw new qO("Non-default alpha value ("+t.alpha+") is not supported by the ELU layer yet.");return n.alpha=null==t.alpha?n.DEFAULT_ALPHA:t.alpha,n}Cv(t,e);var n=t.prototype;return n.call=function(e,t){var n=SM(e);return DS(n)},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={alpha:this.alpha},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);lP.className="ELU",dR(lP);var cP=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).DEFAULT_THETA=1,null==t&&(t={}),n.theta=null==t.theta?n.DEFAULT_THETA:t.theta,n}Cv(t,e);var n=t.prototype;return n.call=function(e,t){var n=SM(e);return lI(n,XN(sT(n,this.theta),"float32"))},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={theta:this.theta},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);cP.className="ThresholdedReLU",dR(cP);var pP=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).DEFAULT_AXIS=1,null==t&&(t={}),n.softmax=(new qz).apply,n.axis=null==t.axis?n.DEFAULT_AXIS:t.axis,n}Cv(t,e);var n=t.prototype;return n.call=function(e,t){var n=SM(e);return this.softmax(n,this.axis)},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={axis:this.axis},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);function hP(e,t,n){if("number"==typeof e)return YO(e,t);if(e.length!==t)throw new HO("The "+n+" argument must be an integer or tuple of "+t+" integers. Received: "+e.length+" elements.");for(var r=0;r<t;++r){var a=e[r];if((i=a)!==parseInt(i.toString(),10))throw new HO("The "+n+" argument must be an integer or tuple of "+t+" integers. Received: "+JSON.stringify(e)+" including a non-integer number "+a)}return e;var i}function dP(e,t,n,r,a){return void 0===a&&(a=1),null==e?e:(i="same"===n?e:e-(t+(t-1)*(a-1))+1,Math.floor((i+r-1)/r));var i}function fP(e,t,n,r){if(null==e)return null;if("valid"===r)e=e*t+LD([n-t,0]);else{if("same"!==r)throw new HO("Unsupport padding mode: "+r+".");e*=t}return e}function mP(e,t){return eI((function(){return ID(t),"channelsFirst"===t?PE(e,[0,2,3,1]):e}))}function vP(e,t){return eI((function(){return ID(t),"channelsFirst"===t?PE(e,[0,2,3,4,1]):e}))}function gP(e,t,n,r,a,i,o){return void 0===r&&(r=1),void 0===a&&(a="valid"),void 0===o&&(o=1),eI((function(){if(null==i&&(i="channelsLast"),ID(i),3!==e.shape.length)throw new HO("The input of a conv1dWithBias operation should be 3, but is "+e.shape.length+" instead.");if(3!==t.shape.length)throw new HO("The kernel for a conv1dWithBias operation should be 3, but is "+t.shape.length+" instead");if(null!=n&&1!==n.shape.length)throw new HO("The bias for a conv1dWithBias operation should be 1, but is "+t.shape.length+" instead");if("channelsFirst"===i&&(e=PE(e,[0,2,1])),"causal"===a)throw new qO("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");var s=lS(e,t,r,"same"===a?"same":"valid","NWC",o);return null!=n&&(s=QD(s,n)),s}))}function yP(e,t,n,r,a,i,o,s){return void 0===r&&(r=[1,1]),void 0===a&&(a="valid"),void 0===s&&(s=null),eI((function(){if(null==i&&(i="channelsLast"),ID(i),3!==e.rank&&4!==e.rank)throw new HO("conv2dWithBiasActivation expects input to be of rank 3 or 4, but received "+e.rank+".");if(3!==t.rank&&4!==t.rank)throw new HO("conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received "+e.rank+".");var u=mP(e,i);if("causal"===a)throw new qO("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=$E({x:u,filter:t,strides:r,pad:"same"===a?"same":"valid",dilations:o,dataFormat:"NHWC",bias:n,activation:s}),"channelsFirst"===i&&(u=PE(u,[0,3,1,2])),u}))}function bP(e,t,n,r,a,i,o){return void 0===r&&(r=[1,1,1]),void 0===a&&(a="valid"),eI((function(){if(null==i&&(i="channelsLast"),ID(i),4!==e.rank&&5!==e.rank)throw new HO("conv3dWithBias expects input to be of rank 4 or 5, but received "+e.rank+".");if(4!==t.rank&&5!==t.rank)throw new HO("conv3dWithBias expects kernel to be of rank 4 or 5, but received "+e.rank+".");var s=vP(e,i);if("causal"===a)throw new qO("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return s=hS(s,t,r,"same"===a?"same":"valid","NDHWC",o),null!=n&&(s=QD(s,n)),"channelsFirst"===i&&(s=PE(s,[0,4,1,2,3])),s}))}pP.className="Softmax",dR(pP);var xP=function(e){function t(n,r){var a;if((a=e.call(this,r)||this).bias=null,a.DEFAULT_KERNEL_INITIALIZER="glorotNormal",a.DEFAULT_BIAS_INITIALIZER="zeros",t.verifyArgs(r),a.rank=n,pD(a.rank,"rank"),1!==a.rank&&2!==a.rank&&3!==a.rank)throw new qO("Convolution layer for rank other than 1, 2, or 3 ("+a.rank+") is not implemented yet.");if(a.kernelSize=hP(r.kernelSize,n,"kernelSize"),a.strides=hP(null==r.strides?1:r.strides,n,"strides"),a.padding=null==r.padding?"valid":r.padding,SD(a.padding),a.dataFormat=null==r.dataFormat?"channelsLast":r.dataFormat,ID(a.dataFormat),a.activation=Qz(r.activation),a.useBias=null==r.useBias||r.useBias,a.biasInitializer=kM(r.biasInitializer||a.DEFAULT_BIAS_INITIALIZER),a.biasConstraint=rL(r.biasConstraint),a.biasRegularizer=iP(r.biasRegularizer),a.activityRegularizer=iP(r.activityRegularizer),a.dilationRate=hP(null==r.dilationRate?1:r.dilationRate,n,"dilationRate"),1===a.rank&&Array.isArray(a.dilationRate)&&1!==a.dilationRate.length)throw new HO("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 HO("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 HO("dilationRate must be a number or array of three numbers for 3D convolution, but received "+JSON.stringify(a.dilationRate));return a}return Cv(t,e),t.verifyArgs=function(e){if(JO("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!=typeof e.kernelSize&&!cD(e.kernelSize,"number",1,3))throw new HO("BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received "+JSON.stringify(e.kernelSize)+".")},t.prototype.getConfig=function(){var t={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:Jz(this.activation),useBias:this.useBias,biasInitializer:wM(this.biasInitializer),biasRegularizer:rP(this.biasRegularizer),activityRegularizer:rP(this.activityRegularizer),biasConstraint:tL(this.biasConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM),wP=function(e){function t(n,r){var a;return(a=e.call(this,n,r)||this).kernel=null,t.verifyArgs(r),a.filters=r.filters,pD(a.filters,"filters"),a.kernelInitializer=kM(r.kernelInitializer||a.DEFAULT_KERNEL_INITIALIZER),a.kernelConstraint=rL(r.kernelConstraint),a.kernelRegularizer=iP(r.kernelRegularizer),a}Cv(t,e);var n=t.prototype;return n.build=function(e){var t;e=TM(e);var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new HO("The channel dimension of the input should be defined. Found "+e[n]);var r=e[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:(t={},t[n]=r,t)}],this.built=!0},n.call=function(e,t){var n=this;return eI((function(){var t;e=SM(e);var r=null==n.bias?null:n.bias.read(),a=dD(n.activation.getClassName());if(null!=a&&2===n.rank)t=yP(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate,a);else{if(1===n.rank)t=gP(e,n.kernel.read(),r,n.strides[0],n.padding,n.dataFormat,n.dilationRate[0]);else if(2===n.rank)t=yP(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate);else{if(3!==n.rank)throw new qO("convolutions greater than 3D are not implemented yet.");t=bP(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate)}null!=n.activation&&(t=n.activation.apply(t))}return t}))},n.computeOutputShape=function(e){e=TM(e);for(var t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2),r=0;r<n.length;++r){var a=dP(n[r],this.kernelSize[r],this.padding,this.strides[r],"number"==typeof this.dilationRate?this.dilationRate:this.dilationRate[r]);t.push(a)}var i=[e[0]];return"channelsLast"===this.dataFormat?(i=i.concat(t)).push(this.filters):(i.push(this.filters),i=i.concat(t)),i},n.getConfig=function(){var t={filters:this.filters,kernelInitializer:wM(this.kernelInitializer),kernelRegularizer:rP(this.kernelRegularizer),kernelConstraint:tL(this.kernelConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t.verifyArgs=function(e){if(!("filters"in e)||"number"!=typeof e.filters||e.filters<1)throw new HO("Convolution layer expected config.filters to be a 'number' > 0 but got "+JSON.stringify(e.filters))},t}(xP),kP=function(e){function t(n){var r;return r=e.call(this,2,n)||this,t.verifyArgs(n),r}return Cv(t,e),t.prototype.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.rank,t},t.verifyArgs=function(e){if("number"!=typeof e.kernelSize&&!cD(e.kernelSize,"number",1,2))throw new HO("Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received "+JSON.stringify(e.kernelSize)+".")},t}(wP);kP.className="Conv2D",dR(kP);var NP=function(e){function t(n){var r;return r=e.call(this,3,n)||this,t.verifyArgs(n),r}return Cv(t,e),t.prototype.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.rank,t},t.verifyArgs=function(e){if("number"!=typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new HO("Conv3D expects config.kernelSize to be number or [number, number, number], but received "+JSON.stringify(e.kernelSize)+".")},t}(wP);NP.className="Conv3D",dR(NP);var IP=function(e){function t(t){var n;if((n=e.call(this,t)||this).inputSpec=[new FM({ndim:4})],"same"!==n.padding&&"valid"!==n.padding)throw new HO("Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode "+n.padding);return n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t;if(4!==(e=TM(e)).length)throw new HO("Input should have rank 4; Received input shape: "+JSON.stringify(e));var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new HO("The channel dimension of the inputs should be defined. Found `None`.");var r=e[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 FM({ndim:4,axes:(t={},t[n]=r,t)})],this.built=!0},n.call=function(e,t){var n=this;return eI((function(){var t=SM(e);if(4!==t.shape.length)throw new HO("Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-"+t.shape.length);var r,a,i=t.shape,o=i[0];"channelsFirst"===n.dataFormat?(r=2,a=3):(r=1,a=2);var s=i[r],u=i[a],l=n.kernelSize[0],c=n.kernelSize[1],p=n.strides[0],h=n.strides[1],d=[o,fP(s,p,l,n.padding),fP(u,h,c,n.padding),n.filters];"channelsLast"!==n.dataFormat&&(t=PE(t,[0,2,3,1]));var f=pS(t,n.kernel.read(),d,n.strides,n.padding);return"channelsLast"!==n.dataFormat&&(f=PE(f,[0,3,1,2])),null!=n.bias&&(f=QD(f,n.bias.read(),n.dataFormat)),null!=n.activation&&(f=n.activation.apply(f)),f}))},n.computeOutputShape=function(e){var t,n,r,a=(e=TM(e)).slice();"channelsFirst"===this.dataFormat?(t=1,n=2,r=3):(t=3,n=1,r=2);var i=this.kernelSize[0],o=this.kernelSize[1],s=this.strides[0],u=this.strides[1];return a[t]=this.filters,a[n]=fP(a[n],s,i,this.padding),a[r]=fP(a[r],u,o,this.padding),a},n.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.dilationRate,t},t}(kP);IP.className="Conv2DTranspose",dR(IP);var SP=function(e){function t(t){var n;if((n=e.call(this,t)||this).inputSpec=[new FM({ndim:5})],"same"!==n.padding&&"valid"!==n.padding)throw new HO("Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode "+n.padding);return n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t;if(5!==(e=TM(e)).length)throw new HO("Input should have rank 5; Received input shape: "+JSON.stringify(e));var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new HO("The channel dimension of the inputs should be defined. Found `None`.");var r=e[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 FM({ndim:5,axes:(t={},t[n]=r,t)})],this.built=!0},n.call=function(e,t){var n=this;return eI((function(){var t=SM(e);if(5!==t.shape.length)throw new HO("Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-"+t.shape.length);var r,a,i,o=t.shape,s=o[0];"channelsFirst"===n.dataFormat?(i=2,r=3,a=4):(i=1,r=2,a=3);var u=o[i],l=o[r],c=o[a],p=n.kernelSize[0],h=n.kernelSize[1],d=n.kernelSize[2],f=n.strides[0],m=n.strides[1],v=n.strides[2],g=[s,fP(u,f,p,n.padding),fP(l,m,h,n.padding),fP(c,v,d,n.padding),n.filters];"channelsLast"!==n.dataFormat&&(t=PE(t,[0,2,3,4,1]));var y=fS(t,n.kernel.read(),g,n.strides,n.padding);return"channelsLast"!==n.dataFormat&&(y=PE(y,[0,4,1,2,3])),null!==n.bias&&(y=QD(y,n.bias.read(),n.dataFormat)),null!==n.activation&&(y=n.activation.apply(y)),y}))},n.computeOutputShape=function(e){var t,n,r,a,i=(e=TM(e)).slice();"channelsFirst"===this.dataFormat?(t=1,n=2,r=3,a=4):(t=4,n=1,r=2,a=3);var o=this.kernelSize[0],s=this.kernelSize[1],u=this.kernelSize[2],l=this.strides[0],c=this.strides[1],p=this.strides[2];return i[t]=this.filters,i[n]=fP(i[n],l,o,this.padding),i[r]=fP(i[r],c,s,this.padding),i[a]=fP(i[a],p,u,this.padding),i},n.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.dilationRate,t},t}(NP);SP.className="Conv3DTranspose",dR(SP);var TP=function(e){function t(t,n){var r;if((r=e.call(this,t,n)||this).DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",r.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",r.depthwiseKernel=null,r.pointwiseKernel=null,null==n.filters)throw new HO("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=n.kernelInitializer||null!=n.kernelRegularizer||null!=n.kernelConstraint)throw new HO("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 HO("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=kM(n.depthwiseInitializer||r.DEFAULT_DEPTHWISE_INITIALIZER),r.depthwiseRegularizer=iP(n.depthwiseRegularizer),r.depthwiseConstraint=rL(n.depthwiseConstraint),r.pointwiseInitializer=kM(n.depthwiseInitializer||r.DEFAULT_POINTWISE_INITIALIZER),r.pointwiseRegularizer=iP(n.pointwiseRegularizer),r.pointwiseConstraint=rL(n.pointwiseConstraint),r}Cv(t,e);var n=t.prototype;return n.build=function(e){var t;if((e=TM(e)).length<this.rank+2)throw new HO("Inputs to SeparableConv"+this.rank+"D should have rank "+(this.rank+2)+", but received input shape: "+JSON.stringify(e));var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n]||e[n]<0)throw new HO("The channel dimension of the inputs should be defined, but found "+JSON.stringify(e[n]));for(var r=e[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);var s=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",a,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,s,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",i,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,s,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,s,this.biasConstraint):this.bias=null,this.inputSpec=[new FM({ndim:this.rank+2,axes:(t={},t[n]=r,t)})],this.built=!0},n.call=function(e,t){var n=this;return eI((function(){var t;if(e=SM(e),1===n.rank)throw new qO("1D separable convolution is not implemented yet.");return 2===n.rank&&("channelsFirst"===n.dataFormat&&(e=PE(e,[0,2,3,1])),t=KC(e,n.depthwiseKernel.read(),n.pointwiseKernel.read(),n.strides,n.padding,n.dilationRate,"NHWC")),n.useBias&&(t=QD(t,n.bias.read(),n.dataFormat)),null!=n.activation&&(t=n.activation.apply(t)),"channelsFirst"===n.dataFormat&&(t=PE(t,[0,3,1,2])),t}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.rank,delete t.kernelInitializer,delete t.kernelRegularizer,delete t.kernelConstraint,t.depthwiseInitializer=wM(this.depthwiseInitializer),t.pointwiseInitializer=wM(this.pointwiseInitializer),t.depthwiseRegularizer=rP(this.depthwiseRegularizer),t.pointwiseRegularizer=rP(this.pointwiseRegularizer),t.depthwiseConstraint=tL(this.depthwiseConstraint),t.pointwiseConstraint=tL(this.pointwiseConstraint),t},t}(wP);TP.className="SeparableConv";var CP=function(e){function t(t){return e.call(this,2,t)||this}return Cv(t,e),t}(TP);CP.className="SeparableConv2D",dR(CP);var EP=function(e){function t(n){var r;return r=e.call(this,1,n)||this,t.verifyArgs(n),r.inputSpec=[{ndim:3}],r}return Cv(t,e),t.prototype.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.rank,delete t.dataFormat,t},t.verifyArgs=function(e){if("number"!=typeof e.kernelSize&&!cD(e.kernelSize,"number",1,1))throw new HO("Conv1D expects config.kernelSize to be number or number[] with length 1, but received "+JSON.stringify(e.kernelSize)+".")},t}(wP);EP.className="Conv1D",dR(EP);var AP=function(e){function t(t){var n;return n=e.call(this,t)||this,"number"==typeof t.cropping?n.cropping=[[t.cropping,t.cropping],[t.cropping,t.cropping]]:"number"==typeof t.cropping[0]?n.cropping=[[t.cropping[0],t.cropping[0]],[t.cropping[1],t.cropping[1]]]:n.cropping=t.cropping,n.dataFormat=void 0===t.dataFormat?"channelsLast":t.dataFormat,n.inputSpec=[{ndim:4}],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return"channelsFirst"===this.dataFormat?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]},n.call=function(e,t){var n=this;return eI((function(){if(e=SM(e),"channelsLast"===n.dataFormat){var t=GD(e,n.cropping[0][0],e.shape[1]-n.cropping[0][0]-n.cropping[0][1],2);return GD(t,n.cropping[1][0],e.shape[2]-n.cropping[1][1]-n.cropping[1][0],3)}var r=GD(e,n.cropping[0][0],e.shape[2]-n.cropping[0][0]-n.cropping[0][1],3);return GD(r,n.cropping[1][0],e.shape[3]-n.cropping[1][1]-n.cropping[1][0],4)}))},n.getConfig=function(){var t={cropping:this.cropping,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);AP.className="Cropping2D",dR(AP);var RP=function(e){function t(t){var n,r;return(n=e.call(this,t)||this).DEFAULT_SIZE=[2,2],n.inputSpec=[{ndim:4}],n.size=null==t.size?n.DEFAULT_SIZE:t.size,n.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,ID(n.dataFormat),n.interpolation=null==t.interpolation?"nearest":t.interpolation,r=n.interpolation,lD(bD,"InterpolationFormat",r),n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){if("channelsFirst"===this.dataFormat){var t=null==e[2]?null:this.size[0]*e[2],n=null==e[3]?null:this.size[1]*e[3];return[e[0],e[1],t,n]}var r=null==e[1]?null:this.size[0]*e[1],a=null==e[2]?null:this.size[1]*e[2];return[e[0],r,a,e[3]]},n.call=function(e,t){var n=this;return eI((function(){var t=SM(e),r=t.shape;if("channelsFirst"===n.dataFormat){t=PE(t,[0,2,3,1]);var a=n.size[0]*r[2],i=n.size[1]*r[3],o="nearest"===n.interpolation?oR.resizeNearestNeighbor(t,[a,i]):oR.resizeBilinear(t,[a,i]);return PE(o,[0,3,1,2])}var s=n.size[0]*r[1],u=n.size[1]*r[2];return"nearest"===n.interpolation?oR.resizeNearestNeighbor(t,[s,u]):oR.resizeBilinear(t,[s,u])}))},n.getConfig=function(){var t={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);RP.className="UpSampling2D",dR(RP);var _P=function(e){function t(t){var n;return(n=e.call(this,2,t)||this).depthwiseKernel=null,n.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,n.depthwiseInitializer=kM(t.depthwiseInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.depthwiseConstraint=rL(t.depthwiseConstraint),n.depthwiseRegularizer=iP(t.depthwiseRegularizer),n}Cv(t,e);var n=t.prototype;return n.build=function(e){if((e=TM(e)).length<4)throw new HO("Inputs to DepthwiseConv2D should have rank 4. Received input shape: "+JSON.stringify(e)+".");var t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new HO("The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not ("+e[t]+").");var n=e[t],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(e,t){var n=this;return eI((function(){e=SM(e);var t,r,a,i,o,s,u=(t=e,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"),eI((function(){null==o&&(o="channelsLast"),ID(o);var e=mP(t,o);if(4!==t.rank)throw new HO("Input for depthwiseConv2d is required to be 4-D, but is instead "+t.rank+"-D");if(4!==r.rank)throw new HO("depthwiseKernel is required to be 4-D, but is instead "+r.rank+"-D");return e=wS(e,r,a,"same"===i?"same":"valid","NHWC",s),"channelsFirst"===o&&(e=PE(e,[0,3,1,2])),e})));return n.useBias&&(u=QD(u,n.bias.read(),n.dataFormat)),null!=n.activation&&(u=n.activation.apply(u)),u}))},n.computeOutputShape=function(e){e=TM(e);var t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=dP(t,this.kernelSize[0],this.padding,this.strides[0]),i=dP(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],r,a,i]:[e[0],a,i,r]},n.getConfig=function(){var t=e.prototype.getConfig.call(this);return t.depthMultiplier=this.depthMultiplier,t.depthwiseInitializer=wM(this.depthwiseInitializer),t.depthwiseRegularizer=rP(this.depthwiseRegularizer),t.depthwiseConstraint=tL(this.depthwiseRegularizer),t},t}(xP);function FP(e,t,n,r){if(Array.isArray(e)){if(null!=t||null!=n)throw new HO("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=e.slice(e.length-r,e.length),e=e.slice(0,e.length-r)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function a(e){return null==e||Array.isArray(e)?e:[e]}return{inputs:e,initialState:t=a(t),constants:n=a(n)}}function OP(e,t,n,r,a,i,o,s){return void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),eI((function(){var u=t.shape.length;if(u<3)throw new HO("Input should be at least 3D, but is "+u+"D.");var l=[1,0].concat(zD(2,u));if(t=PE(t,l),null!=i)throw new qO("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=XN(XN(a,"bool"),"float32")).rank===u-1&&(a=tT(a,-1)),a=PE(a,l)),r&&(t=BC(t,0),null!=a&&(a=BC(a,0)));var c,p,h=[],d=n,f=t.shape[0],m=RE(t);null!=a&&(p=RE(a));for(var v,g=function(t){var n=m[t],r=eI((function(){return e(n,d)}));if(null==a)c=r[0],d=r[1];else{var i=eI((function(){var e=p[t],n=TT(QT(e),e);return{output:oI(lI(r[0],e),lI(d[0],n)),newStates:d.map((function(t,a){return oI(lI(r[1][a],e),lI(t,n))}))}}));c=i.output,d=i.newStates}s&&h.push(c)},y=0;y<f;++y)g(y);if(s){v=pE(h,1)}return[c,v,d]}))}_P.className="DepthwiseConv2D",dR(_P);var DP=function(e){function t(t){var n,r;if(n=e.call(this,t)||this,null==t.cell)throw new HO("cell property is missing for the constructor of RNN.");if(null==(r=Array.isArray(t.cell)?new UP({cells:t.cell}):t.cell).stateSize)throw new HO("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");return n.cell=r,n.returnSequences=null!=t.returnSequences&&t.returnSequences,n.returnState=null!=t.returnState&&t.returnState,n.goBackwards=null!=t.goBackwards&&t.goBackwards,n._stateful=null!=t.stateful&&t.stateful,n.unroll=null!=t.unroll&&t.unroll,n.supportsMasking=!0,n.inputSpec=[new FM({ndim:3})],n.stateSpec=null,n.states_=null,n.numConstants=null,n.keptStates=[],n}Cv(t,e);var n=t.prototype;return n.getStates=function(){return null==this.states_?zD(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((function(e){return null})):this.states_},n.setStates=function(e){this.states_=e},n.computeOutputShape=function(e){NM(e)&&(e=e[0]);var t=this.cell.stateSize;Array.isArray(t)||(t=[t]);var n,r=t[0];if(n=this.returnSequences?[e[0],e[1],r]:[e[0],r],this.returnState){for(var a,i=[],o=Lv(t);!(a=o()).done;){var s=a.value;i.push([e[0],s])}return[n].concat(i)}return n},n.computeMask=function(e,t){var n=this;return eI((function(){Array.isArray(t)&&(t=t[0]);var e=n.returnSequences?t:null;if(n.returnState){var r=n.states.map((function(e){return null}));return[e].concat(r)}return e}))},n.build=function(e){if(null!=this.numConstants)throw new qO("Constants support is not implemented in RNN yet.");NM(e)&&(e=e[0]);var t=this.stateful?e[0]:null,n=e.slice(2);this.inputSpec[0]=new FM({shape:[t,null].concat(n)});var r,a=[e[0]].concat(e.slice(2));if(this.cell.build(a),r=Array.isArray(this.cell.stateSize)?this.cell.stateSize:[this.cell.stateSize],null!=this.stateSpec){if(!Yv(this.stateSpec.map((function(e){return e.shape[e.shape.length-1]})),r))throw new HO("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(e){return new FM({shape:[null,e]})}));this.stateful&&this.resetStates()},n.resetStates=function(e,t){var n=this;void 0===t&&(t=!1),eI((function(){if(!n.stateful)throw new GO("Cannot call resetStates() on an RNN Layer that is not stateful.");var r=n.inputSpec[0].shape[0];if(null==r)throw new HO("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(e){return VT([r,e])})):n.states_=[VT([r,n.cell.stateSize])];else if(null==e)tI(n.states_),null!=n.keptStates&&(tI(n.keptStates),n.keptStates=[]),Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(e){return VT([r,e])})):n.states_[0]=VT([r,n.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==n.states_.length)throw new HO("Layer "+n.name+" expects "+n.states_.length+" state(s), but it received "+e.length+" state value(s). Input received: "+e);!0===t?n.keptStates.push(n.states_.slice()):tI(n.states_);for(var a=0;a<n.states_.length;++a){var i=e[a],o=Array.isArray(n.cell.stateSize)?n.cell.stateSize[a]:n.cell.stateSize,s=[r,o];if(!Yv(i.shape,s))throw new HO("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(e){return nI(e.clone())}))}))},n.apply=function(t,n){var r=null==n?null:n.initialState,a=null==n?null:n.constants;null==n&&(n={});var i=FP(t,r,a,this.numConstants);t=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,l=Lv(r);!(u=l()).done;){var c=u.value;this.stateSpec.push(new FM({shape:c.shape}))}s=s.concat(this.stateSpec)}if(null!=a&&(n.constants=a,o=o.concat(a),this.numConstants=a.length),o[0]instanceof OM){var p=[t].concat(o),h=this.inputSpec.concat(s),d=this.inputSpec;this.inputSpec=h;var f=e.prototype.apply.call(this,p,n);return this.inputSpec=d,f}return e.prototype.apply.call(this,t,n)},n.call=function(e,t){var n=this;return eI((function(){var r=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;e=SM(e),null==i&&(i=n.stateful?n.states_:n.getInitialState(e));var o=Array.isArray(n.cell.stateSize)?n.cell.stateSize.length:1;if(i.length!==o)throw new HO("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=OP((function(e,t){var r=n.cell.call([e].concat(t),s);return[r[0],r.slice(1)]}),e,i,n.goBackwards,r,null,n.unroll,n.returnSequences),l=u[0],c=u[1],p=u[2];n.stateful&&n.resetStates(p,a);var h=n.returnSequences?c:l;return n.returnState?[h].concat(p):h}))},n.getInitialState=function(e){var t=this;return eI((function(){var n=VT(e.shape);return n=WD(n=JS(n,[1,2])),Array.isArray(t.cell.stateSize)?t.cell.stateSize.map((function(e){return e>1?qD(n,[1,e]):n})):t.cell.stateSize>1?[qD(n,[1,t.cell.stateSize])]:[n]}))},n.setFastWeightInitDuringBuild=function(t){e.prototype.setFastWeightInitDuringBuild.call(this,t),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(t)},n.getConfig=function(){var n=e.prototype.getConfig.call(this),r={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(r.numConstants=this.numConstants);var a=this.cell.getConfig();return this.getClassName()===t.className&&(r.cell={className:this.cell.getClassName(),config:a}),Object.assign(Object.assign(Object.assign({},a),n),r)},t.fromConfig=function(e,t,n){void 0===n&&(n={});var r=yL(t.cell,n);return new e(Object.assign(t,{cell:r}))},Tv(t,[{key:"states",get:function(){if(null==this.states_){for(var e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[],n=0;n<e;++n)t.push(null);return t}return this.states_},set:function(e){this.states_=e}},{key:"trainableWeights",get:function(){return this.trainable?this.cell.trainableWeights:[]}},{key:"nonTrainableWeights",get:function(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}}]),t}(zM);DP.className="RNN",dR(DP);var MP=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t}(zM),LP=function(e){function t(t){var n;return(n=e.call(this,t)||this).DEFAULT_ACTIVATION="tanh",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=t.units,pD(n.units,"units"),n.activation=Qz(null==t.activation?n.DEFAULT_ACTIVATION:t.activation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=kM(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=kM(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=kM(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=iP(t.kernelRegularizer),n.recurrentRegularizer=iP(t.recurrentRegularizer),n.biasRegularizer=iP(t.biasRegularizer),n.kernelConstraint=rL(t.kernelConstraint),n.recurrentConstraint=rL(t.recurrentConstraint),n.biasConstraint=rL(t.biasConstraint),n.dropout=MD([1,LD([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=MD([1,LD([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.dropoutFunc=t.dropoutFunc,n.stateSize=n.units,n.dropoutMask=null,n.recurrentDropoutMask=null,n}Cv(t,e);var n=t.prototype;return n.build=function(e){e=TM(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},n.call=function(e,t){var n=this;return eI((function(){if(2!==e.length)throw new HO("SimpleRNNCell expects 2 input Tensors, got "+e.length+".");var r=e[1];e=e[0];var a,i=null!=t.training&&t.training;0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=GP({ones:function(){return QT(e)},rate:n.dropout,training:i,dropoutFunc:n.dropoutFunc})),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=GP({ones:function(){return QT(r)},rate:n.recurrentDropout,training:i,dropoutFunc:n.dropoutFunc}));var o=n.dropoutMask,s=n.recurrentDropoutMask;a=XD(null!=o?lI(e,o):e,n.kernel.read()),null!=n.bias&&(a=QD(a,n.bias.read())),null!=s&&(r=lI(r,s));var u=oI(a,XD(r,n.recurrentKernel.read()));return null!=n.activation&&(u=n.activation.apply(u)),[u,u]}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={units:this.units,activation:Jz(this.activation),useBias:this.useBias,kernelInitializer:wM(this.kernelInitializer),recurrentInitializer:wM(this.recurrentInitializer),biasInitializer:wM(this.biasInitializer),kernelRegularizer:rP(this.kernelRegularizer),recurrentRegularizer:rP(this.recurrentRegularizer),biasRegularizer:rP(this.biasRegularizer),activityRegularizer:rP(this.activityRegularizer),kernelConstraint:tL(this.kernelConstraint),recurrentConstraint:tL(this.recurrentConstraint),biasConstraint:tL(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},t),n)},t}(MP);LP.className="SimpleRNNCell",dR(LP);var zP=function(e){function t(t){return t.cell=new LP(t),e.call(this,t)||this}return Cv(t,e),t.prototype.call=function(t,n){var r=this;return eI((function(){null!=r.cell.dropoutMask&&(tI(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(tI(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 e.prototype.call.call(r,t,{mask:a,training:i,initialState:o})}))},t.fromConfig=function(e,t){return new e(t)},t}(DP);zP.className="SimpleRNN",dR(zP);var PP=function(e){function t(t){var n;if((n=e.call(this,t)||this).DEFAULT_ACTIVATION="tanh",n.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",t.resetAfter)throw new HO("GRUCell does not support reset_after parameter set to true.");return n.units=t.units,pD(n.units,"units"),n.activation=Qz(void 0===t.activation?n.DEFAULT_ACTIVATION:t.activation),n.recurrentActivation=Qz(void 0===t.recurrentActivation?n.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=kM(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=kM(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=kM(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=iP(t.kernelRegularizer),n.recurrentRegularizer=iP(t.recurrentRegularizer),n.biasRegularizer=iP(t.biasRegularizer),n.kernelConstraint=rL(t.kernelConstraint),n.recurrentConstraint=rL(t.recurrentConstraint),n.biasConstraint=rL(t.biasConstraint),n.dropout=MD([1,LD([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=MD([1,LD([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.dropoutFunc=t.dropoutFunc,n.implementation=t.implementation,n.stateSize=n.units,n.dropoutMask=null,n.recurrentDropoutMask=null,n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t=(e=TM(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,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(e,t){var n=this;return eI((function(){if(2!==e.length)throw new HO("GRUCell expects 2 input Tensors (inputs, h, c), got "+e.length+".");var r=null!=t.training&&t.training,a=e[1];e=e[0],0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=GP({ones:function(){return QT(e)},rate:n.dropout,training:r,count:3,dropoutFunc:n.dropoutFunc})),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=GP({ones:function(){return QT(a)},rate:n.recurrentDropout,training:r,count:3,dropoutFunc:n.dropoutFunc}));var i,o,s,u=n.dropoutMask,l=n.recurrentDropoutMask;0<n.dropout&&n.dropout<1&&(e=lI(e,u[0]));var c=XD(e,n.kernel.read());n.useBias&&(c=QD(c,n.bias.read())),0<n.recurrentDropout&&n.recurrentDropout<1&&(a=lI(a,l[0]));var p=n.recurrentKernel.read(),h=sE(p,[2*n.units,n.units],p.rank-1),d=h[0],f=h[1],m=XD(a,d),v=sE(c,3,c.rank-1),g=v[0],y=v[1],b=v[2],x=sE(m,2,m.rank-1),w=x[0],k=x[1];i=n.recurrentActivation.apply(oI(g,w)),o=n.recurrentActivation.apply(oI(y,k));var N=XD(lI(o,a),f);s=n.activation.apply(oI(b,N));var I=oI(lI(i,a),lI(oI(1,NT(i)),s));return[I,I]}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={units:this.units,activation:Jz(this.activation),recurrentActivation:Jz(this.recurrentActivation),useBias:this.useBias,kernelInitializer:wM(this.kernelInitializer),recurrentInitializer:wM(this.recurrentInitializer),biasInitializer:wM(this.biasInitializer),kernelRegularizer:rP(this.kernelRegularizer),recurrentRegularizer:rP(this.recurrentRegularizer),biasRegularizer:rP(this.biasRegularizer),activityRegularizer:rP(this.activityRegularizer),kernelConstraint:tL(this.kernelConstraint),recurrentConstraint:tL(this.recurrentConstraint),biasConstraint:tL(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign(Object.assign({},t),n)},t}(MP);PP.className="GRUCell",dR(PP);var BP=function(e){function t(t){return 0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new PP(t),e.call(this,t)||this}return Cv(t,e),t.prototype.call=function(t,n){var r=this;return eI((function(){null!=r.cell.dropoutMask&&(tI(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(tI(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 e.prototype.call.call(r,t,{mask:a,training:i,initialState:o})}))},t.fromConfig=function(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)},t}(DP);BP.className="GRU",dR(BP);var WP=function(e){function t(t){var n;return(n=e.call(this,t)||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=t.units,pD(n.units,"units"),n.activation=Qz(void 0===t.activation?n.DEFAULT_ACTIVATION:t.activation),n.recurrentActivation=Qz(void 0===t.recurrentActivation?n.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=kM(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=kM(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=kM(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.unitForgetBias=t.unitForgetBias,n.kernelRegularizer=iP(t.kernelRegularizer),n.recurrentRegularizer=iP(t.recurrentRegularizer),n.biasRegularizer=iP(t.biasRegularizer),n.kernelConstraint=rL(t.kernelConstraint),n.recurrentConstraint=rL(t.recurrentConstraint),n.biasConstraint=rL(t.biasConstraint),n.dropout=MD([1,LD([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=MD([1,LD([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.dropoutFunc=t.dropoutFunc,n.implementation=t.implementation,n.stateSize=[n.units,n.units],n.dropoutMask=null,n.recurrentDropoutMask=null,n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t,n,r=(e=TM(e))[e.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(t=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e,t){var n=a.apply([i]),r=(new iM).apply([i]),o=a.apply([2*i]);return HD(HD(n,r),o)},t}(rM),t.className="CustomInit",t)}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(e,t){var n=this;return eI((function(){var r=null!=t.training&&t.training;if(3!==e.length)throw new HO("LSTMCell expects 3 input Tensors (inputs, h, c), got "+e.length+".");var a=e[1],i=e[2];e=e[0],0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=GP({ones:function(){return QT(e)},rate:n.dropout,training:r,count:4,dropoutFunc:n.dropoutFunc})),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=GP({ones:function(){return QT(a)},rate:n.recurrentDropout,training:r,count:4,dropoutFunc:n.dropoutFunc}));var o,s,u,l,c=n.dropoutMask,p=n.recurrentDropoutMask;0<n.dropout&&n.dropout<1&&(e=lI(e,c[0]));var h=XD(e,n.kernel.read());0<n.recurrentDropout&&n.recurrentDropout<1&&(a=lI(a,p[0])),h=oI(h,XD(a,n.recurrentKernel.read())),n.useBias&&(h=QD(h,n.bias.read()));var d=sE(h,4,h.rank-1),f=d[0],m=d[1],v=d[2],g=d[3];o=n.recurrentActivation.apply(f),s=n.recurrentActivation.apply(m),u=oI(lI(s,i),lI(o,n.activation.apply(v))),l=n.recurrentActivation.apply(g);var y=lI(l,n.activation.apply(u));return[y,y,u]}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={units:this.units,activation:Jz(this.activation),recurrentActivation:Jz(this.recurrentActivation),useBias:this.useBias,kernelInitializer:wM(this.kernelInitializer),recurrentInitializer:wM(this.recurrentInitializer),biasInitializer:wM(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:rP(this.kernelRegularizer),recurrentRegularizer:rP(this.recurrentRegularizer),biasRegularizer:rP(this.biasRegularizer),activityRegularizer:rP(this.activityRegularizer),kernelConstraint:tL(this.kernelConstraint),recurrentConstraint:tL(this.recurrentConstraint),biasConstraint:tL(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign(Object.assign({},t),n)},t}(MP);WP.className="LSTMCell",dR(WP);var VP=function(e){function t(t){return 0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new WP(t),e.call(this,t)||this}return Cv(t,e),t.prototype.call=function(t,n){var r=this;return eI((function(){null!=r.cell.dropoutMask&&(tI(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(tI(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 e.prototype.call.call(r,t,{mask:a,training:i,initialState:o})}))},t.fromConfig=function(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)},t}(DP);VP.className="LSTM",dR(VP);var UP=function(e){function t(t){var n;return(n=e.call(this,t)||this).cells=t.cells,n}Cv(t,e);var n=t.prototype;return n.call=function(e,t){var n=this;return eI((function(){for(var r,a=e.slice(1),i=[],o=Lv(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,l=[],c=0;c<n.cells.length;++c){var p=n.cells[c];a=i[c],u=0===c?[e[0]].concat(a):[u[0]].concat(a),u=p.call(u,t),l.push(u.slice(1))}a=[];for(var h,d=Lv(l.slice().reverse());!(h=d()).done;){var f,m=h.value;(f=a).push.apply(f,m)}return[u[0]].concat(a)}))},n.build=function(e){var t;NM(e)&&(e=e[0]),this.cells.forEach((function(n,r){ED("RNNCell_"+r,(function(){n.build(e),t=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,e=[e[0],t]}))})),this.built=!0},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={cells:this.cells.map((function(e){return{className:e.getClassName(),config:e.getConfig()}}))};return Object.assign(Object.assign({},t),n)},t.fromConfig=function(e,t,n){void 0===n&&(n={});for(var r,a=[],i=Lv(t.cells);!(r=i()).done;){var o=r.value;a.push(yL(o,n))}return new e({cells:a})},n.getWeights=function(){for(var e,t=[],n=Lv(this.cells);!(e=n()).done;){var r=e.value;t.push.apply(t,r.weights)}return RM(t)},n.setWeights=function(e){for(var t,n=[],r=Lv(this.cells);!(t=r()).done;)for(var a=t.value,i=a.weights.length,o=e.splice(i),s=0;s<a.weights.length;++s)n.push([a.weights[s],o[s]]);_M(n)},Tv(t,[{key:"stateSize",get:function(){for(var e,t=[],n=Lv(this.cells.slice().reverse());!(e=n()).done;){var r=e.value;Array.isArray(r.stateSize)?t.push.apply(t,r.stateSize):t.push(r.stateSize)}return t}},{key:"trainableWeights",get:function(){if(!this.trainable)return[];for(var e,t=[],n=Lv(this.cells);!(e=n()).done;){var r=e.value;t.push.apply(t,r.trainableWeights)}return t}},{key:"nonTrainableWeights",get:function(){for(var e,t=[],n=Lv(this.cells);!(e=n()).done;){var r=e.value;t.push.apply(t,r.nonTrainableWeights)}if(!this.trainable){for(var a,i=[],o=Lv(this.cells);!(a=o()).done;){var s=a.value;i.push.apply(i,s.trainableWeights)}return i.concat(t)}return t}}]),t}(MP);function GP(e){var t=e.ones,n=e.rate,r=e.training,a=void 0!==r&&r,i=e.count,o=void 0===i?1:i,s=e.dropoutFunc,u=function(){return null!=s?s(t(),n):$D(t(),n)},l=function(){return eM(u,t,a)};return!o||o<=1?nI(l().clone()):Array(o).fill(void 0).map(l).map((function(e){return nI(e.clone())}))}UP.className="StackedRNNCells",dR(UP);var jP=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n},HP=function(e){function t(t){var n;if(t.unroll)throw new qO("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(t.cell))throw new qO("It is not possible at the moment to stack convolutional cells.");return(n=e.call(this,t)||this).inputSpec=[new FM({ndim:5})],n}Cv(t,e);var n=t.prototype;return n.call=function(t,n){var r=this;return eI((function(){if(null!=r.cell.dropoutMask&&(tI(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(tI(r.cell.recurrentDropoutMask),r.cell.recurrentDropoutMask=null),n&&n.constants)throw new HO("ConvRNN2D cell does not support constants");var a=null==n?null:n.mask,i=null==n?null:n.training,o=null==n?null:n.initialState;return e.prototype.call.call(r,t,{mask:a,training:i,initialState:o})}))},n.computeOutputShape=function(e){var t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0]].concat(t.slice(2))),this.returnState&&(t=[t].concat(Array(2).fill([e[0]].concat(t.slice(-3))))),t},n.getInitialState=function(e){var t=this;return eI((function(){var n=t.cell.stateSize,r=e.shape,a=t.computeSingleOutputShape(r),i=VT([a[0]].concat(a.slice(2)));return Array.isArray(n)?Array(n.length).fill(i):[i]}))},n.resetStates=function(e,t){var n=this;void 0===t&&(t=!1),eI((function(){if(!n.stateful)throw new GO("Cannot call resetStates() on an RNN Layer that is not stateful.");var r=n.inputSpec[0].shape,a=n.computeSingleOutputShape(r),i=[a[0]].concat(a.slice(2));if(null==r[0])throw new HO("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.getStates())Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(){return VT(i)})):n.states_=[VT(i)];else if(null==e)tI(n.states_),null!=n.keptStates&&(tI(n.keptStates),n.keptStates=[]),Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(){return VT(i)})):n.states_[0]=VT(i);else{if(Array.isArray(e)||(e=[e]),e.length!==n.states_.length)throw new HO("Layer "+n.name+" expects "+n.states_.length+" state(s), but it received "+e.length+" state value(s). Input received: "+e);t?n.keptStates.push(n.states_.slice()):tI(n.states_);for(var o=0;o<n.states_.length;++o){var s=e[o],u=i;if(!Yv(s.shape,u))throw new HO("State "+o+" is incompatible with layer "+n.name+": expected shape="+u+", received shape="+s.shape);n.states_[o]=s}}n.states_=n.states_.map((function(e){return nI(e.clone())}))}))},n.computeSingleOutputShape=function(e){var t=this.cell,n=t.dataFormat,r=t.filters,a=t.kernelSize,i=t.padding,o=t.strides,s=t.dilationRate,u="channelsFirst"===n,l=e[u?3:2],c=e[u?4:3],p=dP(l,a[0],i,o[0],s[0]),h=dP(c,a[1],i,o[1],s[1]);return[].concat(e.slice(0,2),u?[r,p,h]:[p,h,r])},t}(DP);HP.className="ConvRNN2D";var qP=function(e){function t(t){var n,r=t.filters,a=t.kernelSize,i=t.strides,o=t.padding,s=t.dataFormat,u=t.dilationRate;return(n=e.call(this,Object.assign(Object.assign({},t),{units:r}))||this).filters=r,pD(n.filters,"filters"),n.kernelSize=hP(a,2,"kernelSize"),n.kernelSize.forEach((function(e){return pD(e,"kernelSize")})),n.strides=hP(i||1,2,"strides"),n.strides.forEach((function(e){return pD(e,"strides")})),n.padding=o||"valid",SD(n.padding),n.dataFormat=s||"channelsLast",ID(n.dataFormat),n.dilationRate=hP(u||1,2,"dilationRate"),n.dilationRate.forEach((function(e){return pD(e,"dilationRate")})),n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t;e=TM(e);var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new HO("The channel dimension of the input should be defined. Found "+e[n]);var r=e[n],a=this.kernelSize.concat([r,4*this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);var i=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",i,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){var o;if(this.unitForgetBias){var s=this.biasInitializer,u=this.filters;o=new(t=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.apply=function(e,t){return jD([s.apply([u]),UT([u]),s.apply([2*u])])},t}(rM),t.className="CustomInit",t)}else o=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,o,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0},n.call=function(e,t){var n=this;return eI((function(){if(3!==e.length)throw new HO("ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got "+e.length+".");var r=t.training||!1,a=e[0],i=e[1],o=e[2];0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=GP({ones:function(){return QT(a)},rate:n.dropout,training:r,count:4,dropoutFunc:n.dropoutFunc}));var s=n.dropoutMask,u=function(e,t,n){return t&&t[n]?lI(t[n],e):e},l=u(a,s,0),c=u(a,s,1),p=u(a,s,2),h=u(a,s,3);0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=GP({ones:function(){return QT(i)},rate:n.recurrentDropout,training:r,count:4,dropoutFunc:n.dropoutFunc}));var d=n.recurrentDropoutMask,f=u(i,d,0),m=u(i,d,1),v=u(i,d,2),g=u(i,d,3),y=sE(n.kernel.read(),4,3),b=y[0],x=y[1],w=y[2],k=y[3],N=n.useBias?sE(n.bias.read(),4):[null,null,null,null],I=N[0],S=N[1],T=N[2],C=N[3];l=n.inputConv(l,b,I,n.padding),c=n.inputConv(c,x,S,n.padding),p=n.inputConv(p,w,T,n.padding),h=n.inputConv(h,k,C,n.padding);var E=sE(n.recurrentKernel.read(),4,3),A=E[0],R=E[1],_=E[2],F=E[3];f=n.recurrentConv(f,A),m=n.recurrentConv(m,R),v=n.recurrentConv(v,_),g=n.recurrentConv(g,F);var O=n.recurrentActivation.apply(oI(l,f)),D=n.recurrentActivation.apply(oI(c,m)),M=oI(lI(D,o),lI(O,n.activation.apply(oI(p,v)))),L=lI(n.recurrentActivation.apply(oI(h,g)),n.activation.apply(M));return[L,L,M]}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n=(t.units,jP(t,["units"])),r={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},n),r)},n.inputConv=function(e,t,n,r){var a=uS(e,t,this.strides,r||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return n?QD(a,n,this.dataFormat):a},n.recurrentConv=function(e,t){return uS(e,t,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")},t}(WP);qP.className="ConvLSTM2DCell",dR(qP);var KP=function(e){function t(t){var n=new qP(t);return e.call(this,Object.assign(Object.assign({},t),{cell:n}))||this}return Cv(t,e),t.fromConfig=function(e,t){return new e(t)},t}(HP);KP.className="ConvLSTM2D",dR(KP);var XP=function(e){function t(t){var n;return(n=e.call(this,t)||this).rate=Math.max(Math.min(t.rate,1),0),n.noiseShape=t.noiseShape,n.seed=t.seed,n.supportsMasking=!0,n}Cv(t,e);var n=t.prototype;return n.getNoiseShape=function(e){if(null==this.noiseShape)return this.noiseShape;for(var t=e.shape,n=[],r=0;r<this.noiseShape.length;++r)n.push(null==this.noiseShape[r]?t[r]:this.noiseShape[r]);return n},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r=SM(e);if(0<n.rate&&n.rate<1){var a=null!=t.training&&t.training,i=n.getNoiseShape(r);return eM((function(){return $D(r,n.rate,i,n.seed)}),(function(){return r}),a)}return e}))},n.getConfig=function(){var t={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},n.dispose=function(){return e.prototype.dispose.call(this)},t}(zM);XP.className="Dropout",dR(XP);var YP=function(e){function t(t){var n;return(n=e.call(this,t)||this).inputSpec=[{ndim:3}],n}return Cv(t,e),t.prototype.getNoiseShape=function(e){var t=e.shape;return[t[0],1,t[2]]},t}(XP);YP.className="SpatialDropout1D",dR(YP);var JP=function(e){function t(t){var n;if((n=e.call(this,t)||this).activation=null,n.useBias=!0,n.kernel=null,n.bias=null,n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_BIAS_INITIALIZER="zeros",null==t.batchInputShape&&null==t.inputShape&&null!=t.inputDim){var r=null;null!=t.batchSize&&(r=t.batchSize),n.batchInputShape=[r,t.inputDim]}return n.units=t.units,pD(n.units,"units"),n.activation=Qz(t.activation),null!=t.useBias&&(n.useBias=t.useBias),n.kernelInitializer=kM(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.biasInitializer=kM(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelConstraint=rL(t.kernelConstraint),n.biasConstraint=rL(t.biasConstraint),n.kernelRegularizer=iP(t.kernelRegularizer),n.biasRegularizer=iP(t.biasRegularizer),n.activityRegularizer=iP(t.activityRegularizer),n.supportsMasking=!0,n.inputSpec=[{minNDim:2}],n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t,n=(e=TM(e))[e.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:(t={},t[-1]=n,t)}],this.built=!0},n.computeOutputShape=function(e){var t=(e=TM(e)).slice();return t[t.length-1]=this.units,t},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r,a=SM(e),i=dD(n.activation.getClassName());return null!=i?r=XD(a,n.kernel.read(),i,n.bias?n.bias.read():null):(r=XD(a,n.kernel.read()),null!=n.bias&&(r=QD(r,n.bias.read())),null!=n.activation&&(r=n.activation.apply(r))),r}))},n.getConfig=function(){var t={units:this.units,activation:Jz(this.activation),useBias:this.useBias,kernelInitializer:wM(this.kernelInitializer),biasInitializer:wM(this.biasInitializer),kernelRegularizer:rP(this.kernelRegularizer),biasRegularizer:rP(this.biasRegularizer),activityRegularizer:rP(this.activityRegularizer),kernelConstraint:tL(this.kernelConstraint),biasConstraint:tL(this.biasConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);JP.className="Dense",dR(JP);var ZP=function(e){function t(t){var n;return t=t||{},(n=e.call(this,t)||this).inputSpec=[{minNDim:3}],n.dataFormat=t.dataFormat,n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){for(var t,n=Lv((e=TM(e)).slice(1));!(t=n()).done;){if(null==t.value)throw new HO('The shape of the input to "Flatten" is not fully defined (got '+e.slice(1)+'). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.')}return[e[0],DD(e,1)]},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r=SM(e);if("channelsFirst"===n.dataFormat&&r.rank>1){for(var a=[0],i=2;i<r.rank;++i)a.push(i);a.push(1),r=PE(r,a)}return function(e){if(e.rank<=1)throw new HO("batchFlatten requires a minimum rank of 2. Got rank: "+e.rank+".");var t=[e.shape[0],DD(e.shape,1)];return PI(e,t)}(r)}))},n.getConfig=function(){var t={};null!=this.dataFormat&&(t.dataFormat=this.dataFormat);var n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);ZP.className="Flatten",dR(ZP);var QP=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n.activation=Qz(t.activation),n}Cv(t,e);var n=t.prototype;return n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r=SM(e);return n.activation.apply(r)}))},n.getConfig=function(){var t={activation:Jz(this.activation)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);QP.className="Activation",dR(QP);var $P=function(e){function t(t){var n;return(n=e.call(this,t)||this).n=t.n,n.inputSpec=[{ndim:2}],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return[e[0],this.n,e[1]]},n.call=function(e,t){var n=this;return eI((function(){return e=SM(e),t=e,r=n.n,eI((function(){if(2!==t.shape.length)throw new HO("repeat() expects a rank-2 tensor, but received a rank-"+t.shape.length+" tensor.");return qD(WD(t,1),[1,r,1])}));var t,r}))},n.getConfig=function(){var t={n:this.n},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);$P.className="RepeatVector",dR($P);var eB=function(e){function t(t){var n;(n=e.call(this,t)||this).targetShape=t.targetShape;for(var r=0;r<n.targetShape.length;++r)n.isUnknown(n.targetShape[r])&&(n.targetShape[r]=null);return n}Cv(t,e);var n=t.prototype;return n.isUnknown=function(e){return e<0||null==e},n.fixUnknownDimension=function(e,t){for(var n="Total size of new array must be unchanged.",r=t.slice(),a=1,i=null,o=0;o<r.length;++o){var s=r[o];if(this.isUnknown(s)){if(null!==i)throw new HO("Can only specifiy one unknown dimension.");i=o}else a*=s}var u=DD(e);if(null!==i){if(0===a||u%a!=0)throw new HO(n);r[i]=u/a}else if(u!==a)throw new HO(n);return r},n.computeOutputShape=function(e){for(var t=!1,n=0;n<e.length;++n)if(this.isUnknown(e[n])){t=!0;break}return t?e.slice(0,1).concat(this.targetShape):e.slice(0,1).concat(this.fixUnknownDimension(e.slice(1),this.targetShape))},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r=SM(e),a=r.shape,i=a.slice(0,1).concat(n.fixUnknownDimension(a.slice(1),n.targetShape));return PI(r,i)}))},n.getConfig=function(){var t={targetShape:this.targetShape},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);eB.className="Reshape",dR(eB);var tB=function(e){function t(t){var n;if(n=e.call(this,t)||this,null==t.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(t.dims))throw new Error("Permute constructor requires `dims` to be an Array, but received "+t.dims+" instead.");var r=zD(1,t.dims.length+1);if(!Yv(t.dims.slice().sort(),r))throw new Error("Invalid permutation `dims`: "+JSON.stringify(t.dims)+" `dims` must contain consecutive integers starting from 1.");return n.dims=t.dims,n.dimsIncludingBatch=[0].concat(n.dims),n.inputSpec=[new FM({ndim:n.dims.length+1})],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){var t=(e=TM(e)).slice();return this.dims.forEach((function(n,r){t[r+1]=e[n]})),t},n.call=function(e,t){return PE(SM(e),this.dimsIncludingBatch)},n.getConfig=function(){var t={dims:this.dims},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);tB.className="Permute",dR(tB);var nB=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).supportsMasking=!0,n.maskValue=null!=t?null==t.maskValue?0:t.maskValue:0,n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return e},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={maskValue:this.maskValue};return Object.assign(n,t),n},n.computeMask=function(e,t){var n=SM(e);return mI(JT(n,this.maskValue),-1)},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r=SM(e),a=mI(JT(r,n.maskValue),-1,!0);return lI(r,XN(a,r.dtype))}))},t}(zM);nB.className="Masking",dR(nB);var rB=function(e){function t(t){var n;if((n=e.call(this,t)||this).embeddings=null,n.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==t.batchInputShape&&null==t.inputShape){var r=null;null!=t.batchSize&&(r=t.batchSize),null==t.inputLength?n.batchInputShape=[r,null]:n.batchInputShape=[r].concat($O(t.inputLength))}return n.inputDim=t.inputDim,pD(n.inputDim,"inputDim"),n.outputDim=t.outputDim,pD(n.outputDim,"outputDim"),n.embeddingsInitializer=kM(t.embeddingsInitializer||n.DEFAULT_EMBEDDINGS_INITIALIZER),n.embeddingsRegularizer=iP(t.embeddingsRegularizer),n.activityRegularizer=iP(t.activityRegularizer),n.embeddingsConstraint=rL(t.embeddingsConstraint),n.maskZero=t.maskZero,n.supportsMasking=t.maskZero,n.inputLength=t.inputLength,n}Cv(t,e);var n=t.prototype;return n.build=function(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0},n.warnOnIncompatibleInputShape=function(e){},n.computeMask=function(e,t){var n=this;return eI((function(){return n.maskZero?(e=SM(e),JT(e,RS(e))):null}))},n.computeOutputShape=function(e){if(e=TM(e),null==this.inputLength)return[].concat(e,[this.outputDim]);var t=$O(this.inputLength);if(t.length!==e.length-1)throw new HO('"inputLength" is '+this.inputLength+", but received input shape has shape "+e);for(var n=0,r=0;r<t.length;++r){var a=t[r],i=e[r+1];if(null!=a&&null!=i&&a!==i)throw new HO('"inputLength" is '+this.inputLength+", but received input shape has shape "+e);null==a&&(t[n]=i),n++}return[e[0]].concat(t,[this.outputDim])},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r=SM(e);"int32"!==r.dtype&&(r=BD(r,"int32"));var a=YD(n.embeddings.read(),PI(r,[r.size]));return PI(a,TM(n.computeOutputShape(r.shape)))}))},n.getConfig=function(){var t={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:wM(this.embeddingsInitializer),embeddingsRegularizer:rP(this.embeddingsRegularizer),activityRegularizer:rP(this.activityRegularizer),embeddingsConstraint:tL(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);rB.className="Embedding",dR(rB);var aB=function(e){function t(t){var n;return(n=e.call(this,t||{})||this).supportsMasking=!0,n}Cv(t,e);var n=t.prototype;return n.mergeFunction=function(e){throw new qO},n.computeElementwiseOpOutputShape=function(e,t){if(null==e||null==t)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(0===t.length)return e;for(var n=e.slice(0,e.length-t.length),r=0;r<t.length;++r){var a=e[e.length-t.length+r],i=t[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 HO("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));n.push(a)}}return n},n.build=function(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[TM(e)]),e.length<2)throw new HO("A merge layer should be called on an Array of at least 2 inputs. Got "+e.length+" input(s).");for(var t,n=[],r=Lv(e);!(t=r()).done;){var a=t.value;null!=a&&null!==a[0]&&n.push(a[0])}if((n=sD(n)).length>1)throw new HO("Can not merge tensors with different batch sizes. Got tensors with shapes: "+JSON.stringify(e)+".");for(var i=null==e[0]?null:e[0].slice(1),o=1;o<e.length;++o){var s=null==e[o]?null:e[o].slice(1);i=this.computeElementwiseOpOutputShape(i,s)}var u=e.map((function(e){return e.length}));-1===e.indexOf(null)&&1===sD(u).length?this.reshapeRequired=!1:this.reshapeRequired=!0},n.call=function(e,t){var n=this;return eI((function(){if(n.reshapeRequired){var t=[],r=e.map((function(e){return e.rank}));if(-1===r.indexOf(null)){for(var a,i=LD(r),o=Lv(e);!(a=o()).done;){for(var s=a.value,u=s.rank,l=0;l<i-u;++l)s=WD(s,1);t.push(s)}return n.mergeFunction(t)}for(var c,p=!1,h=Lv(e);!(c=h()).done;){var d=c.value,f=d.rank;if(null==f){var m=d.shape,v=m[0],g=m.slice(1).concat([v]),y=PI(d,[v].concat(DD(m.slice(1))));y=PE(y,[1,0]),y=PI(y,g),t.push(y),p=!0}else if(f>1){var b=zD(1,f).concat([0]);t.push(PE(d,b)),p=!0}else t.push(d)}var x=n.mergeFunction(t),w=x.rank;if(p)if(null==w){var k=x.shape,N=k[k.length-1],I=[N].concat(k.slice(0,k.length-1));x=PI(PE(PI(x,[-1,N]),[1,0]),I)}else if(w>1){var S=[w-1].concat(zD(0,w-1));x=PE(x,S)}return x}return n.mergeFunction(e)}))},n.computeOutputShape=function(e){var t;t=null==e[0]?null:e[0].slice(1);for(var n=1;n<e.length;++n){var r=null==e[n]?null:e[n].slice(1);t=this.computeElementwiseOpOutputShape(t,r)}for(var a,i=[],o=Lv(e);!(a=o()).done;){var s=a.value;null!=s&&null!==s[0]&&i.push(s[0])}return t=1===(i=sD(i)).length?i.concat(t):[null].concat(t)},n.computeMask=function(e,t){return eI((function(){if(null==t)return null;if(!Array.isArray(t))throw new HO("`mask` should be an Array");if(!Array.isArray(e))throw new HO("`inputs` should be an Array");if(t.length!==e.length)throw new HO("The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths ("+e.length+" vs "+t.length+")");if(t.every((function(e){return null==e})))return null;for(var n=(t=t.map((function(e){return null==e?e:tT(e,0)})))[0],r=1;r<t.length-1;++r)n=AT(n,t[r]);return n}))},t}(zM),iB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.mergeFunction=function(e){return eI((function(){for(var t=e[0].clone(),n=1;n<e.length;++n)t=oI(t,e[n]);return t}))},t}(aB);iB.className="Add",dR(iB);var oB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.mergeFunction=function(e){return eI((function(){for(var t=e[0].clone(),n=1;n<e.length;++n)t=lI(t,e[n]);return t}))},t}(aB);oB.className="Multiply",dR(oB);var sB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.mergeFunction=function(e){return eI((function(){for(var t=e[0].clone(),n=1;n<e.length;++n)t=oI(t,e[n]);return lI(1/e.length,t)}))},t}(aB);sB.className="Average",dR(sB);var uB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.mergeFunction=function(e){return eI((function(){for(var t=e[0],n=1;n<e.length;++n)t=BT(t,e[n]);return t}))},t}(aB);uB.className="Maximum",dR(uB);var lB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.mergeFunction=function(e){return eI((function(){for(var t=e[0],n=1;n<e.length;++n)t=jT(t,e[n]);return t}))},t}(aB);lB.className="Minimum",dR(lB);var cB=function(e){function t(t){var n;return(n=e.call(this,t)||this).DEFAULT_AXIS=-1,null==t&&(t={}),n.axis=null==t.axis?n.DEFAULT_AXIS:t.axis,n.supportsMasking=!0,n.reshapeRequired=!1,n}Cv(t,e);var n=t.prototype;return n.build=function(e){if(!Array.isArray(e)||!Array.isArray(e[0])||1===e.length)throw new HO("A `Concatenate` layer should be called on a list of at least 2 inputs");for(var t,n=!0,r=Lv(e);!(t=r()).done;){if(null!=t.value){n=!1;break}}if(!n){for(var a=[],i=0;i<e.length;++i){var o=e[i].slice();o.splice(this.axis,1);for(var s,u=!1,l=Lv(a);!(s=l()).done;){if(Yv(s.value,o)){u=!0;break}}u||a.push(o)}if(a.length>1)throw new HO("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}},n.mergeFunction=function(e){var t=this;return eI((function(){return jD(e,t.axis)}))},n.computeOutputShape=function(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new HO("A `Concatenate` layer should be called on a list of inputs.");for(var t,n=e,r=n[0].slice(),a=this.axis<0?r.length+this.axis:this.axis,i=Lv(n.slice(1));!(t=i()).done;){var o=t.value;if(null==r[a]||null==o[a]){r[a]=null;break}r[a]+=o[a]}return r},n.computeMask=function(e,t){var n=this;if(null==t)return null;if(!Array.isArray(t))throw new HO("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new HO("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new HO("Mismatch in the length of mask ("+t.length+") and the legnth of inputs ("+e.length+")");return eI((function(){var r=!0;if(t.forEach((function(e){null==e||(r=!1)})),r)return null;for(var a=[],i=0;i<e.length;++i)null==t[i]?a.push(XN(QT(e[i]),"bool")):t[i].rank<e[i].rank?a.push(tT(t[i],-1)):a.push(t[i]);var o=VI(a,n.axis);return fI(o,-1,!1)}))},n.getConfig=function(){var t={axis:this.axis},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(aB);function pB(e,t){for(;e<0;)e+=t;return e}cB.className="Concatenate",dR(cB);var hB=function(e){function t(t){var n;return(n=e.call(this,t)||this).axes=t.axes,n.normalize=null!=t.normalize&&t.normalize,n.supportsMasking=!0,n.reshapeRequired=!1,n}Cv(t,e);var n=t.prototype;return n.build=function(e){Hv(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),(function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."}));var t=e[0],n=e[1];if(t.length>3||n.length>3)throw new qO("Dot layer does not support tensors of 4D or higher rank yet.");var r=this.interpretAxes(t,n);if(t[r[0]]!==n[r[1]])throw new HO("Dimension incompatibility: "+t[r[0]]+" !== "+n[r[1]])},n.mergeFunction=function(e){if(2!==e.length)throw new HO("A `Dot` layer must be called on exactly 2 inputs, but received "+e.length+" input(s).");var t,n=e[0],r=e[1];return t=Array.isArray(this.axes)?this.axes.map((function(t,n){return pB(t,e[n].shape.length)})):[pB(this.axes,n.shape.length),pB(this.axes,r.shape.length)],this.normalize&&(n=bL(n,t[0]),r=bL(r,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new qO("batchDot is not implemented for tensors of 4D or higher rank yet");if(Hv(e.shape.length>=2,(function(){return"batchDot requires the rank of x to be >= 2, but got "+e.shape.length})),Hv(e.shape.length>=2,(function(){return"batchDot requires the rank of y to be >= 2, but got "+t.shape.length})),"number"==typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new qO("batchDot is not implemented for complex64-type Tensors yet.");var r=e.shape.length,a=t.shape.length;null==n&&(n=[r-1,a-2]);var i=n;return eI((function(){var n,o;if(r>a){n=r-a;for(var s=[],u=0;u<n;++u)s.push(1);t=PI(t,t.shape.concat(s))}else if(a>r){n=a-r;for(var l=[],c=0;c<n;++c)l.push(1);e=PI(e,e.shape.concat(l))}else n=0;if(2===e.shape.length&&2===t.shape.length)o=i[0]===i[1]?JS(lI(e,t),i[0]):JS(lI(PE(e,[1,0]),t),i[1]);else{var p=i[0]!==e.shape.length-1,h=i[1]===t.shape.length-1;o=UI(e,t,p,h)}if(n>0){for(var d,f=[],m=d=r>a?r+a-3:r-1;m<d+n;++m)f.push(m);o=cE(o,f)}return 1===o.shape.length&&(o=tT(o,1)),o}))}(n,r,t)},n.interpretAxes=function(e,t){return Array.isArray(this.axes)?this.axes:[pB(this.axes,e.length),pB(this.axes,t.length)]},n.computeOutputShape=function(e){Hv(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),(function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."}));var t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new qO("Dot layer does not support tensors of 4D or higher rank yet.");var r=this.interpretAxes(t,n);t.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);var a=t.concat(n);return 1===a.length&&a.push(1),a},n.computeMask=function(e,t){return null},n.getConfig=function(){var t={axes:this.axes,normalize:this.normalize},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(aB);hB.className="Dot",dR(hB);var dB=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n.stddev=t.stddev,n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return e},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={stddev:this.stddev};return Object.assign(n,t),n},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r=SM(e);return eM((function(){return oI(KD(r.shape,0,n.stddev),r)}),(function(){return r}),t.training||!1)}))},t}(zM);dB.className="GaussianNoise",dR(dB);var fB=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n.rate=t.rate,n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return e},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={rate:this.rate};return Object.assign(n,t),n},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t);var r=SM(e);if(n.rate>0&&n.rate<1){return eM((function(){var e=Math.sqrt(n.rate/(1-n.rate));return lI(r,KD(r.shape,1,e))}),(function(){return r}),t.training||!1)}return r}))},t}(zM);fB.className="GaussianDropout",dR(fB);var mB=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n.rate=t.rate,n.noiseShape=t.noiseShape,n}Cv(t,e);var n=t.prototype;return n._getNoiseShape=function(e){return this.noiseShape||SM(e).shape},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={rate:this.rate};return Object.assign(n,t),n},n.call=function(e,t){var n=this;return eI((function(){if(n.rate<1&&n.rate>0){var r=n._getNoiseShape(e);return eM((function(){var t=SM(e),a=-1.7580993408473766,i=uT(OC(r),n.rate);i=BD(i,"float32");var o=Math.pow((1-n.rate)*(1+n.rate*Math.pow(a,2)),-.5),s=-o*a*n.rate,u=oI(lI(t,i),lI(oI(i,-1),a));return oI(lI(u,o),s)}),(function(){return SM(e)}),t.training||!1)}return e}))},t}(zM);function vB(e,t,n,r,a,i){var o;if(void 0===i&&(i=.001),2===e.rank)o=YI(e,t,n,r,a,i);else if(3===e.rank)o=JI(e,t,n,r,a,i);else{if(4!==e.rank)throw new qO("batchNormalization is not implemented for array of rank "+e.rank+" yet");o=ZI(e,t,n,r,a,i)}return o}function gB(e,t,n,r,a){return void 0===a&&(a=.001),Yv(r.slice().sort(),zD(0,e.rank-1))?function(e,t,n,r,a){return void 0===a&&(a=.001),eI((function(){var i=KT(e,r),o=i.mean,s=i.variance;return[vB(e,o,s,n,t,a),o,s]}))}(e,t,n,r,a):function(e,t,n,r,a){return void 0===a&&(a=.001),eI((function(){for(var i,o=KT(e,r),s=o.mean,u=o.variance,l=[],c=Lv(zD(0,e.rank));!(i=c()).done;){var p=i.value;-1!==r.indexOf(p)?l.push(1):l.push(e.shape[p])}var h=PI(s,l),d=PI(u,l),f=null==t?null:PI(t,l),m=null==n?null:PI(n,l);return[vB(e,h,d,m,f,a),s,u]}))}(e,t,n,r,a)}mB.className="AlphaDropout",dR(mB);var yB=function(e){function t(t){var n;return null==t&&(t={}),(n=e.call(this,t)||this).supportsMasking=!0,n.axis=null==t.axis?-1:t.axis,n.momentum=null==t.momentum?.99:t.momentum,n.epsilon=null==t.epsilon?.001:t.epsilon,n.center=null==t.center||t.center,n.scale=null==t.scale||t.scale,n.betaInitializer=kM(t.betaInitializer||"zeros"),n.gammaInitializer=kM(t.gammaInitializer||"ones"),n.movingMeanInitializer=kM(t.movingMeanInitializer||"zeros"),n.movingVarianceInitializer=kM(t.movingVarianceInitializer||"ones"),n.betaConstraint=rL(t.betaConstraint),n.gammaConstraint=rL(t.gammaConstraint),n.betaRegularizer=iP(t.betaRegularizer),n.gammaRegularizer=iP(t.gammaRegularizer),n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t;e=TM(e);var n=this.axis>=0?this.axis:this.axis+e.length,r=e[n];if(null==r)throw new HO("Axis "+n+" of input tensor should have a defined dimension but the layer received an input with shape "+JSON.stringify(e)+".");this.inputSpec=[new FM({ndim:e.length,axes:(t={},t[n]=r,t)})];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(e,t){var n=this;return eI((function(){var r=null!=t.training&&t.training,a=SM(e),i=a.shape,o=i.length,s=zD(0,o),u=n.axis>=0?n.axis:n.axis+o;s.splice(u,1);var l=YO(1,o);l[u]=i[u];var c=s.slice();c.sort();var p=!Yv(c,zD(0,o).slice(0,o-1));if(!r)return function(){if(p){var e=PI(n.movingMean.read(),l),t=PI(n.movingVariance.read(),l),r=n.center?PI(n.beta.read(),l):null,i=n.scale?PI(n.gamma.read(),l):null;return vB(a,e,t,r,i,n.epsilon)}return vB(a,n.movingMean.read(),n.movingVariance.read(),null==n.beta?null:n.beta.read(),null==n.gamma?null:n.gamma.read(),n.epsilon)}();var h=gB(a,n.gamma.read(),n.beta.read(),s,n.epsilon),d=h[0],f=h[1],m=h[2],v=function(e,t,n){eI((function(){var r=1-n,a=e.read(),i=lI(TT(a,t),r);e.write(TT(a,i))}))};return v(n.movingMean,f,n.momentum),v(n.movingVariance,m,n.momentum),d}))},n.getConfig=function(){var t={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:wM(this.betaInitializer),gammaInitializer:wM(this.gammaInitializer),movingMeanInitializer:wM(this.movingMeanInitializer),movingVarianceInitializer:wM(this.movingVarianceInitializer),betaRegularizer:rP(this.betaRegularizer),gammaRegularizer:rP(this.gammaRegularizer),betaConstraint:tL(this.betaConstraint),gammaConstraint:tL(this.gammaConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);yB.className="BatchNormalization",dR(yB);var bB=function(e){function t(t){var n;if(null==t&&(t={}),(n=e.call(this,t)||this).axis=null==t.axis?-1:t.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=Lv(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==t.epsilon?.001:t.epsilon,n.center=null==t.center||t.center,n.scale=null==t.scale||t.scale,n.betaInitializer=kM(t.betaInitializer||"zeros"),n.gammaInitializer=kM(t.gammaInitializer||"ones"),n.betaRegularizer=iP(t.betaRegularizer),n.gammaRegularizer=iP(t.gammaRegularizer),n.supportsMasking=!0,n}Cv(t,e);var n=t.prototype;return n.build=function(e){var t=(e=TM(e)).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]+=t);for(var r,a=Lv(this.axis);!(r=a()).done;){var i=r.value;if(i<0||i>=t)throw new Error("Invalid axis: "+i)}if(this.axis.length!==sD(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);var o=this.axis.map((function(t){return e[t]}));this.scale?this.gamma=this.addWeight("gamma",o,"float32",this.gammaInitializer,this.gammaRegularizer,true):this.gamma=null,this.center?this.beta=this.addWeight("beta",o,"float32",this.betaInitializer,this.betaRegularizer,true):this.beta=null,this.built=!0},n.call=function(e,t){var n=this,r=SM(e),a=r.shape,i=a.length;return eI((function(){for(var e,t=KT(r,n.axis,!0),o=t.mean,s=t.variance,u=YO(1,i),l=Lv(n.axis);!(e=l()).done;){var c=e.value;u[c]=a[c]}for(var p=function(e){return null!=e&&e.shape.length!==i?PI(e,u):e},h=n.scale?p(n.gamma.read()):null,d=n.center?p(n.beta.read()):null,f=[],m=[],v=0;v<i;++v)-1!==n.axis.indexOf(v)?(f.push(a[v]),m.push(1)):(f.push(1),m.push(a[v]));return o=rT(o,f),s=rT(s,f),null!=h&&(h=rT(h,m)),null!=d&&(d=rT(d,m)),vB(r,o,s,d,h,n.epsilon)}))},n.getConfig=function(){var t={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:wM(this.betaInitializer),gammaInitializer:wM(this.gammaInitializer),betaRegularizer:rP(this.betaRegularizer),gammaRegularizer:rP(this.gammaRegularizer)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);bB.className="LayerNormalization",dR(bB);var xB=function(e){function t(t){var n;if(null==t&&(t={}),(n=e.call(this,t)||this).dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,null==t.padding)n.padding=[[1,1],[1,1]];else if("number"==typeof t.padding)n.padding=[[t.padding,t.padding],[t.padding,t.padding]];else{if(t.padding=t.padding,2!==t.padding.length)throw new HO("ZeroPadding2D expects padding to be a length-2 array, but received a length-"+t.padding.length+" array.");var r,a;if("number"==typeof t.padding[0])r=[t.padding[0],t.padding[0]],a=[t.padding[1],t.padding[1]];else{if(t.padding=t.padding,2!==t.padding[0].length)throw new HO("ZeroPadding2D expects height padding to be a length-2 array, but received a length-"+t.padding[0].length+" array.");if(r=t.padding[0],2!==t.padding[1].length)throw new HO("ZeroPadding2D expects width padding to be a length-2 array, but received a length-"+t.padding[1].length+" array.");a=t.padding[1]}n.padding=[r,a]}return n.inputSpec=[new FM({ndim:4})],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){var t,n;return e=TM(e),"channelsFirst"===this.dataFormat?(t=null!=e[2]&&e[2]>=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])},n.call=function(e,t){var n=this;return eI((function(){return t=SM(e),r=n.padding,a=n.dataFormat,eI((function(){if(4!==t.rank)throw new HO("temporalPadding expects input tensor to be 4-D, but received a "+t.rank+"-D tensor.");if(null==r&&(r=[[1,1],[1,1]]),2!==r.length||2!==r[0].length||2!==r[1].length)throw new HO("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 HO("Unknown data format: "+a+". Supported data formats are 'channelsLast' and 'channelsFirst.");var e;return e="channelsFirst"===a?[[0,0],[0,0],r[0],r[1]]:[[0,0],r[0],r[1],[0,0]],eC(t,e)}));var t,r,a}))},n.getConfig=function(){var t={padding:this.padding,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM);function wB(e,t,n,r,a,i){return eI((function(){var o;ID(a),TD(i),SD(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=mP(e,a);var s="same"===r?"same":"valid";return o="max"===i?LT(e,t,n,s):BI(e,t,n,s),"channelsFirst"===a&&(o=PE(o,[0,3,1,2])),o}))}function kB(e,t,n,r,a,i){return eI((function(){var o;ID(a),TD(i),SD(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=vP(e,a);var s="same"===r?"same":"valid";return o="max"===i?zT(e,t,n,s):WI(e,t,n,s),"channelsFirst"===a&&(o=PE(o,[0,4,1,2,3])),o}))}xB.className="ZeroPadding2D",dR(xB);var NB=function(e){function t(t){var n;if(null==t.poolSize&&(t.poolSize=2),n=e.call(this,t)||this,"number"==typeof t.poolSize)n.poolSize=[t.poolSize];else{if(!Array.isArray(t.poolSize)||1!==t.poolSize.length||"number"!=typeof t.poolSize[0])throw new HO("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(t.poolSize));n.poolSize=t.poolSize}if(pD(n.poolSize,"poolSize"),null==t.strides)n.strides=n.poolSize;else if("number"==typeof t.strides)n.strides=[t.strides];else{if(!Array.isArray(t.strides)||1!==t.strides.length||"number"!=typeof t.strides[0])throw new HO("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(t.strides));n.strides=t.strides}return pD(n.strides,"strides"),n.padding=null==t.padding?"valid":t.padding,SD(n.padding),n.inputSpec=[new FM({ndim:3})],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){var t=dP((e=TM(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]},n.call=function(e,t){var n=this;return eI((function(){n.invokeCallHook(e,t),e=WD(SM(e),2);var r=n.poolingFunction(SM(e),[n.poolSize[0],1],[n.strides[0],1],n.padding,"channelsLast");return cE(r,[2])}))},n.getConfig=function(){var t={poolSize:this.poolSize,padding:this.padding,strides:this.strides},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM),IB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return ID(a),SD(r),wB(e,t,n,r,a,"max")},t}(NB);IB.className="MaxPooling1D",dR(IB);var SB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return ID(a),SD(r),wB(e,t,n,r,a,"avg")},t}(NB);SB.className="AveragePooling1D",dR(SB);var TB=function(e){function t(t){var n;if(null==t.poolSize&&(t.poolSize=[2,2]),(n=e.call(this,t)||this).poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize],null==t.strides)n.strides=n.poolSize;else if(Array.isArray(t.strides)){if(2!==t.strides.length)throw new HO("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length "+t.strides.length+".");n.strides=t.strides}else n.strides=[t.strides,t.strides];return pD(n.poolSize,"poolSize"),pD(n.strides,"strides"),n.padding=null==t.padding?"valid":t.padding,n.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,ID(n.dataFormat),SD(n.padding),n.inputSpec=[new FM({ndim:4})],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){e=TM(e);var t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=dP(t,this.poolSize[0],this.padding,this.strides[0]),n=dP(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]},n.call=function(e,t){var n=this;return eI((function(){return n.invokeCallHook(e,t),n.poolingFunction(SM(e),n.poolSize,n.strides,n.padding,n.dataFormat)}))},n.getConfig=function(){var t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM),CB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return ID(a),SD(r),wB(e,t,n,r,a,"max")},t}(TB);CB.className="MaxPooling2D",dR(CB);var EB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return ID(a),SD(r),wB(e,t,n,r,a,"avg")},t}(TB);EB.className="AveragePooling2D",dR(EB);var AB=function(e){function t(t){var n;if(null==t.poolSize&&(t.poolSize=[2,2,2]),(n=e.call(this,t)||this).poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize,t.poolSize],null==t.strides)n.strides=n.poolSize;else if(Array.isArray(t.strides)){if(3!==t.strides.length)throw new HO("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length "+t.strides.length+".");n.strides=t.strides}else n.strides=[t.strides,t.strides,t.strides];return pD(n.poolSize,"poolSize"),pD(n.strides,"strides"),n.padding=null==t.padding?"valid":t.padding,n.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,ID(n.dataFormat),SD(n.padding),n.inputSpec=[new FM({ndim:5})],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){e=TM(e);var t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[4]:e[3];return t=dP(t,this.poolSize[0],this.padding,this.strides[0]),n=dP(n,this.poolSize[1],this.padding,this.strides[1]),r=dP(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n,r]:[e[0],t,n,r,e[4]]},n.call=function(e,t){var n=this;return eI((function(){return n.invokeCallHook(e,t),n.poolingFunction(SM(e),n.poolSize,n.strides,n.padding,n.dataFormat)}))},n.getConfig=function(){var t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM),RB=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return ID(a),SD(r),kB(e,t,n,r,a,"max")},t}(AB);RB.className="MaxPooling3D",dR(RB);var _B=function(e){function t(t){return e.call(this,t)||this}return Cv(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return ID(a),SD(r),kB(e,t,n,r,a,"avg")},t}(AB);_B.className="AveragePooling3D",dR(_B);var FB=function(e){function t(t){var n;return(n=e.call(this,t)||this).inputSpec=[new FM({ndim:3})],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return[e[0],e[2]]},n.call=function(e,t){throw new qO},t}(zM),OB=function(e){function t(t){return e.call(this,t||{})||this}return Cv(t,e),t.prototype.call=function(e,t){return eI((function(){var t=SM(e);return WT(t,1)}))},t}(FB);OB.className="GlobalAveragePooling1D",dR(OB);var DB=function(e){function t(t){return e.call(this,t||{})||this}return Cv(t,e),t.prototype.call=function(e,t){return eI((function(){var t=SM(e);return jS(t,1)}))},t}(FB);DB.className="GlobalMaxPooling1D",dR(DB);var MB=function(e){function t(t){var n;return(n=e.call(this,t)||this).dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,ID(n.dataFormat),n.inputSpec=[new FM({ndim:4})],n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]},n.call=function(e,t){throw new qO},n.getConfig=function(){var t={dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(zM),LB=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.call=function(e,t){var n=this;return eI((function(){var t=SM(e);return"channelsLast"===n.dataFormat?WT(t,[1,2]):WT(t,[2,3])}))},t}(MB);LB.className="GlobalAveragePooling2D",dR(LB);var zB=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.call=function(e,t){var n=this;return eI((function(){var t=SM(e);return"channelsLast"===n.dataFormat?jS(t,[1,2]):jS(t,[2,3])}))},t}(MB);zB.className="GlobalMaxPooling2D",dR(zB);var PB=function(e){function t(t){var n;return(n=e.call(this,t)||this).layer=t.layer,n}Cv(t,e);var n=t.prototype;return n.build=function(e){this.built=!0},n.getWeights=function(){return this.layer.getWeights()},n.setWeights=function(e){this.layer.setWeights(e)},n.getConfig=function(){var t={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},n.setFastWeightInitDuringBuild=function(t){e.prototype.setFastWeightInitDuringBuild.call(this,t),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(t)},t.fromConfig=function(e,t,n){void 0===n&&(n={});var r=yL(t.layer,n);delete t.layer;var a={layer:r};return Object.assign(a,t),new e(a)},Tv(t,[{key:"trainable",get:function(){return null!=this.layer&&this.layer.trainable},set:function(e){null!=this.layer&&(this.layer.trainable=e)}},{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}}]),t}(zM),BB=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n}Cv(t,e);var n=t.prototype;return n.build=function(t){if((t=TM(t)).length<3)throw new HO("TimeDistributed layer expects an input shape >= 3D, but received input shape "+JSON.stringify(t));this.inputSpec=[{shape:t}];var n=[t[0]].concat(t.slice(2));this.layer.built||(this.layer.build(n),this.layer.built=!0),e.prototype.build.call(this,t)},n.computeOutputShape=function(e){var t=[(e=TM(e))[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))},n.call=function(e,t){var n=this;return eI((function(){return OP((function(e,r){return[SM(n.layer.call(e,t)),[]]}),e=SM(e),[],!1,null,null,!1,!0)[1]}))},t}(PB);BB.className="TimeDistributed",dR(BB);var WB=function(e){function t(t){var n;n=e.call(this,t)||this;var r=t.layer.getConfig(),a={};a.className=t.layer.getClassName(),a.config=r,n.forwardLayer=yL(a),r.goBackwards=!0!==r.goBackwards;var i,o={};if(o.className=t.layer.getClassName(),o.config=r,n.backwardLayer=yL(o),n.forwardLayer.name="forward_"+n.forwardLayer.name,n.backwardLayer.name="backward_"+n.backwardLayer.name,n.mergeMode=void 0===t.mergeMode?"concat":t.mergeMode,i=n.mergeMode,lD(kD,"BidirectionalMergeMode",i),t.weights)throw new qO("weights support is not implemented for Bidirectional layer yet.");return n._stateful=t.layer.stateful,n.returnSequences=t.layer.returnSequences,n.returnState=t.layer.returnState,n.supportsMasking=!0,n._trainable=!0,n.inputSpec=t.layer.inputSpec,n.numConstants=null,n}Cv(t,e);var n=t.prototype;return n.getWeights=function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())},n.setWeights=function(e){var t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))},n.computeOutputShape=function(e){var t,n,r,a=this.forwardLayer.computeOutputShape(e);return Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),this.returnState?(r=a.slice(1),t=a[0]):t=a[0],"concat"===this.mergeMode?(t[t.length-1]*=2,n=[t]):n=null==this.mergeMode?[t,t.slice()]:[t],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[t].concat(r).concat(r.slice()):QO(n)},n.apply=function(t,n){var r=null==n?null:n.initialState,a=null==n?null:n.constants;null==n&&(n={});var i=FP(t,r,a,this.numConstants);if(t=i.inputs,r=i.initialState,a=i.constants,Array.isArray(t)&&(r=t.slice(1),t=t[0]),(null==r||0===r.length)&&null==a)return e.prototype.apply.call(this,t,n);var o=[],s=[];if(null!=r){var u=r.length;if(u%2>0)throw new HO("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 l=r.map((function(e){return new FM({shape:e.shape})}));this.forwardLayer.stateSpec=l.slice(0,u/2),this.backwardLayer.stateSpec=l.slice(u/2),s.push.apply(s,l)}if(null!=a)throw new qO("Support for constants in Bidirectional layers is not implemented yet.");for(var c=o[0]instanceof OM,p=0,h=o;p<h.length;p++){if(h[p]instanceof OM!==c)throw new HO("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors")}if(c){var d=[t].concat(o),f=this.inputSpec.concat(s),m=this.inputSpec;this.inputSpec=f;var v=e.prototype.apply.call(this,d,n);return this.inputSpec=m,v}return e.prototype.apply.call(this,t,n)},n.call=function(e,t){var n=this;return eI((function(){var r,a,i,o,s=t.initialState;if(null==s)r=n.forwardLayer.call(e,t),a=n.backwardLayer.call(e,t);else{var u=s.slice(0,s.length/2),l=s.slice(s.length/2);r=n.forwardLayer.call(e,Object.assign(t,{initialState:u})),a=n.backwardLayer.call(e,Object.assign(t,{initialState:l}))}return n.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),n.returnSequences&&(a=BC(a,1)),"concat"===n.mergeMode?o=jD([r,a]):"sum"===n.mergeMode?o=oI(r,a):"ave"===n.mergeMode?o=lI(.5,oI(r,a)):"mul"===n.mergeMode?o=lI(r,a):null==n.mergeMode&&(o=[r,a]),n.returnState?null==n.mergeMode?o.concat(i):[o].concat(i):o}))},n.resetStates=function(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()},n.build=function(e){var t=this;ED(this.forwardLayer.name,(function(){t.forwardLayer.build(e)})),ED(this.backwardLayer.name,(function(){t.backwardLayer.build(e)})),this.built=!0},n.computeMask=function(e,t){var n;if(Array.isArray(t)&&(t=t[0]),n=this.returnSequences?null==this.mergeMode?[t,t]:t:null==this.mergeMode?[null,null]:null,this.returnState){var r=this.forwardLayer.states.map((function(e){return null}));return Array.isArray(n)?n.concat(r).concat(r):[n].concat(r).concat(r)}return n},n.setFastWeightInitDuringBuild=function(t){e.prototype.setFastWeightInitDuringBuild.call(this,t),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(t),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(t)},n.getConfig=function(){var t={mergeMode:this.mergeMode},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t.fromConfig=function(e,t){var n=yL(t.layer);if(delete t.layer,null!=t.numConstants)throw new qO("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");var r=t;return r.layer=n,new e(r)},Tv(t,[{key:"trainable",get:function(){return this._trainable},set:function(e){this._trainable=e,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)}},{key:"trainableWeights",get:function(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}},{key:"nonTrainableWeights",get:function(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}}]),t}(PB);WB.className="Bidirectional",dR(WB);var VB=function(e){function t(t){var n;return(n=e.call(this,t)||this).scale=t.scale,t.offset?n.offset=t.offset:n.offset=0,n}Cv(t,e);var n=t.prototype;return n.getConfig=function(){var t={scale:this.scale,offset:this.offset},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},n.call=function(e,t){var n=this;return eI((function(){return"float32"!==(e=SM(e)).dtype&&(e=BD(e,"float32")),oI(lI(e,n.scale),n.offset)}))},t}(zM);VB.className="Rescaling",dR(VB);var UB=oR.resizeBilinear,GB=oR.cropAndResize,jB=function(e){function t(t){var n;return(n=e.call(this,t)||this).height=t.height,n.width=t.width,n}Cv(t,e);var n=t.prototype;return n.centerCrop=function(e,t,n,r,a,i,o,s){return eI((function(){var u,l=!1,c=[t/i,n/o,(r+t)/i,(a+n)/o],p=[];3===e.rank?(l=!0,u=pE([e])):u=e;for(var h=0;h<u.shape[0];h++)p.push(c);var d=Gk(p,[p.length,4]),f=DC(0,p.length,1,"int32"),m=GB(u,d,f,[r,a],"nearest");return BD(l?SM(RE(m)):m,s)}))},n.upsize=function(e,t,n,r){return eI((function(){return BD(UB(e,[t,n]),r)}))},n.call=function(e,t){var n=this;return eI((function(){var t=SM(e),r=t.dtype,a=t.shape,i=a[a.length-3],o=a[a.length-2],s=0;i!==n.height&&(s=Math.floor((i-n.height)/2));var u=0;return o!==n.width&&0===(u=Math.floor((o-n.width)/2))&&(u=1),s>=0&&u>=0?n.centerCrop(t,s,u,n.height,n.width,i,o,r):n.upsize(e,n.height,n.width,r)}))},n.getConfig=function(){var t={height:this.height,width:this.width},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},n.computeOutputShape=function(e){var t=(e=TM(e)).length-3,n=e.length-2;return e[t]=this.height,e[n]=this.width,e},t}(zM);jB.className="CenterCrop",dR(jB);var HB=function(e){function t(t){var n;return(n=e.call(this,t)||this).numTokens=t.numTokens,t.outputMode?n.outputMode=t.outputMode:n.outputMode="multiHot",n}Cv(t,e);var n=t.prototype;return n.getConfig=function(){var t={numTokens:this.numTokens,outputMode:this.outputMode},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},n.computeOutputShape=function(e){return null==(e=TM(e))?[this.numTokens]:"oneHot"===this.outputMode&&1!==e[e.length-1]?(e.push(this.numTokens),e):(e[e.length-1]=this.numTokens,e)},n.call=function(e,t){var n=this;return eI((function(){var r;if("int32"!==(e=SM(e)).dtype&&(e=BD(e,"int32")),void 0!==t.countWeights){if("count"!==n.outputMode)throw new HO("countWeights is not used when outputMode !== count.\n Received countWeights="+t.countWeights);r=SM(t.countWeights)}var a=jS(e),i=HS(e),o=sT(n.numTokens,a).bufferSync().get(0),s=uT(i,0).bufferSync().get(0);if(!o||!s)throw new HO("Input values must be between 0 < values <= numTokens with numTokens="+n.numTokens);return function(e,t,n,r){var a=SM(e);if("int32"!==a.dtype&&(a=BD(a,"int32")),"int"===t)return a;var i=a.shape;if(0===a.rank&&(a=tT(a,-1)),"oneHot"===t&&1!==a.shape[a.shape.length-1]&&(a=tT(a,-1)),a.rank>2)throw new HO("When outputMode is not int, maximum output rank is 2 Received outputMode "+t+" and input shape "+i+" which would result in output rank "+a.rank+".");var o,s=["multiHot","oneHot"].includes(t);if(o=bS(a,void 0!==r&&"count"===t?r:[],n,s),"tfIdf"!==t)return o;if(r)return lI(o,r);throw new HO("When outputMode is 'tfIdf', weights must be provided.")}(e,n.outputMode,n.numTokens,r)}))},t}(zM);HB.className="CategoryEncoding",dR(HB);var qB=new Set(["bilinear","nearest"]),KB=function(e){function t(t){var n;if((n=e.call(this,t)||this).height=t.height,n.width=t.width,t.interpolation){if(!qB.has(t.interpolation))throw new HO("Invalid interpolation parameter: "+t.interpolation+" is not implemented");n.interpolation=t.interpolation}else n.interpolation="bilinear";return n.cropToAspectRatio=Boolean(t.cropToAspectRatio),n}Cv(t,e);var n=t.prototype;return n.computeOutputShape=function(e){var t=(e=TM(e))[2];return[this.height,this.width,t]},n.getConfig=function(){var t={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},n.call=function(e,t){var n=this;return eI((function(){var t=[n.height,n.width];if("bilinear"===n.interpolation)return oR.resizeBilinear(e,t,!n.cropToAspectRatio);if("nearest"===n.interpolation)return oR.resizeNearestNeighbor(e,t,!n.cropToAspectRatio);throw new Error("Interpolation is "+n.interpolation+" but only "+[].concat(qB)+" are supported")}))},t}(zM);function XB(e){return new SB(e)}function YB(e){return new EB(e)}function JB(e){return new _B(e)}function ZB(e){return new DB(e)}function QB(e){return new zB(e)}function $B(e){return new IB(e)}function eW(e){return new CB(e)}KB.className="Resizing",dR(KB);var tW={__proto__:null,inputLayer:function(e){return new BM(e)},elu:function(e){return new lP(e)},reLU:function(e){return new oP(e)},leakyReLU:function(e){return new sP(e)},prelu:function(e){return new uP(e)},softmax:function(e){return new pP(e)},thresholdedReLU:function(e){return new cP(e)},conv1d:function(e){return new EP(e)},conv2d:function(e){return new kP(e)},conv2dTranspose:function(e){return new IP(e)},conv3d:function(e){return new NP(e)},conv3dTranspose:function(e){return new SP(e)},separableConv2d:function(e){return new CP(e)},cropping2D:function(e){return new AP(e)},upSampling2d:function(e){return new RP(e)},depthwiseConv2d:function(e){return new _P(e)},activation:function(e){return new QP(e)},dense:function(e){return new JP(e)},dropout:function(e){return new XP(e)},spatialDropout1d:function(e){return new YP(e)},flatten:function(e){return new ZP(e)},repeatVector:function(e){return new $P(e)},reshape:function(e){return new eB(e)},permute:function(e){return new tB(e)},embedding:function(e){return new rB(e)},add:function(e){return new iB(e)},average:function(e){return new sB(e)},concatenate:function(e){return new cB(e)},maximum:function(e){return new uB(e)},minimum:function(e){return new lB(e)},multiply:function(e){return new oB(e)},dot:function(e){return new hB(e)},batchNormalization:function(e){return new yB(e)},layerNormalization:function(e){return new bB(e)},zeroPadding2d:function(e){return new xB(e)},averagePooling1d:XB,avgPool1d:function(e){return XB(e)},avgPooling1d:function(e){return XB(e)},averagePooling2d:YB,avgPool2d:function(e){return YB(e)},avgPooling2d:function(e){return YB(e)},averagePooling3d:JB,avgPool3d:function(e){return JB(e)},avgPooling3d:function(e){return JB(e)},globalAveragePooling1d:function(e){return new OB(e)},globalAveragePooling2d:function(e){return new LB(e)},globalMaxPooling1d:ZB,globalMaxPooling2d:QB,maxPooling1d:$B,maxPooling2d:eW,maxPooling3d:function(e){return new RB(e)},gru:function(e){return new BP(e)},gruCell:function(e){return new PP(e)},lstm:function(e){return new VP(e)},lstmCell:function(e){return new WP(e)},simpleRNN:function(e){return new zP(e)},simpleRNNCell:function(e){return new LP(e)},convLstm2d:function(e){return new KP(e)},convLstm2dCell:function(e){return new qP(e)},rnn:function(e){return new DP(e)},stackedRNNCells:function(e){return new UP(e)},bidirectional:function(e){return new WB(e)},timeDistributed:function(e){return new BB(e)},globalMaxPool1d:ZB,globalMaxPool2d:QB,maxPool1d:$B,maxPool2d:eW,Layer:zM,RNN:DP,RNNCell:MP,input:Dz,gaussianNoise:function(e){return new dB(e)},gaussianDropout:function(e){return new fB(e)},alphaDropout:function(e){return new mB(e)},masking:function(e){return new nB(e)},rescaling:function(e){return new VB(e)},centerCrop:function(e){return new jB(e)},resizing:function(e){return new KB(e)},categoryEncoding:function(e){return new HB(e)}};var nW={__proto__:null,binaryAccuracy:function(e,t){return _L(e,t)},binaryCrossentropy:function(e,t){return LL(e,t)},sparseCategoricalAccuracy:function(e,t){return zL(e,t)},categoricalAccuracy:function(e,t){return FL(e,t)},categoricalCrossentropy:function(e,t){return PL(e,t)},precision:function(e,t){return DL(e,t)},recall:function(e,t){return ML(e,t)},cosineProximity:function(e,t){return EL(e,t)},meanAbsoluteError:function(e,t){return wL(e,t)},meanAbsolutePercentageError:function(e,t){return kL(e,t)},MAPE:function(e,t){return kL(e,t)},mape:function(e,t){return kL(e,t)},meanSquaredError:function(e,t){return xL(e,t)},MSE:function(e,t){return xL(e,t)},mse:function(e,t){return xL(e,t)}},rW={__proto__:null,modelFromJSON:function(e,t){return Ez.apply(this,arguments)}};var aW={__proto__:null,l1l2:function(e){return new tP(e)},l1:function(e){return $z(t=e),new tP({l1:null!=t?t.l1:null,l2:0});var t},l2:function(e){return $z(t=e),new tP({l2:null!=t?t.l2:null,l1:0});var t}},iW=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).model=null,t}return Cv(t,e),t.prototype.setModel=function(e){if(!(e instanceof Tz))throw new Error("model must be a LayersModel, not some other Container");this.model=e},t}(cL);function oW(e,t){return e<t}function sW(e,t){return e>t}var uW=function(e){function t(t){var n;if(n=e.call(this)||this,null==t&&(t={}),t.restoreBestWeights)throw new qO("restoreBestWeights = True is not implemented in EarlyStopping yet.");return n.monitor=t.monitor||"val_loss",n.minDelta=Math.abs(t.minDelta||0),n.patience=t.patience||0,n.verbose=t.verbose||0,n.mode=t.mode||"auto",n.baseline=t.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=oW:"max"===n.mode||-1!==n.monitor.indexOf("acc")?n.monitorFunc=sW:n.monitorFunc=oW,n.monitorFunc===oW&&(n.minDelta*=-1),n}Cv(t,e);var n=t.prototype;return n.onTrainBegin=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===oW?1/0:-1/0;case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.onEpochEnd=function(){var e=Iv(kv().mark((function e(t,n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,sL(n);case 2:if(null!=(r=this.getMonitorValue(n))){e.next=5;break}return e.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=t,this.model.stopTraining=!0));case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onTrainEnd=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.stoppedEpoch>0&&this.verbose&&console.log("Epoch "+this.stoppedEpoch+": early stopping.");case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getMonitorValue=function(e){null==e&&(e={});var t=e[this.monitor];return null==t&&console.warn("Metric for EarlyStopping "+this.monitor+" is not available. Available metrics are: "+Object.keys(e)),t},t}(iW);var lW,cW,pW={earlyStopping:function(e){return new uW(e)}};Fg().registerFlag("KEEP_INTERMEDIATE_TENSORS",(function(){return!1}),(function(e){e&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")})),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(lW||(lW={})),function(e){!function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"}(e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))}(cW||(cW={}));var hW={};function dW(e){return hW[e]}function fW(e,t,n,r,a){var i=t.inputParams[e];if(i&&void 0!==i.inputIndexStart){var o=i.inputIndexStart,s=0===i.inputIndexEnd?void 0:void 0===i.inputIndexEnd?o+1:i.inputIndexEnd,u=o<0?t.inputNames.length+o:o;if("tensor"===i.type)return mW(t.inputNames[u],n,r,a);if("tensors"===i.type){var l=t.inputs.slice(o,s),c=t.inputNames.slice(o,s).filter((function(e,t){var n;return"NoOp"!==(null===(n=l[t])||void 0===n?void 0:n.op)}));return c.map((function(e){return mW(e,n,r,a)}))}var p=mW(t.inputNames[u],n,r,a),h=p.dataSync();return"number"===i.type?h[0]:yg(p.shape,h)}var d=t.attrParams[e];return d&&d.value}function mW(e,t,n,r){var a=bW(e,n),i=a[0],o=a[1];if(null!=r){var s=r.getHashTableHandleByName(i);if(null!=s)return s}var u=n.currentContextIds.find((function(e){return!!t[yW(i,e)]}));return void 0!==u?t[yW(i,u)][o]:void 0}function vW(e,t,n){return t[yW(e,n.currentContextId)]}function gW(e,t){var n=bW(e,t),r=n[0],a=n[1],i=n[2];return[yW(r,t&&t.currentContextId),a,i]}function yW(e,t){return t?e+"-"+t:e}function bW(e,t){if(""===e)return["",0,void 0];var n=null!=t&&null!=t.parseNodeNameCache;if(n){var r=t.parseNodeNameCache.get(e);if(null!=r)return r}var a,i=e.split(":");if(1===i.length)a=[e,0,void 0];else{var o=i[0],s=3===i.length?i[1]:void 0;a=[o,Number(i[i.length-1]),s]}return n&&t.parseNodeNameCache.set(e,a),a}function xW(e,t,n){var r=fW("pad",e,t,n);if("explicit"===r){r=fW("explicitPaddings",e,t,n);for(var a=[[0,0],[0,0],[0,0],[0,0]],i=0;i<4;i++)a[i][0]=r[2*i],a[i][1]=r[2*i+1];return a}return r}function wW(e){return e.kept?e:YN(e)}var kW={__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},{tfName:"data_format",name:"dataFormat",type:"string",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"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",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:"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}]}]},NW={__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"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{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}]},{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}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsFinite",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsInf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},IW={__proto__:null,json:[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}]},SW={__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:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",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:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}]},TW={__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"}]},{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:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{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:"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"}]}]},CW={__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:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},EW={__proto__:null,json:[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}]},AW={__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"}]}]},RW={__proto__:null,json:[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}]},_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:"half_pixel_centers",name:"halfPixelCenters",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:"half_pixel_centers",name:"halfPixelCenters",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"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}]},FW={__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}]}]},OW={__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:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{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}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"MatrixBandPart",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"numLower",type:"tensor"},{start:1,name:"numUpper",type:"tensor"}]}]},DW={__proto__:null,json:[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{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}]}]},MW={__proto__:null,json:[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}]},LW={__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}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{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[]"}]},{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}]},{tfOpName:"TensorScatterUpdate",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"values",type:"tensor"}]}]},zW={__proto__:null,json:[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}]},PW={__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}]}]},BW={__proto__:null,json:[{tfOpName:"StaticRegexReplace",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"pattern",name:"pattern",type:"string"},{tfName:"rewrite",name:"rewrite",type:"string"},{tfName:"replace_global",name:"replaceGlobal",type:"bool"}]},{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}]},WW={__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:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}]},VW=function(){function e(){var e,t=[kW,NW,IW,SW,TW,CW,EW,AW,RW,_W,FW,OW,DW,MW,LW,zW,PW,BW,WW],n=(e=[]).concat.apply(e,t.map((function(e){return e.json})));this.opMappers=n.reduce((function(e,t){return e[t.tfOpName]=t,e}),{})}var t=e.prototype;return t.transformGraph=function(e,t){var n=this;void 0===t&&(t={});var r=e.node,a=[],i=[],o=[],s=r.reduce((function(e,t){return e[t.name]=n.mapNode(t),t.op.startsWith("Placeholder")?a.push(e[t.name]):"Const"===t.op?i.push(e[t.name]):null!=t.input&&0!==t.input.length||o.push(e[t.name]),e}),{}),u=[],l=[],c={},p={};null!=t&&(c=this.mapSignatureEntries(t.inputs),p=this.mapSignatureEntries(t.outputs));var h=Object.keys(s);h.forEach((function(e){var t=s[e];t.inputNames.forEach((function(e,n){var r=gW(e),a=r[0],i=r[2],o=s[a];if(null!=o.outputs){var u=o.outputs.indexOf(i);if(-1!==u){var l=a+":"+u;t.inputNames[n]=l}}t.inputs.push(o),o.children.push(t)}))})),0===Object.keys(p).length?h.forEach((function(e){var t=s[e];0===t.children.length&&l.push(t)})):Object.keys(p).forEach((function(e){var t=gW(e)[0],n=s[t];null!=n&&(n.signatureKey=p[e],l.push(n))})),Object.keys(c).length>0?Object.keys(c).forEach((function(e){var t=gW(e)[0],n=s[t];n&&(n.signatureKey=c[e],u.push(n))})):u=a;var d={};null!=e.library&&null!=e.library.function&&(d=e.library.function.reduce((function(e,t){return e[t.signature.name]=n.mapFunction(t),e}),{}));var f={nodes:s,inputs:u,outputs:l,weights:i,placeholders:a,signature:t,functions:d};return o.length>0&&(f.initNodes=o),f},t.mapSignatureEntries=function(e){return Object.keys(e||{}).reduce((function(t,n){return t[e[n].name]=n,t}),{})},t.mapNode=function(e){var t=dW(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});var n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((function(e){return e.startsWith("^")?e.slice(1):e})),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce((function(e,t){return e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e}),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce((function(t,n){var r=n.type,a=void 0;switch(n.type){case"string":void 0===(a=GW(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=GW(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":void 0===(a=$W(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=$W(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":void 0===(a=HW(e.attr,n.tfName,n.defaultValue||0))&&n.tfDeprecatedName&&(a=HW(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":void 0===(a=QW(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=QW(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":void 0===(a=jW(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=jW(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":void 0===(a=tV(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=tV(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":void 0===(a=ZW(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=ZW(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":void 0===(a=eV(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=eV(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":void 0===(a=XW(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=XW(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":void 0===(a=YW(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=YW(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":void 0===(a=KW(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=KW(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: "+n.type+" for op: "+e.op)}return t[n.name]={value:a,type:r},t}),{})),n},t.mapFunction=function(e){var t=this,n=e.nodeDef,r=[],a={};null!=n&&(a=n.reduce((function(e,n){return e[n.name]=t.mapNode(n),"Const"===n.op&&r.push(e[n.name]),e}),{}));var i=[],o=[];e.signature.inputArg.forEach((function(e){var t=gW(e.name)[0],n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:qW(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,i.push(n),a[t]=n})),Object.keys(a).forEach((function(e){var t=a[e];t.inputNames.forEach((function(e,n){var r=gW(e),i=r[0],o=r[2],s=a[i];if(null!=s.outputs){var u=s.outputs.indexOf(o);if(-1!==u){var l=i+":"+u;t.inputNames[n]=l}}t.inputs.push(s),s.children.push(t)}))}));var s=e.ret;e.signature.outputArg.forEach((function(e){var t=gW(s[e.name]),n=t[0],r=t[1],i=a[n];null!=i&&(i.defaultOutput=r,o.push(i))}));var u=this.mapArgsToSignature(e);return{nodes:a,inputs:i,outputs:o,weights:r,placeholders:[],signature:u}},t.mapArgsToSignature=function(e){var t=this;return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((function(e,n){return e[n.name]=t.mapArgToTensorInfo(n),e}),{}),outputs:e.signature.outputArg.reduce((function(n,r){return n[r.name]=t.mapArgToTensorInfo(r,e.ret),n}),{})}},t.mapArgToTensorInfo=function(e,t){var n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}},Tv(e,null,[{key:"Instance",get:function(){return this._instance||(this._instance=new this)}}]),e}();function UW(e,t){var n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){var t=Fg().global;if(void 0!==t.atob)return t.atob(e);if("undefined"!=typeof Buffer)return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function GW(e,t,n,r){void 0===r&&(r=!1);var a=e[t];return null!=a?UW(a.s,r):n}function jW(e,t,n){var r=e[t];return r?r.b:n}function HW(e,t,n){var r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function qW(e){switch("string"==typeof e&&(e=lW[e]),e){case lW.DT_FLOAT:case lW.DT_HALF:return"float32";case lW.DT_INT32:case lW.DT_INT64:case lW.DT_INT8:case lW.DT_UINT8:return"int32";case lW.DT_BOOL:return"bool";case lW.DT_DOUBLE:return"float32";case lW.DT_STRING:return"string";default:return null}}function KW(e,t,n){var r=e[t];return r&&r.func?r.func.name:n}function XW(e,t,n){var r=e[t];return r&&r.type?qW(r.type):n}function YW(e,t,n){var r=e[t];return r&&r.list&&r.list.type?r.list.type.map((function(e){return qW(e)})):n}function JW(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((function(e){return"number"==typeof e.size?e.size:parseInt(e.size,10)})):[]}function ZW(e,t,n){var r=e[t];return r&&r.shape?JW(r.shape):n}function QW(e,t,n){var r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((function(e){return"number"==typeof e?e:parseInt(e,10)})):n}function $W(e,t,n,r){void 0===r&&(r=!1);var a=e[t];return a&&a.list&&a.list.s?a.list.s.map((function(e){return UW(e,r)})):n}function eV(e,t,n){var r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((function(e){return JW(e)})):n}function tV(e,t,n){var r=e[t];return r&&r.list&&r.list.b?r.list.b:n}var nV=function(){function e(e,t,n){var r=this;this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((function(e){return r.getInput(e)})),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce((function(e,t){return e[t]=r.getAttr(t),e}),{}))}var t=e.prototype;return t.getInput=function(e){return mW(e,this.tensorMap,this.context)},t.getAttr=function(e,t){var n=this.node.rawAttrs[e];if(null!=n.tensor)return mW(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return HW(this.node.rawAttrs,e,t);if(null!=n.s)return GW(this.node.rawAttrs,e,t);if(null!=n.b)return jW(this.node.rawAttrs,e,t);if(null!=n.shape)return ZW(this.node.rawAttrs,e,t);if(null!=n.type)return XW(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return QW(this.node.rawAttrs,e,t);if(null!=n.list.s)return $W(this.node.rawAttrs,e,t);if(null!=n.list.shape)return eV(this.node.rawAttrs,e,t);if(null!=n.list.b)return tV(this.node.rawAttrs,e,t);if(null!=n.list.type)return YW(this.node.rawAttrs,e,t)}return t},e}(),rV={__proto__:null,abs:cI,acos:pI,acosh:hI,add:oI,addN:dI,all:fI,any:mI,argMax:vI,argMin:gI,asin:yI,asinh:bI,atan:xI,atan2:wI,atanh:kI,avgPool:BI,avgPool3d:WI,basicLSTMCell:qI,batchToSpaceND:KI,batchNorm:XI,batchNorm2d:YI,batchNorm3d:JI,batchNorm4d:ZI,bincount:QI,broadcastArgs:$I,broadcastTo:eS,buffer:KN,cast:XN,ceil:tS,clipByValue:rS,clone:YN,complex:Vk,concat:VI,concat1d:aS,concat2d:iS,concat3d:oS,concat4d:sS,conv1d:lS,conv2d:uS,conv2dTranspose:pS,conv3d:hS,conv3dTranspose:fS,cos:mS,cosh:vS,cumprod:gS,cumsum:yS,denseBincount:bS,depthToSpace:xS,depthwiseConv2d:wS,diag:kS,dilation2d:NS,div:uI,divNoNan:_S,dot:FS,einsum:OS,elu:DS,equal:ES,erf:MS,euclideanNorm:$S,exp:eT,expandDims:tT,expm1:nT,eye:aT,fill:nS,floor:iT,floorDiv:sI,gather:oT,greater:sT,greaterEqual:uT,imag:lT,isFinite:cT,isInf:pT,isNaN:hT,leakyRelu:dT,less:fT,lessEqual:mT,linspace:vT,localResponseNormalization:gT,log:yT,log1p:bT,logSigmoid:ST,logSoftmax:CT,logSumExp:ET,logicalAnd:AT,logicalNot:RT,logicalOr:_T,logicalXor:FT,lowerBound:MT,matMul:UI,max:jS,maxPool:LT,maxPool3d:zT,maxPoolWithArgmax:PT,maximum:BT,mean:WT,meshgrid:GT,min:HS,minimum:jT,mirrorPad:HT,mod:qT,moments:KT,mul:lI,multiRNNCell:XT,multinomial:YT,neg:NT,notEqual:JT,oneHot:ZT,ones:UT,onesLike:QT,outerProduct:$T,pad:eC,pad1d:tC,pad2d:nC,pad3d:rC,pad4d:aC,pool:oC,pow:qS,prelu:sC,print:JN,prod:uC,raggedGather:lC,raggedRange:cC,raggedTensorToTensor:pC,rand:hC,randomGamma:RC,randomNormal:_C,randomStandardNormal:FC,randomUniform:OC,range:DC,real:MC,reciprocal:LC,relu:zC,relu6:PC,reshape:PI,reverse:BC,reverse1d:WC,reverse2d:VC,reverse3d:UC,reverse4d:GC,round:jC,rsqrt:HC,scalar:KS,selu:qC,separableConv2d:KC,setdiff1dAsync:YC,sigmoid:GI,sign:JC,sin:ZC,sinh:QC,slice:jI,slice1d:$C,slice2d:eE,slice3d:tE,slice4d:nE,softmax:rE,softplus:IT,spaceToBatchND:iC,fft:aE,ifft:iE,irfft:oE,rfft:uE,split:sE,sqrt:XS,square:YS,squaredDifference:lE,squeeze:cE,stack:pE,step:hE,stridedSlice:dE,sub:TT,sum:JS,tan:fE,tanh:HI,tensor:Gk,tensor1d:mE,tensor2d:vE,tensor3d:gE,tensor4d:yE,tensor5d:bE,tensor6d:xE,tensorScatterUpdate:SE,tile:rT,topk:TE,truncatedNormal:CE,unique:EE,unsortedSegmentSum:AE,unstack:RE,upperBound:_E,variable:FE,where:AS,whereAsync:ME,zeros:VT,zerosLike:RS,op:Wk,OP_SCOPE_SUFFIX:Bk,booleanMaskAsync:zE,transpose:PE,norm:QS,movingAverage:BE,scatterND:WE,searchSorted:DT,sparseToDense:VE,gatherND:UE,dropout:GE,enclosingPowerOfTwo:jE,cosineWindow:HE,inTopKAsync:KE,image:oR,linalg:sR,losses:uR,spectral:aR,fused:aA,signal:iR,sparse:lR,string:cR};function aV(e,t,n){if(void 0===n&&(n=""),"number"!=typeof e&&"number"!=typeof t){Hv(e.length===t.length,(function(){return n+" Shapes "+e+" and "+t+" must match"}));for(var r=0;r<e.length;r++){var a=e[r],i=t[r];Hv(a<0||i<0||a===i,(function(){return n+" Shapes "+e+" and "+t+" must match"}))}}}function iV(e){return"number"!=typeof e&&!e.some((function(e){return e<0}))}function oV(e,t,n){var r=sV(e,n),a=!iV(r);if(a&&0===t.length)throw new Error("Tried to calculate elements of an empty list with non-fully-defined elementShape: "+r);if(a&&t.forEach((function(e){r=sV(e.shape,r)})),!iV(r))throw new Error("Non-fully-defined elementShape: "+r);return r}function sV(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error("Incompatible ranks during merge: "+e+" vs. "+t);for(var n=[],r=0;r<e.length;++r){var a=e[r],i=t[r];if(a>=0&&i>=0&&a!==i)throw new Error("Incompatible shape during merge: "+e+" vs. "+t);n[r]=a>=0?a:i}return n}var uV=function(){function e(e,t,n,r,a,i,o){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=i,this.clearAfterRead=o,this.tensors=[],this.closed_=!1,this.idTensor=KS(0),nI(this.idTensor)}var t=e.prototype;return t.clearAndClose=function(e){this.tensors.forEach((function(t){null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()},t.size=function(){return this.tensors.length},t.read=function(e){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(e<0||e>=this.size())throw new Error("Tried to read from index "+e+", but array size is: "+this.size());var t=this.tensors[e];if(t.cleared)throw new Error("TensorArray "+this.name+": Could not read index "+e+" twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).");return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor},t.readMany=function(e){var t=this;return e.map((function(e){return t.read(e)}))},t.write=function(e,t){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error("Tried to write to index "+e+", but array is not resizeable and size is: "+this.maxSize);var n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+e+",\n because the value dtype is "+t.dtype+", but TensorArray dtype is "+this.dtype+".");if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),aV(this.elementShape,t.shape,"TensorArray "+this.name+": Could not write to TensorArray index "+e+"."),n.read)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+e+", because it has already been read.");if(n.written)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+e+", because it has already been written.");n.tensor=t,nI(t),n.written=!0,this.tensors[e]=n},t.writeMany=function(e,t){var n=this;if(e.length!==t.length)throw new Error("TensorArray "+this.name+": could not write multiple tensors,because the index size: "+e.length+" is not the same as tensors size: "+t.length+".");e.forEach((function(e,r){return n.write(e,t[r])}))},t.gather=function(e,t){if(t&&t!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but gather requested dtype "+t);if(e)e=e.slice(0,this.size());else{e=[];for(var n=0;n<this.size();n++)e.push(n)}if(0===e.length)return Gk([],[0].concat(this.elementShape));var r=this.readMany(e);return aV(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),pE(r,0)},t.concat=function(e){if(e&&e!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but concat requested dtype "+e);if(0===this.size())return Gk([],[0].concat(this.elementShape));for(var t=[],n=0;n<this.size();n++)t.push(n);var r=this.readMany(t);return aV(this.elementShape,r[0].shape,"TensorArray shape mismatch: tensor array shape ("+this.elementShape+") vs first tensor shape ("+r[0].shape+")"),VI(r,0)},t.scatter=function(e,t){if(t.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+t.dtype);if(e.length!==t.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+e.length+" vs. "+t.shape[0]);var n=Math.max.apply(Math,e);if(!this.dynamicSize&&n>=this.maxSize)throw new Error("Max index must be < array size ("+n+" vs. "+this.maxSize+")");this.writeMany(e,RE(t,0))},t.split=function(e,t){var n=this;if(t.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+t.dtype);var r=0,a=e.map((function(e){return r+=e}));if(r!==t.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: "+t.shape);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error("TensorArray's size is not equal to the size of lengths ("+this.maxSize+" vs. "+e.length+"), and the TensorArray is not marked as dynamically resizeable");var i=0===r?0:t.size/r,o=[];eI((function(){t=PI(t,[1,r,i]);for(var s=0;s<e.length;++s){var u=[0,0===s?0:a[s-1],0],l=[1,e[s],i];o[s]=PI(jI(t,u,l),n.elementShape)}return o}));for(var s=[],u=0;u<e.length;u++)s[u]=u;this.writeMany(s,o)},Tv(e,[{key:"id",get:function(){return this.idTensor.id}},{key:"closed",get:function(){return this.closed_}}]),e}(),lV=function(){function e(e,t,n,r){void 0===r&&(r=-1),this.tensors=e,this.elementShape=t,this.elementDtype=n,null!=e&&e.forEach((function(e){if(n!==e.dtype)throw new Error("Invalid data types; op elements "+n+", but list elements "+e.dtype);aV(t,e.shape,"TensorList shape mismatch: "),nI(e)})),this.idTensor=KS(0),this.maxNumElements=r,nI(this.idTensor)}var t=e.prototype;return t.copy=function(){return new e([].concat(this.tensors),this.elementShape,this.elementDtype)},t.clearAndClose=function(e){this.tensors.forEach((function(t){null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()},t.size=function(){return this.tensors.length},t.stack=function(e,t,n){var r=this;if(void 0===n&&(n=-1),t!==this.elementDtype)throw new Error("Invalid data types; op elements "+t+", but list elements "+this.elementDtype);if(-1!==n&&this.tensors.length!==n)throw new Error("Operation expected a list with "+n+" elements but got a list with "+this.tensors.length+" elements.");aV(e,this.elementShape,"TensorList shape mismatch: ");var a=oV(this.elementShape,this.tensors,e);return eI((function(){var e=r.tensors.map((function(e){return PI(e,a)}));return pE(e,0)}))},t.popBack=function(e,t){if(t!==this.elementDtype)throw new Error("Invalid data types; op elements "+t+", but list elements "+this.elementDtype);if(0===this.size())throw new Error("Trying to pop from an empty list.");var n=oV(this.elementShape,this.tensors,e),r=this.tensors.pop();return r.kept=!1,aV(r.shape,e,"TensorList shape mismatch: "),PI(r,n)},t.pushBack=function(e){if(e.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+e.dtype+", but list elements "+this.elementDtype);if(aV(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");nI(e),this.tensors.push(e)},t.resize=function(t){if(t<0)throw new Error("TensorListResize expects size to be non-negative. Got: "+t);if(-1!==this.maxNumElements&&t>this.maxNumElements)throw new Error("TensorListResize input size "+t+" is greater maxNumElement "+this.maxNumElements+".");var n=new e([],this.elementShape,this.elementDtype,this.maxNumElements);n.tensors.length=t;for(var r=0;r<Math.min(this.tensors.length,t);++r)n.tensors[r]=this.tensors[r];return n},t.getItem=function(e,t,n){if(n!==this.elementDtype)throw new Error("Invalid data types; op elements "+n+", but list elements "+this.elementDtype);if(e<0||e>this.tensors.length)throw new Error("Trying to access element "+e+" in a list with "+this.tensors.length+" elements.");if(null==this.tensors[e])throw new Error("element at index "+e+" is null.");aV(this.tensors[e].shape,t,"TensorList shape mismatch: ");var r=oV(this.elementShape,this.tensors,t);return PI(this.tensors[e],r)},t.setItem=function(e,t){if(t.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+t.dtype+", but list elements "+this.elementDtype);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error("Trying to set element "+e+" in a list with max "+this.maxNumElements+" elements.");aV(this.elementShape,t.shape,"TensorList shape mismatch: "),nI(t),null!=this.tensors[e]&&(this.tensors[e].kept=!1),this.tensors[e]=t},t.gather=function(e,t,n){var r=this;if(t!==this.elementDtype)throw new Error("Invalid data types; op elements "+t+", but list elements "+this.elementDtype);aV(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());var a=oV(this.elementShape,this.tensors,n);return 0===e.length?Gk([],[0].concat(a)):eI((function(){var t=e.map((function(e){return PI(r.tensors[e],a)}));return pE(t,0)}))},t.concat=function(e,t){var n=this;if(e&&e!==this.elementDtype)throw new Error("TensorList dtype is "+this.elementDtype+" but concat requested dtype "+e);aV(this.elementShape,t,"TensorList shape mismatch: ");var r=oV(this.elementShape,this.tensors,t);return 0===this.size()?Gk([],[0].concat(r)):eI((function(){var e=n.tensors.map((function(e){return PI(e,r)}));return VI(e,0)}))},Tv(e,[{key:"id",get:function(){return this.idTensor.id}}]),e}();function cV(e,t,n){var r=e.dtype;if(e.shape.length<1)throw new Error("Tensor must be at least a vector, but saw shape: "+e.shape);if(e.dtype!==n)throw new Error("Invalid data types; op elements "+e.dtype+", but list elements "+n);aV(e.shape.slice(1),t,"TensorList shape mismatch: ");var a=RE(e);return new lV(a,t,r)}function pV(e,t,n,r){return new lV([],e,t,r)}function hV(e,t,n,r){if(t.length!==e.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+t.length+" vs. "+e.shape[0]);var a=Math.max.apply(Math,t);if(null!=r&&-1!==r&&a>=r)throw new Error("Max index must be < array size ("+a+" vs. "+r+")");var i=new lV([],n,e.dtype,r),o=RE(e,0);return t.forEach((function(e,t){i.setItem(e,o[t])})),i}function dV(e,t,n){var r=0,a=t.map((function(e){return r+=e}));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);for(var i=sV(e.shape.slice(1),n),o=0===r?0:e.size/r,s=eI((function(){var n=[];e=PI(e,[1,r,o]);for(var s=0;s<t.length;++s){var u=[0,0===s?0:a[s-1],0],l=[1,t[s],o];n[s]=PI(jI(e,u,l),i)}return e.dispose(),n})),u=new lV([],n,e.dtype,t.length),l=0;l<s.length;l++)u.setItem(l,s[l]);return u}var fV=function(){var e=Iv(kv().mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,d,f,m,v,g,y,b,x,w,k,N,I,S,T,C,E,A,R,_,F,O,D,M,L,z,P,B,W,V,U,G,j,H,q,K,X,Y,J,Z,Q,$,ee,te,ne,re,ae,ie,oe,se,ue,le,ce,pe,he,de,fe,me,ve,ge,ye,be,xe,we,ke,Ne,Ie,Se,Te,Ce,Ee,Ae,Re,_e,Fe,Oe,De,Me,Le,ze,Pe,Be,We,Ve,Ue,Ge,je,He,qe,Ke,Xe,Ye,Je,Ze,Qe;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.op,e.next="If"===e.t0||"StatelessIf"===e.t0?3:"While"===e.t0||"StatelessWhile"===e.t0?15:"LoopCond"===e.t0?19:"Switch"===e.t0?21:"Merge"===e.t0?32:"Enter"===e.t0?37:"Exit"===e.t0?41:"NextIteration"===e.t0?44:"TensorArrayV3"===e.t0?47:"TensorArrayWriteV3"===e.t0?57:"TensorArrayReadV3"===e.t0?63:"TensorArrayGatherV3"===e.t0?67:"TensorArrayScatterV3"===e.t0?72:"TensorArrayConcatV3"===e.t0?78:"TensorArraySplitV3"===e.t0?82:"TensorArraySizeV3"===e.t0?88:"TensorArrayCloseV3"===e.t0?91:"TensorListSetItem"===e.t0?95:"TensorListGetItem"===e.t0?101:"TensorListScatterV2"===e.t0||"TensorListScatter"===e.t0?107:"TensorListReserve"===e.t0||"EmptyTensorList"===e.t0?114:"TensorListGather"===e.t0?122:"TensorListStack"===e.t0?128:"TensorListFromTensor"===e.t0?134:"TensorListConcat"===e.t0||"TensorListConcatV2"===e.t0?140:"TensorListPushBack"===e.t0?145:"TensorListPopBack"===e.t0?150:"TensorListSplit"===e.t0?155:"TensorListLength"===e.t0?161:"TensorListResize"===e.t0?164:170;break;case 3:return a=fW("thenBranch",t,n,r),i=fW("elseBranch",t,n,r),o=fW("cond",t,n,r),s=fW("args",t,n,r),e.next=9,o.data();case 9:if(!e.sent[0]){e.next=14;break}return e.abrupt("return",r.functionMap[a].executeFunctionAsync(s,r.tensorArrayMap,r.tensorListMap));case 14:return e.abrupt("return",r.functionMap[i].executeFunctionAsync(s,r.tensorArrayMap,r.tensorListMap));case 15:return e.delegateYield(kv().mark((function e(){var a,i,o,s,u,l,c,p;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=fW("body",t,n,r),i=fW("cond",t,n,r),o=fW("args",t,n,r),e.next=5,r.functionMap[i].executeFunctionAsync(o,r.tensorArrayMap,r.tensorListMap);case 5:return s=e.sent,u=o.map((function(e){return e.id})),e.next=9,s[0].data();case 9:l=e.sent,s.forEach((function(e){e.kept||-1!==u.indexOf(e.id)||e.dispose()})),c=o,p=kv().mark((function e(){var t,n,o;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c,e.next=3,r.functionMap[a].executeFunctionAsync(c,r.tensorArrayMap,r.tensorListMap);case 3:return c=e.sent,n=c.map((function(e){return e.id})),t.forEach((function(e){e.kept||-1!==u.indexOf(e.id)||-1!==n.indexOf(e.id)||e.dispose()})),e.next=8,r.functionMap[i].executeFunctionAsync(c,r.tensorArrayMap,r.tensorListMap);case 8:return o=e.sent,e.next=11,o[0].data();case 11:l=e.sent,o.forEach((function(e){e.kept||-1!==u.indexOf(e.id)||-1!==n.indexOf(e.id)||e.dispose()}));case 13:case"end":return e.stop()}}),e)}));case 13:if(!l[0]){e.next=17;break}return e.delegateYield(p(),"t0",15);case 15:e.next=13;break;case 17:return e.abrupt("return",{v:c});case 18:case"end":return e.stop()}}),e)}))(),"t1",16);case 16:if("object"!=typeof(u=e.t1)){e.next=19;break}return e.abrupt("return",u.v);case 19:return l=fW("pred",t,n,r),e.abrupt("return",[wW(l)]);case 21:return c=fW("pred",t,n,r),(p=fW("data",t,n,r)).kept||(p=wW(p)),e.next=26,c.data();case 26:if(!e.sent[0]){e.next=30;break}e.t2=[void 0,p],e.next=31;break;case 30:e.t2=[p,void 0];case 31:return e.abrupt("return",e.t2);case 32:if(h=t.inputNames.find((function(e){return void 0!==mW(e,n,r)})),!h){e.next=36;break}return d=mW(h,n,r),e.abrupt("return",[wW(d)]);case 36:return e.abrupt("return",void 0);case 37:return f=fW("frameName",t,n,r),m=fW("tensor",t,n,r),r.enterFrame(f),e.abrupt("return",[wW(m)]);case 41:return v=fW("tensor",t,n,r),r.exitFrame(),e.abrupt("return",[wW(v)]);case 44:return g=fW("tensor",t,n,r),r.nextIteration(),e.abrupt("return",[wW(g)]);case 47:return y=fW("size",t,n,r),b=fW("dtype",t,n,r),x=fW("elementShape",t,n,r),w=fW("dynamicSize",t,n,r),k=fW("clearAfterRead",t,n,r),N=fW("identicalElementShapes",t,n,r),I=fW("name",t,n,r),S=new uV(I,b,y,x,N,w,k),r.addTensorArray(S),e.abrupt("return",[S.idTensor,KS(1)]);case 57:return T=fW("tensorArrayId",t,n,r),C=fW("index",t,n,r),E=fW("tensor",t,n,r),(A=r.getTensorArray(T.id)).write(C,E),e.abrupt("return",[A.idTensor]);case 63:return R=fW("tensorArrayId",t,n,r),_=fW("index",t,n,r),F=r.getTensorArray(R.id),e.abrupt("return",[F.read(_)]);case 67:return O=fW("tensorArrayId",t,n,r),D=fW("indices",t,n,r),M=fW("dtype",t,n,r),L=r.getTensorArray(O.id),e.abrupt("return",[L.gather(D,M)]);case 72:return z=fW("tensorArrayId",t,n,r),P=fW("indices",t,n,r),B=fW("tensor",t,n,r),(W=r.getTensorArray(z.id)).scatter(P,B),e.abrupt("return",[W.idTensor]);case 78:return V=fW("tensorArrayId",t,n,r),U=r.getTensorArray(V.id),G=fW("dtype",t,n,r),e.abrupt("return",[U.concat(G)]);case 82:return j=fW("tensorArrayId",t,n,r),H=fW("tensor",t,n,r),q=fW("lengths",t,n,r),(K=r.getTensorArray(j.id)).split(q,H),e.abrupt("return",[K.idTensor]);case 88:return X=fW("tensorArrayId",t,n,r),Y=r.getTensorArray(X.id),e.abrupt("return",[KS(Y.size(),"int32")]);case 91:return J=fW("tensorArrayId",t,n,r),(Z=r.getTensorArray(J.id)).clearAndClose(),e.abrupt("return",[Z.idTensor]);case 95:return Q=fW("tensorListId",t,n,r),$=fW("index",t,n,r),ee=fW("tensor",t,n,r),(te=r.getTensorList(Q.id)).setItem($,ee),e.abrupt("return",[te.idTensor]);case 101:return ne=fW("tensorListId",t,n,r),re=fW("index",t,n,r),ae=fW("elementShape",t,n,r),ie=fW("elementDType",t,n,r),oe=r.getTensorList(ne.id),e.abrupt("return",[oe.getItem(re,ae,ie)]);case 107:return se=fW("indices",t,n,r),ue=fW("tensor",t,n,r),le=fW("elementShape",t,n,r),ce=fW("numElements",t,n,r),pe=hV(ue,se,le,ce),r.addTensorList(pe),e.abrupt("return",[pe.idTensor]);case 114:return he=fW("elementShape",t,n,r),de=fW("elementDType",t,n,r),fe="TensorListReserve"===t.op?"numElements":"maxNumElements",me=fW(fe,t,n,r),ve="TensorListReserve"===t.op?-1:me,ge=pV(he,de,0,ve),r.addTensorList(ge),e.abrupt("return",[ge.idTensor]);case 122:return ye=fW("tensorListId",t,n,r),be=fW("indices",t,n,r),xe=fW("elementShape",t,n,r),we=fW("elementDType",t,n,r),ke=r.getTensorList(ye.id),e.abrupt("return",[ke.gather(be,we,xe)]);case 128:return Ne=fW("tensorListId",t,n,r),Ie=fW("elementShape",t,n,r),Se=fW("elementDType",t,n,r),Te=fW("numElements",t,n,r),Ce=r.getTensorList(Ne.id),e.abrupt("return",[Ce.stack(Ie,Se,Te)]);case 134:return Ee=fW("tensor",t,n,r),Ae=fW("elementShape",t,n,r),Re=fW("elementDType",t,n,r),_e=cV(Ee,Ae,Re),r.addTensorList(_e),e.abrupt("return",[_e.idTensor]);case 140:return Fe=fW("tensorListId",t,n,r),Oe=r.getTensorList(Fe.id),De=fW("dtype",t,n,r),Me=fW("elementShape",t,n,r),e.abrupt("return",[Oe.concat(De,Me)]);case 145:return Le=fW("tensorListId",t,n,r),ze=fW("tensor",t,n,r),(Pe=r.getTensorList(Le.id)).pushBack(ze),e.abrupt("return",[Pe.idTensor]);case 150:return Be=fW("tensorListId",t,n,r),We=fW("elementShape",t,n,r),Ve=fW("elementDType",t,n,r),Ue=r.getTensorList(Be.id),e.abrupt("return",[Ue.popBack(We,Ve)]);case 155:return Ge=fW("tensor",t,n,r),je=fW("elementShape",t,n,r),He=fW("lengths",t,n,r),qe=dV(Ge,He,je),r.addTensorList(qe),e.abrupt("return",[qe.idTensor]);case 161:return Ke=fW("tensorListId",t,n,r),Xe=r.getTensorList(Ke.id),e.abrupt("return",[KS(Xe.size(),"int32")]);case 164:return Ye=fW("tensorListId",t,n,r),Je=fW("size",t,n,r),Ze=r.getTensorList(Ye.id),Qe=Ze.resize(Je),r.addTensorList(Qe),e.abrupt("return",[Qe.idTensor]);case 170:throw TypeError("Node type "+t.op+" is not implemented");case 171:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}();function mV(e,t,n){var r=fW("fusedOps",e,t,n),a=r[0],i=r[1],o="biasadd"===a,s=!o,u="prelu"===i,l="fusedbatchnorm"===a,c=fW("numArgs",e,t,n);if(o){if(u&&2!==c)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!u&&o&&1!==c)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(l)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");var p=fW("strides",e,t,n),h=xW(e,t,n),d=fW("dataFormat",e,t,n).toUpperCase(),f=fW("dilations",e,t,n),m=fW("args",e,t,n),v=m[0],g=m[1];return s&&(g=v,v=void 0),{stride:p,pad:h,dataFormat:d,dilations:f,biasArg:v,preluArg:g,activationFunc:i,leakyreluAlpha:fW("leakyreluAlpha",e,t,n)}}function vV(e,t,n){return{boxes:fW("boxes",e,t,n),scores:fW("scores",e,t,n),maxOutputSize:fW("maxOutputSize",e,t,n),iouThreshold:fW("iouThreshold",e,t,n),scoreThreshold:fW("scoreThreshold",e,t,n),softNmsSigma:fW("softNmsSigma",e,t,n)}}var gV=function(){var e=Iv(kv().mark((function e(t,n,r,a,i){var o,s,u,l,c,p,h,d,f,m,v,g,y,b,x,w,k,N,I,S,T,C,E,A;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:void 0===i&&(i=rV),e.t0=t.op,e.next="NonMaxSuppressionV5"===e.t0?4:"NonMaxSuppressionV4"===e.t0?9:"NonMaxSuppressionV3"===e.t0||"NonMaxSuppressionV2"===e.t0?15:"Where"===e.t0?20:"ListDiff"===e.t0?27:28;break;case 4:return o=vV(t,n,r),s=o.boxes,u=o.scores,l=o.maxOutputSize,c=o.iouThreshold,p=o.scoreThreshold,h=o.softNmsSigma,e.next=7,i.image.nonMaxSuppressionWithScoreAsync(s,u,l,c,p,h);case 7:return d=e.sent,e.abrupt("return",[d.selectedIndices,d.selectedScores]);case 9:return f=vV(t,n,r),m=f.boxes,v=f.scores,g=f.maxOutputSize,y=f.iouThreshold,b=f.scoreThreshold,x=fW("padToMaxOutputSize",t,n,r),e.next=13,i.image.nonMaxSuppressionPaddedAsync(m,v,g,y,b,x);case 13:return w=e.sent,e.abrupt("return",[w.selectedIndices,w.validOutputs]);case 15:return k=vV(t,n,r),N=k.boxes,I=k.scores,S=k.maxOutputSize,T=k.iouThreshold,C=k.scoreThreshold,e.next=18,i.image.nonMaxSuppressionAsync(N,I,S,T,C);case 18:return e.t1=e.sent,e.abrupt("return",[e.t1]);case 20:return E=i.cast(fW("condition",t,n,r),"bool"),e.next=23,i.whereAsync(E);case 23:return e.t2=e.sent,A=[e.t2],E.dispose(),e.abrupt("return",A);case 27:return e.abrupt("return",i.setdiff1dAsync(fW("x",t,n,r),fW("y",t,n,r)));case 28:throw TypeError("Node type "+t.op+" is not implemented");case 29:case"end":return e.stop()}}),e)})));return function(t,n,r,a,i){return e.apply(this,arguments)}}(),yV=function(){function e(e,t){this.keyDType=e,this.valueDType=t,this.handle=KS(0),this.tensorMap=new Map,nI(this.handle)}var t=e.prototype;return t.clearAndClose=function(){this.tensorMap.forEach((function(e){return e.dispose()})),this.tensorMap.clear(),this.handle.dispose()},t.size=function(){return this.tensorMap.size},t.tensorSize=function(){return KS(this.size(),"int32")},t.import=function(){var e=Iv(kv().mark((function e(t,n){var r,a=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.checkKeyAndValueTensor(t,n),e.next=3,t.data();case 3:return r=e.sent,this.tensorMap.forEach((function(e){return e.dispose()})),this.tensorMap.clear(),e.abrupt("return",eI((function(){var e=RE(n),t=r.length,i=e.length;Hv(t===i,(function(){return"The number of elements doesn't match, keys has "+t+" elements, the values has "+i+" elements."}));for(var o=0;o<t;o++){var s=r[o],u=e[o];nI(u),a.tensorMap.set(s,u)}return a.handle})));case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.find=function(){var e=Iv(kv().mark((function e(t,n){var r,a=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.checkKeyAndValueTensor(t,n),e.next=3,t.data();case 3:return r=e.sent,e.abrupt("return",eI((function(){for(var e=[],t=0;t<r.length;t++){var i=r[t],o=a.findWithDefault(i,n);e.push(o)}return pE(e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.findWithDefault=function(e,t){var n=this.tensorMap.get(e);return null!=n?n:t},t.checkKeyAndValueTensor=function(e,t){if(e.dtype!==this.keyDType)throw new Error("Expect key dtype "+this.keyDType+", but got "+e.dtype);if(t.dtype!==this.valueDType)throw new Error("Expect value dtype "+this.valueDType+", but got "+t.dtype)},Tv(e,[{key:"id",get:function(){return this.handle.id}}]),e}(),bV=function(){var e=Iv(kv().mark((function e(t,n,r,a){var i,o,s,u,l,c,p,h,d,f,m,v,g,y;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.op,e.next="HashTable"===e.t0||"HashTableV2"===e.t0?3:"InitializeTable"===e.t0||"InitializeTableV2"===e.t0||"LookupTableImport"===e.t0||"LookupTableImportV2"===e.t0?13:"LookupTableFind"===e.t0||"LookupTableFindV2"===e.t0?21:"LookupTableSize"===e.t0||"LookupTableSizeV2"===e.t0?29:32;break;case 3:if(null==(i=a.getHashTableHandleByName(t.name))){e.next=8;break}return e.abrupt("return",[i]);case 8:return o=fW("keyDType",t,n,r),s=fW("valueDType",t,n,r),u=new yV(o,s),a.addHashTable(t.name,u),e.abrupt("return",[u.handle]);case 13:return l=fW("tableHandle",t,n,r,a),c=fW("keys",t,n,r),p=fW("values",t,n,r),h=a.getHashTableById(l.id),e.next=19,h.import(c,p);case 19:return e.t1=e.sent,e.abrupt("return",[e.t1]);case 21:return d=fW("tableHandle",t,n,r,a),f=fW("keys",t,n,r),m=fW("defaultValue",t,n,r),v=a.getHashTableById(d.id),e.next=27,v.find(f,m);case 27:return e.t2=e.sent,e.abrupt("return",[e.t2]);case 29:return g=fW("tableHandle",t,n,r,a),y=a.getHashTableById(g.id),e.abrupt("return",[y.tensorSize()]);case 32:throw TypeError("Node type "+t.op+" is not implemented");case 33:case"end":return e.stop()}}),e)})));return function(t,n,r,a){return e.apply(this,arguments)}}();function xV(e,t,n,r,a){void 0===a&&(a=eI);var i=function(e,t,n){switch(e.category){case"arithmetic":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(fW("a",e,t,n),fW("b",e,t,n))];case"AddN":return[r.addN(fW("tensors",e,t,n))];case"FloorMod":case"Mod":return[r.mod(fW("a",e,t,n),fW("b",e,t,n))];case"Mul":return[r.mul(fW("a",e,t,n),fW("b",e,t,n))];case"RealDiv":case"Div":return[r.div(fW("a",e,t,n),fW("b",e,t,n))];case"DivNoNan":return[r.divNoNan(fW("a",e,t,n),fW("b",e,t,n))];case"FloorDiv":return[r.floorDiv(fW("a",e,t,n),fW("b",e,t,n))];case"Sub":return[r.sub(fW("a",e,t,n),fW("b",e,t,n))];case"Minimum":return[r.minimum(fW("a",e,t,n),fW("b",e,t,n))];case"Maximum":return[r.maximum(fW("a",e,t,n),fW("b",e,t,n))];case"Pow":return[r.pow(fW("a",e,t,n),fW("b",e,t,n))];case"SquaredDifference":return[r.squaredDifference(fW("a",e,t,n),fW("b",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"basic_math":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"Abs":case"ComplexAbs":return[r.abs(fW("x",e,t,n))];case"Acos":return[r.acos(fW("x",e,t,n))];case"Acosh":return[r.acosh(fW("x",e,t,n))];case"Asin":return[r.asin(fW("x",e,t,n))];case"Asinh":return[r.asinh(fW("x",e,t,n))];case"Atan":return[r.atan(fW("x",e,t,n))];case"Atan2":return[r.atan2(fW("x",e,t,n),fW("y",e,t,n))];case"Atanh":return[r.atanh(fW("x",e,t,n))];case"Ceil":return[r.ceil(fW("x",e,t,n))];case"Complex":return[r.complex(fW("real",e,t,n),fW("imag",e,t,n))];case"Cos":return[r.cos(fW("x",e,t,n))];case"Cosh":return[r.cosh(fW("x",e,t,n))];case"Elu":return[r.elu(fW("x",e,t,n))];case"Erf":return[r.erf(fW("x",e,t,n))];case"Exp":return[r.exp(fW("x",e,t,n))];case"Expm1":return[r.expm1(fW("x",e,t,n))];case"Floor":return[r.floor(fW("x",e,t,n))];case"Log":return[r.log(fW("x",e,t,n))];case"Log1p":return[r.log1p(fW("x",e,t,n))];case"Imag":return[r.imag(fW("x",e,t,n))];case"Neg":return[r.neg(fW("x",e,t,n))];case"Reciprocal":return[r.reciprocal(fW("x",e,t,n))];case"Real":return[r.real(fW("x",e,t,n))];case"Relu":return[r.relu(fW("x",e,t,n))];case"Round":return[r.round(fW("x",e,t,n))];case"Selu":return[r.selu(fW("x",e,t,n))];case"Sigmoid":return[r.sigmoid(fW("x",e,t,n))];case"Sin":return[r.sin(fW("x",e,t,n))];case"Sign":return[r.sign(fW("x",e,t,n))];case"Sinh":return[r.sinh(fW("x",e,t,n))];case"Softplus":return[r.softplus(fW("x",e,t,n))];case"Sqrt":return[r.sqrt(fW("x",e,t,n))];case"Square":return[r.square(fW("x",e,t,n))];case"Tanh":return[r.tanh(fW("x",e,t,n))];case"Tan":return[r.tan(fW("x",e,t,n))];case"ClipByValue":return[r.clipByValue(fW("x",e,t,n),fW("clipValueMin",e,t,n),fW("clipValueMax",e,t,n))];case"Relu6":return[r.relu6(fW("x",e,t,n))];case"Rsqrt":return[r.rsqrt(mW(e.inputNames[0],t,n))];case"Prod":return[r.prod(fW("x",e,t,n),fW("axes",e,t,n))];case"LeakyRelu":return[r.leakyRelu(fW("x",e,t,n),fW("alpha",e,t,n))];case"Prelu":return[r.prelu(fW("x",e,t,n),fW("alpha",e,t,n))];case"IsNan":return[r.isNaN(mW(e.inputNames[0],t,n))];case"IsInf":return[r.isInf(mW(e.inputNames[0],t,n))];case"IsFinite":return[r.isFinite(mW(e.inputNames[0],t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"control":return fV(e,t,n);case"convolution":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"Conv1D":var a=fW("stride",e,t,n),i=fW("pad",e,t,n),o=fW("dataFormat",e,t,n).toUpperCase(),s=fW("dilation",e,t,n);return[r.conv1d(fW("x",e,t,n),fW("filter",e,t,n),a,i,o,s)];case"Conv2D":var u=fW("strides",e,t,n),l=xW(e,t,n),c=fW("dataFormat",e,t,n).toUpperCase(),p=fW("dilations",e,t,n);return[r.conv2d(fW("x",e,t,n),fW("filter",e,t,n),[u[1],u[2]],l,c,[p[1],p[2]])];case"_FusedConv2D":var h=mV(e,t,n),d=h.stride,f=h.pad,m=h.dataFormat,v=h.dilations,g=h.biasArg,y=h.preluArg,b=h.activationFunc,x=h.leakyreluAlpha;return[r.fused.conv2d({x:fW("x",e,t,n),filter:fW("filter",e,t,n),strides:[d[1],d[2]],pad:f,dataFormat:m,dilations:[v[1],v[2]],bias:g,activation:b,preluActivationWeights:y,leakyreluAlpha:x})];case"FusedDepthwiseConv2dNative":var w=mV(e,t,n),k=w.stride,N=w.pad,I=w.dataFormat,S=w.dilations,T=w.biasArg,C=w.preluArg,E=w.activationFunc,A=w.leakyreluAlpha;return[r.fused.depthwiseConv2d({x:fW("x",e,t,n),filter:fW("filter",e,t,n),strides:[k[1],k[2]],pad:N,dataFormat:I,dilations:[S[1],S[2]],bias:T,activation:E,preluActivationWeights:C,leakyreluAlpha:A})];case"Conv2DBackpropInput":case"Conv2dTranspose":var R=fW("outputShape",e,t,n),_=fW("strides",e,t,n),F=xW(e,t,n);return[r.conv2dTranspose(fW("x",e,t,n),fW("filter",e,t,n),R,[_[1],_[2]],F)];case"DepthwiseConv2dNative":case"DepthwiseConv2d":var O=fW("strides",e,t,n),D=xW(e,t,n),M=fW("dilations",e,t,n),L=fW("dataFormat",e,t,n).toUpperCase();return[r.depthwiseConv2d(fW("input",e,t,n),fW("filter",e,t,n),[O[1],O[2]],D,L,[M[1],M[2]])];case"Conv3D":var z=fW("strides",e,t,n),P=fW("pad",e,t,n),B=fW("dataFormat",e,t,n).toUpperCase(),W=fW("dilations",e,t,n);return[r.conv3d(fW("x",e,t,n),fW("filter",e,t,n),[z[1],z[2],z[3]],P,B,[W[1],W[2],W[3]])];case"AvgPool":var V=fW("strides",e,t,n),U=fW("pad",e,t,n),G=fW("kernelSize",e,t,n);return[r.avgPool(fW("x",e,t,n),[G[1],G[2]],[V[1],V[2]],U)];case"MaxPool":var j=fW("strides",e,t,n),H=fW("pad",e,t,n),q=fW("kernelSize",e,t,n);return[r.maxPool(fW("x",e,t,n),[q[1],q[2]],[j[1],j[2]],H)];case"MaxPoolWithArgmax":var K=fW("strides",e,t,n),X=fW("pad",e,t,n),Y=fW("kernelSize",e,t,n),J=fW("includeBatchInIndex",e,t,n),Z=r.maxPoolWithArgmax(fW("x",e,t,n),[Y[1],Y[2]],[K[1],K[2]],X,J);return[Z.result,Z.indexes];case"AvgPool3D":var Q=fW("strides",e,t,n),$=fW("pad",e,t,n),ee=fW("kernelSize",e,t,n);return[r.avgPool3d(fW("x",e,t,n),[ee[1],ee[2],ee[3]],[Q[1],Q[2],Q[3]],$)];case"MaxPool3D":var te=fW("strides",e,t,n),ne=fW("pad",e,t,n),re=fW("kernelSize",e,t,n);return[r.maxPool3d(fW("x",e,t,n),[re[1],re[2],re[3]],[te[1],te[2],te[3]],ne)];case"Dilation2D":var ae=fW("strides",e,t,n),ie=fW("pad",e,t,n),oe=fW("dilations",e,t,n),se=ae[1],ue=ae[2],le=oe[1],ce=oe[2];return[r.dilation2d(fW("x",e,t,n),fW("filter",e,t,n),[se,ue],ie,[le,ce],"NHWC")];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"creation":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"Fill":var a=fW("shape",e,t,n),i=fW("dtype",e,t,n),o=fW("value",e,t,n);return[r.fill(a,o,i)];case"LinSpace":var s=fW("start",e,t,n),u=fW("stop",e,t,n),l=fW("num",e,t,n);return[r.linspace(s,u,l)];case"Multinomial":var c=fW("logits",e,t,n),p=fW("numSamples",e,t,n),h=fW("seed",e,t,n);return[r.multinomial(c,p,h)];case"OneHot":var d=fW("indices",e,t,n),f=fW("depth",e,t,n),m=fW("onValue",e,t,n),v=fW("offValue",e,t,n),g=fW("dtype",e,t,n);return[r.oneHot(d,f,m,v,g)];case"Ones":return[r.ones(fW("shape",e,t,n),fW("dtype",e,t,n))];case"OnesLike":return[r.onesLike(fW("x",e,t,n))];case"RandomStandardNormal":return[r.randomStandardNormal(fW("shape",e,t,n),fW("dtype",e,t,n),fW("seed",e,t,n))];case"RandomUniform":return[r.randomUniform(fW("shape",e,t,n),fW("minval",e,t,n),fW("maxval",e,t,n),fW("dtype",e,t,n))];case"Range":var y=fW("start",e,t,n),b=fW("stop",e,t,n),x=fW("step",e,t,n);return[r.range(y,b,x,fW("dtype",e,t,n))];case"TruncatedNormal":var w=fW("shape",e,t,n),k=fW("mean",e,t,n),N=fW("stdDev",e,t,n),I=fW("seed",e,t,n);return[r.truncatedNormal(w,k,N,fW("dtype",e,t,n),I)];case"Zeros":return[r.zeros(fW("shape",e,t,n),fW("dtype",e,t,n))];case"ZerosLike":return[r.zerosLike(fW("x",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"dynamic":return gV(e,t,n);case"evaluation":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"LowerBound":var a=fW("sortedSequence",e,t,n),i=fW("values",e,t,n);return[r.lowerBound(a,i)];case"TopKV2":var o=fW("x",e,t,n),s=fW("k",e,t,n),u=fW("sorted",e,t,n),l=r.topk(o,s,u);return[l.values,l.indices];case"UpperBound":var c=fW("sortedSequence",e,t,n),p=fW("values",e,t,n);return[r.upperBound(c,p)];case"Unique":var h=fW("x",e,t,n),d=r.unique(h);return[d.values,d.indices];case"UniqueV2":var f=fW("x",e,t,n),m=fW("axis",e,t,n),v=r.unique(f,m);return[v.values,v.indices];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"image":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"ResizeBilinear":var a=fW("images",e,t,n),i=fW("size",e,t,n),o=fW("alignCorners",e,t,n),s=fW("halfPixelCenters",e,t,n);return[r.image.resizeBilinear(a,[i[0],i[1]],o,s)];case"ResizeNearestNeighbor":var u=fW("images",e,t,n),l=fW("size",e,t,n),c=fW("alignCorners",e,t,n),p=fW("halfPixelCenters",e,t,n);return[r.image.resizeNearestNeighbor(u,[l[0],l[1]],c,p)];case"CropAndResize":var h=fW("image",e,t,n),d=fW("boxes",e,t,n),f=fW("boxInd",e,t,n),m=fW("cropSize",e,t,n),v=fW("method",e,t,n),g=fW("extrapolationValue",e,t,n);return[r.image.cropAndResize(h,d,f,m,v,g)];case"ImageProjectiveTransformV3":var y=fW("images",e,t,n),b=fW("transforms",e,t,n),x=fW("outputShape",e,t,n),w=fW("fillValue",e,t,n),k=fW("interpolation",e,t,n),N=fW("fillMode",e,t,n);return[r.image.transform(y,b,k.toLowerCase(),N.toLowerCase(),w,x)];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"graph":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":var a=fW("default",e,t,n);return[mW(e.name,t,n)||a];case"Placeholder":return[mW(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[wW(fW("x",e,t,n))];case"IdentityN":return fW("x",e,t,n).map((function(e){return wW(e)}));case"Shape":return[r.tensor1d(fW("x",e,t,n).shape,"int32")];case"ShapeN":return fW("x",e,t,n).map((function(e){return r.tensor1d(e.shape)}));case"Size":return[r.scalar(fW("x",e,t,n).size,"int32")];case"Rank":return[r.scalar(fW("x",e,t,n).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":var i=fW("x",e,t,n),o=fW("data",e,t,n),s=fW("message",e,t,n),u=fW("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(s);for(var l=0;l<o.length;l++)console.log(Array.prototype.slice.call(o[l].dataSync()).slice(0,u));return[i];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"logical":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"Equal":return[r.equal(fW("a",e,t,n),fW("b",e,t,n))];case"NotEqual":return[r.notEqual(fW("a",e,t,n),fW("b",e,t,n))];case"Greater":return[r.greater(fW("a",e,t,n),fW("b",e,t,n))];case"GreaterEqual":return[r.greaterEqual(fW("a",e,t,n),fW("b",e,t,n))];case"Less":return[r.less(fW("a",e,t,n),fW("b",e,t,n))];case"LessEqual":return[r.lessEqual(fW("a",e,t,n),fW("b",e,t,n))];case"LogicalAnd":return[r.logicalAnd(fW("a",e,t,n),fW("b",e,t,n))];case"LogicalNot":return[r.logicalNot(fW("a",e,t,n))];case"LogicalOr":return[r.logicalOr(fW("a",e,t,n),fW("b",e,t,n))];case"Select":case"SelectV2":return[r.where(fW("condition",e,t,n),fW("a",e,t,n),fW("b",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"matrices":return a((function(){return function(e,t,n,r){var a;switch(void 0===r&&(r=rV),e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(fW("a",e,t,n),fW("b",e,t,n),fW("transposeA",e,t,n),fW("transposeB",e,t,n))];case"Einsum":return[(a=r).einsum.apply(a,[fW("equation",e,t,n)].concat(fW("tensors",e,t,n)))];case"Transpose":return[r.transpose(fW("x",e,t,n),fW("perm",e,t,n))];case"_FusedMatMul":var i=fW("fusedOps",e,t,n),o=i[0],s=i[1],u="biasadd"===o,l="prelu"===s,c=fW("numArgs",e,t,n),p=fW("leakyreluAlpha",e,t,n);if(u){if(l&&2!==c)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!l&&1!==c)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}var h=fW("args",e,t,n),d=h[0],f=h[1];return[r.fused.matMul({a:fW("a",e,t,n),b:fW("b",e,t,n),transposeA:fW("transposeA",e,t,n),transposeB:fW("transposeB",e,t,n),bias:d,activation:s,preluActivationWeights:f,leakyreluAlpha:p})];case"MatrixBandPart":return[r.linalg.bandPart(fW("a",e,t,n),fW("numLower",e,t,n),fW("numUpper",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"normalization":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"EuclideanNorm":return[r.euclideanNorm(fW("x",e,t,n),fW("axis",e,t,n),fW("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[r.batchNorm(fW("x",e,t,n),fW("mean",e,t,n),fW("variance",e,t,n),fW("offset",e,t,n),fW("scale",e,t,n),fW("epsilon",e,t,n))];case"LRN":return[r.localResponseNormalization(fW("x",e,t,n),fW("radius",e,t,n),fW("bias",e,t,n),fW("alpha",e,t,n),fW("beta",e,t,n))];case"Softmax":return[r.softmax(fW("x",e,t,n))];case"LogSoftmax":return[r.logSoftmax(fW("x",e,t,n))];case"SparseToDense":return[r.sparseToDense(fW("sparseIndices",e,t,n),fW("outputShape",e,t,n),fW("sparseValues",e,t,n),fW("defaultValue",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"ragged":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"RaggedGather":var a=r.raggedGather(fW("paramsNestedSplits",e,t,n),fW("paramsDenseValues",e,t,n),fW("indices",e,t,n),fW("outputRaggedRank",e,t,n)),i=a.outputNestedSplits,o=a.outputDenseValues;return i.concat(o);case"RaggedRange":var s=r.raggedRange(fW("starts",e,t,n),fW("limits",e,t,n),fW("splits",e,t,n));return[s.rtNestedSplits,s.rtDenseValues];case"RaggedTensorToTensor":return[r.raggedTensorToTensor(fW("shape",e,t,n),fW("values",e,t,n),fW("defaultValue",e,t,n),fW("rowPartitionTensors",e,t,n),fW("rowPartitionTypes",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"reduction":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"Max":var a=fW("axis",e,t,n),i=fW("keepDims",e,t,n);return[r.max(fW("x",e,t,n),a,i)];case"Mean":var o=fW("axis",e,t,n),s=fW("keepDims",e,t,n);return[r.mean(fW("x",e,t,n),o,s)];case"Min":var u=fW("axis",e,t,n),l=fW("keepDims",e,t,n);return[r.min(fW("x",e,t,n),u,l)];case"Sum":var c=fW("axis",e,t,n),p=fW("keepDims",e,t,n);return[r.sum(fW("x",e,t,n),c,p)];case"All":var h=fW("axis",e,t,n),d=fW("keepDims",e,t,n);return[r.all(fW("x",e,t,n),h,d)];case"Any":var f=fW("axis",e,t,n),m=fW("keepDims",e,t,n);return[r.any(fW("x",e,t,n),f,m)];case"ArgMax":var v=fW("axis",e,t,n);return[r.argMax(fW("x",e,t,n),v)];case"ArgMin":var g=fW("axis",e,t,n);return[r.argMin(fW("x",e,t,n),g)];case"Prod":var y=fW("axis",e,t,n),b=fW("keepDims",e,t,n);return[r.prod(fW("x",e,t,n),y,b)];case"Cumprod":var x=fW("axis",e,t,n),w=fW("exclusive",e,t,n),k=fW("reverse",e,t,n);return[r.cumprod(fW("x",e,t,n),x,w,k)];case"Cumsum":var N=fW("axis",e,t,n),I=fW("exclusive",e,t,n),S=fW("reverse",e,t,n);return[r.cumsum(fW("x",e,t,n),N,I,S)];case"Bincount":var T=fW("x",e,t,n),C=fW("weights",e,t,n),E=fW("size",e,t,n);return[r.bincount(T,C,E)];case"DenseBincount":var A=fW("x",e,t,n),R=fW("weights",e,t,n),_=fW("size",e,t,n),F=fW("binaryOutput",e,t,n);return[r.denseBincount(A,R,_,F)];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"slice_join":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"ConcatV2":case"Concat":var a=fW("n",e,t,n),i=fW("axis",e,t,n),o=fW("tensors",e,t,n);return o=o.slice(0,a),[r.concat(o,i)];case"Gather":var s=fW("x",e,t,n),u=fW("indices",e,t,n);return[r.gather(s,r.cast(u,"int32"),0)];case"GatherV2":var l=fW("axis",e,t,n),c=fW("batchDims",e,t,n),p=fW("x",e,t,n),h=fW("indices",e,t,n);return[r.gather(p,r.cast(h,"int32"),l,c)];case"Reverse":for(var d=fW("dims",e,t,n),f=[],m=0;m<d.length;m++)d[m]&&f.push(m);var v=fW("x",e,t,n);return[r.reverse(v,f)];case"ReverseV2":var g=fW("axis",e,t,n),y=fW("x",e,t,n);return[r.reverse(y,g)];case"Slice":var b=fW("begin",e,t,n),x=fW("size",e,t,n);return[r.slice(fW("x",e,t,n),b,x)];case"StridedSlice":var w=fW("begin",e,t,n),k=fW("end",e,t,n),N=fW("strides",e,t,n),I=fW("beginMask",e,t,n),S=fW("endMask",e,t,n),T=fW("ellipsisMask",e,t,n),C=fW("newAxisMask",e,t,n),E=fW("shrinkAxisMask",e,t,n),A=fW("x",e,t,n);return[r.stridedSlice(A,w,k,N,I,S,T,C,E)];case"Pack":return eI((function(){var a=fW("axis",e,t,n),i=fW("tensors",e,t,n),o=i[0].shape,s=r.squeeze(i[0]).shape,u=i.map((function(e){var t=Yv(e.shape,o);if(!t&&!Yv(r.squeeze(e).shape,s))throw new Error("the input tensors shape does not match");return t?e:r.reshape(e,o)}));return[r.stack(u,a)]}));case"Unpack":var R=fW("axis",e,t,n),_=fW("tensor",e,t,n);return r.unstack(_,R);case"Tile":var F=fW("reps",e,t,n);return[r.tile(fW("x",e,t,n),F)];case"Split":case"SplitV":var O=fW("axis",e,t,n),D=fW("numOrSizeSplits",e,t,n),M=fW("x",e,t,n);return r.split(M,D,O);case"ScatterNd":var L=fW("indices",e,t,n),z=fW("values",e,t,n),P=fW("shape",e,t,n);return[r.scatterND(L,z,P)];case"GatherNd":var B=fW("x",e,t,n),W=fW("indices",e,t,n);return[r.gatherND(B,W)];case"SparseToDense":var V=fW("sparseIndices",e,t,n),U=fW("outputShape",e,t,n),G=fW("sparseValues",e,t,n),j=fW("defaultValue",e,t,n);return[r.sparseToDense(V,G,U,G.dtype===j.dtype?j:r.cast(j,G.dtype))];case"TensorScatterUpdate":var H=fW("indices",e,t,n),q=fW("values",e,t,n),K=fW("tensor",e,t,n);return[r.tensorScatterUpdate(K,H,q)];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"sparse":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"SparseFillEmptyRows":var a=r.sparse.sparseFillEmptyRows(fW("indices",e,t,n),fW("values",e,t,n),fW("denseShape",e,t,n),fW("defaultValue",e,t,n));return[a.outputIndices,a.outputValues,a.emptyRowIndicator,a.reverseIndexMap];case"SparseReshape":var i=r.sparse.sparseReshape(fW("inputIndices",e,t,n),fW("inputShape",e,t,n),fW("newShape",e,t,n));return[i.outputIndices,i.outputShape];case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(fW("data",e,t,n),fW("indices",e,t,n),fW("segmentIds",e,t,n))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(fW("data",e,t,n),fW("indices",e,t,n),fW("segmentIds",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"spectral":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"FFT":return[r.fft(fW("x",e,t,n))];case"IFFT":return[r.ifft(fW("x",e,t,n))];case"RFFT":return[r.rfft(fW("x",e,t,n))];case"IRFFT":return[r.irfft(fW("x",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"string":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"StaticRegexReplace":return[r.string.staticRegexReplace(fW("input",e,t,n),fW("pattern",e,t,n),fW("rewrite",e,t,n),fW("replaceGlobal",e,t,n))];case"StringNGrams":var a=r.string.stringNGrams(fW("data",e,t,n),fW("dataSplits",e,t,n),fW("separator",e,t,n),fW("nGramWidths",e,t,n),fW("leftPad",e,t,n),fW("rightPad",e,t,n),fW("padWidth",e,t,n),fW("preserveShortSequences",e,t,n));return[a.nGrams,a.nGramsSplits];case"StringSplit":var i=r.string.stringSplit(fW("input",e,t,n),fW("delimiter",e,t,n),fW("skipEmpty",e,t,n));return[i.indices,i.values,i.shape];case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(fW("input",e,t,n),fW("numBuckets",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"transformation":return a((function(){return function(e,t,n,r){switch(void 0===r&&(r=rV),e.op){case"Cast":return[r.cast(fW("x",e,t,n),fW("dtype",e,t,n))];case"ExpandDims":var a=fW("axis",e,t,n);return[r.expandDims(fW("x",e,t,n),a)];case"Squeeze":var i=fW("axis",e,t,n);return[r.squeeze(fW("x",e,t,n),i)];case"Reshape":return[r.reshape(fW("x",e,t,n),fW("shape",e,t,n))];case"MirrorPad":return[r.mirrorPad(fW("x",e,t,n),fW("padding",e,t,n),fW("mode",e,t,n))];case"PadV2":case"Pad":return[r.pad(fW("x",e,t,n),fW("padding",e,t,n),fW("constantValue",e,t,n))];case"SpaceToBatchND":var o=fW("blockShape",e,t,n),s=fW("paddings",e,t,n);return[r.spaceToBatchND(fW("x",e,t,n),o,s)];case"BatchToSpaceND":var u=fW("blockShape",e,t,n),l=fW("crops",e,t,n);return[r.batchToSpaceND(fW("x",e,t,n),u,l)];case"DepthToSpace":var c=fW("blockSize",e,t,n),p=fW("dataFormat",e,t,n).toUpperCase();return[r.depthToSpace(fW("x",e,t,n),c,p)];case"BroadcastTo":return[r.broadcastTo(fW("x",e,t,n),fW("shape",e,t,n))];case"BroadcastArgs":return[r.broadcastArgs(fW("s0",e,t,n),fW("s1",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"hash_table":return bV(e,t,n,r);case"custom":var i=dW(e.op);if(i&&i.customExecutor)return i.customExecutor(new nV(e,t,n));throw TypeError("Custom op "+e.op+" is not registered.");default:throw TypeError("Unknown op '"+e.op+"'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()")}}(e,t,n);return Tg(i)?i.then((function(e){return[].concat(e)})):[].concat(i)}var wV=function(){function e(e,t,n,r,a){void 0===e&&(e={}),void 0===t&&(t={}),void 0===n&&(n={}),void 0===r&&(r={}),this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.parseNodeNameCache=a,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}var t=e.prototype;return t.newFrame=function(e,t){return{id:e,frameName:t,iterationId:0}},t.generateCurrentContextIds=function(){for(var e=[],t=0;t<this.contexts.length-1;t++){var n=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(n))}e.push(""),this._currentContextIds=e},t.contextIdforContexts=function(e){return e?e.map((function(e){return 0===e.id&&0===e.iterationId?"":e.frameName+"-"+e.iterationId})).join("/"):""},t.enterFrame=function(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))},t.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()},t.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 e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))},t.getWeight=function(e){return this.weightMap[e]},t.addTensorArray=function(e){this.tensorArrayMap[e.id]=e},t.getTensorArray=function(e){return this.tensorArrayMap[e]},t.addTensorList=function(e){this.tensorListMap[e.id]=e},t.getTensorList=function(e){return this.tensorListMap[e]},t.dispose=function(e){for(var t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(var n in this.tensorListMap)this.tensorListMap[n].clearAndClose(e)},Tv(e,[{key:"currentContext",get:function(){return this.contexts},set:function(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}},{key:"currentContextId",get:function(){return this._currentContextIds[0]}},{key:"currentContextIds",get:function(){return this._currentContextIds}}]),e}();function kV(e,t,n,r){var a=new Set,i=[],o=null,s=null,u=new Set,l=new Set(Object.keys(e).map((function(e){return bW(e)[0]})));r=r||[];for(var c=new Set(r.map((function(e){return bW(e.name)[0]}))),p=[].concat(t);p.length>0;){var h=p.pop();(EV(h)||AV(h)||RV(h))&&null==o&&(s=(o=h).children.map((function(e){return e.name})).filter((function(e){return a.has(e)}))),a.add(h.name),null==n[h.name]&&(l.has(h.name)||c.has(h.name)||(0!==h.inputs.length?h.inputs.forEach((function(e){u.has(e.name)||(u.add(e.name),p.push(e))})):i.push(h.name)))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:i,dynamicNode:o,syncInputs:s}}function NV(e,t){var n=t.usedNodes,r=t.inputs,a=Object.keys(r).map((function(e){return bW(e)[0]})).map((function(t){return e.nodes[t]})),i=e.initNodes||[],o=function(e){return n.has("string"==typeof e?e:e.name)};function s(e){return[].concat(new Map(e.map((function(e){return[e.name,e]}))).values())}for(var u,l=s([].concat(a,e.weights,i)).filter(o),c=s([].concat(l,Object.values(e.nodes))).filter(o),p=new Map(c.map((function(e){return[e.name,e]}))),h={},d=Lv(c);!(u=d()).done;){var f=u.value;h[f.name]=h[f.name]||0;for(var m,v=Lv(f.children);!(m=v()).done;){var g=m.value;o(g)||(h[g.name]=Number.POSITIVE_INFINITY),h[g.name]=(h[g.name]||0)+1}}for(var y=Object.entries(h).filter((function(e){return 0===e[1]})).map((function(e){return e[0]})),b=[].concat(y);y.length>0;)for(var x,w=y.pop(),k=Lv(p.get(w).children.filter(o));!(x=k()).done;){var N=x.value;0==--h[N.name]&&(b.push(N.name),y.push(N.name))}var I=function(e,t){var n=new Map(e.map((function(e){return[e.name,e]}))),r=t.map((function(e){return e.name})),a=new Set(r);for(;r.length>0;)for(var i,o=r.pop(),s=Lv(n.get(o).children);!(i=s()).done;){var u=i.value;n.has(u.name)&&!a.has(u.name)&&(a.add(u.name),r.push(u.name))}var l=e.filter((function(e){return a.has(e.name)}));return l}(b.map((function(e){return p.get(e)})),l);return function(e,t){for(var n,r=new Map(e.map((function(e,t){return[e.name,t]}))),a=new Set(t.map((function(e){return e.name}))),i=function(e){return a.has("string"==typeof e?e:e.name)},o=new Set(e.map((function(e){return e.name}))),s=function(e){return o.has("string"==typeof e?e:e.name)},u=Lv(e);!(n=u()).done;){for(var l,c=n.value,p=Lv(c.children.filter(s));!(l=p()).done;){var h=l.value;if(!r.has(h.name))throw new IV("Child "+h.name+" of node "+c.name+" is unreachable.");if(r.get(c.name)>r.get(h.name))throw new IV("Node "+c.name+" is scheduled to run after its child "+h.name+".")}if(!i(c))for(var d,f=Lv(c.inputs);!(d=f()).done;){var m=d.value;if(!r.has(m.name))throw new IV("Input "+m.name+" of node "+c.name+" is unreachable.");if(r.get(m.name)>r.get(c.name))throw new IV("Node "+c.name+" is scheduled to run before its input "+m.name+".")}}}(I,l),I}var IV=function(e){function t(t){return e.call(this,"NodesExecutionOrderError: "+t)||this}return Cv(t,e),t}(Fv(Error));var SV=new Set(["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"]),TV=new Set(["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"]),CV=new Set(["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"]);function EV(e){return SV.has(e.op)}function AV(e){return TV.has(e.op)}function RV(e){return CV.has(e.op)}var _V=function(){function e(t,n){var r=this;this.graph=t,this.parent=n,this.compiledMap=new Map,this.parseNodeNameCache=new Map,this._weightMap={},this.SEPARATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=t.outputs,this._inputs=t.inputs,this._initNodes=t.initNodes,this._signature=t.signature,this._functions=t.functions,null!=t.functions&&Object.keys(t.functions).forEach((function(n){r._functionExecutorMap[n]=new e(t.functions[n],r)}))}var t=e.prototype;return t.getCompilationKey=function(e,t){var n=e.map((function(e){return e.name})).sort(),r=t.map((function(e){return e.name})).sort();return n.join(this.SEPARATOR)+"--"+r.join(this.SEPARATOR)},t.compile=function(e,t){var n=kV(e,t,this.weightMap,this._initNodes),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=t.map((function(e){return e.name})),s=Object.keys(e);throw new Error("Cannot compute the outputs ["+o+"] from the provided inputs ["+s+"]. Missing the following inputs: ["+r+"]")}var u=NV(this.graph,n),l=function(e){for(var t=new Map(e.map((function(e,t){return[e.name,t]}))),n=Number.MAX_SAFE_INTEGER,r=e.map((function(e,t){return EV(e)?n:t})),a=function(e){var n=r[t.get(e.name)];return null==n?-1:n},i=e.map((function(e,t){return e.children.map(a).reduce((function(e,t){return Math.max(e,t)}),r[t])})),o=new Map,s=0;s<e.length;++s){var u=i[s];if(u!==n){var l=e[s],c=e[u];o.has(c.name)||o.set(c.name,[]),o.get(c.name).push(l.name)}}return o}(u);return{orderedNodes:u,nodeLiveUntilMap:l}},t.cloneAndKeepTensor=function(e){if(null==e)return null;var t=e.clone();return nI(t),t},t.cloneTensorList=function(e){var t=this;if(!e)return null;var n=e.map((function(e){return t.cloneAndKeepTensor(e)}));return n},t.cloneTensorMap=function(e){var t=this;return Object.fromEntries(Object.entries(e).map((function(e){var n=e[0],r=e[1];return[n,t.cloneTensorList(r)]})))},t.execute=function(e,t){var n=this;this.disposeIntermediateTensors(),e=this.mapInputs(e);var r=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);var a=r.map((function(e){return n.graph.nodes[bW(e)[0]]})),i=t.map((function(e){return bW(e)[0]})),o=new Set(i),s=i.map((function(e){return n.graph.nodes[e]}));0===s.length&&(s=this._outputs);var u=this.getCompilationKey(a,s),l=this.compiledMap.get(u);null==l&&(l=this.compile(e,s),this.compiledMap.set(u,l));try{this.keepIntermediateTensors=Fg().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}var c={},p={};return eI((function(){var r=new wV(n.weightMap,c,p,n.functionExecutorMap,n.parseNodeNameCache),a=Object.assign({},n.weightMap);n.keepIntermediateTensors&&(n.clonedTensorsMap=n.cloneTensorMap(n.weightMap)),Object.keys(e).forEach((function(t){var i=bW(t,r),o=i[0],s=[];s[i[1]]=e[t],a[o]=s,n.keepIntermediateTensors&&(n.clonedTensorsMap[o]=n.cloneTensorList(s))}));for(var i,s=n.getFrozenTensorIds(a),u=l,h=u.orderedNodes,d=u.nodeLiveUntilMap,f=Lv(h);!(i=f()).done;){var m=i.value;if(!a[m.name]){var v=xV(m,a,r,n._resourceManager);if(Tg(v))throw new Error("The execution of the op '"+m.op+"' returned a promise. Please use model.executeAsync() instead.");a[m.name]=v,n.keepIntermediateTensors&&(n.clonedTensorsMap[m.name]=n.cloneTensorList(v)),n.checkTensorForDisposalWithNodeLiveUntilInfo(m,a,r,s,o,d.get(m.name))}}return null==n.parent&&r.dispose(s),t.map((function(e){return mW(e,a,r)}))}))},t.getFrozenTensorIds=function(e){var t=[].concat.apply([],Object.keys(e).map((function(t){return e[t]})).map((function(e){return e.map((function(e){return e.id}))})));return new Set(t)},t.checkTensorForDisposal=function(e,t,n,r,a,i,o){if(!EV(t)&&!i.has(e)){for(var s,u=Lv(n[e]);!(s=u()).done;){var l=s.value;null!=l&&(o[l.id]=(o[l.id]||0)+t.children.length)}for(var c,p=Lv(t.inputs);!(c=p()).done;){var h=c.value;if(!EV(h)){var d=vW(h.name,n,r);if(null!=d)for(var f,m=Lv(d);!(f=m()).done;){var v=f.value;if(v&&!v.kept&&!a.has(v.id)){var g=o[v.id];1===g?(v.dispose(),delete o[v.id]):null!=g&&o[v.id]--}}}}}},t.checkTensorForDisposalWithNodeLiveUntilInfo=function(e,t,n,r,a,i){if(!EV(e)&&!a.has(e.name)&&null!=i)for(var o,s=Lv(i);!(o=s()).done;)for(var u,l=Lv(vW(o.value,t,n));!(u=l()).done;){var c=u.value;!c||c.kept||r.has(c.id)||c.dispose()}},t.executeAsync=function(){var e=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._executeAsync(t,n));case 1:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.disposeIntermediateTensors=function(){this.clonedTensorsMap&&(Object.values(this.clonedTensorsMap).forEach((function(e){for(var t,n=Lv(e);!(t=n()).done;){var r=t.value;r&&!r.isDisposed&&r.dispose()}})),this.clonedTensorsMap=null)},t.getIntermediateTensors=function(){return this.clonedTensorsMap},t._executeAsync=function(){var e=Iv(kv().mark((function e(t,n,r,a,i){var o,s,u,l,c,p;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:void 0===r&&(r=!1),void 0===a&&(a={}),void 0===i&&(i={}),this.disposeIntermediateTensors(),r||(t=this.mapInputs(t),this.checkInputs(t),this.checkInputShapeAndType(t),n=this.mapOutputs(n),this.checkOutputs(n));try{this.keepIntermediateTensors=Fg().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}return o=new wV(this.weightMap,a,i,this.functionExecutorMap,this.parseNodeNameCache),this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),e.next=10,this.executeWithControlFlow(t,o,n,r);case 10:return s=e.sent,u=n.map((function(e){return mW(e,s,o)})),l=u.map((function(e){return e.id})),c=Object.keys(t).map((function(e){return t[e].id})),p=new Set([].concat(l,c,this.weightIds)),Object.values(s).forEach((function(e){e.forEach((function(e){!e||e.isDisposed||p.has(e.id)||e.dispose()}))})),null==this.parent&&o.dispose(p),e.abrupt("return",u);case 18:case"end":return e.stop()}}),e,this)})));return function(t,n,r,a,i){return e.apply(this,arguments)}}(),t.executeFunctionAsync=function(){var e=Iv(kv().mark((function e(t,n,r){var a,i=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.reduce((function(e,t,n){return e[i.inputs[n].name]=t,e}),{}),e.abrupt("return",this._executeAsync(a,this.outputNodes,!0,n,r));case 2:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.executeWithControlFlow=function(){var e=Iv(kv().mark((function e(t,n,r,a){var i,o,s,u,l,c,p,h,d,f,m,v,g,y,b,x,w,k,N=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=Object.keys(t),o=i.map((function(e){return N.graph.nodes[bW(e)[0]]})),s=r.map((function(e){return bW(e)[0]})),u=new Set(s),0===(l=s.map((function(e){return N.graph.nodes[e]}))).length&&(l=this._outputs),c=kV(t,l,this.weightMap,this._initNodes),p=c.usedNodes,h=c.missingInputs,d=c.dynamicNode,f=c.syncInputs,m=[].concat(o,this.graph.weights,this._initNodes||[]).map((function(e){return{node:e,contexts:n.currentContext}})),v=Object.assign({},this.weightMap),Object.keys(t).forEach((function(e){var n=bW(e),r=n[0],a=[];a[n[1]]=t[e],v[r]=a})),g={},y=this.getFrozenTensorIds(v),b={};case 13:if(!(m.length>0)){e.next=19;break}return x=this.processStack(o,m,n,v,b,y,u,g,p),e.next=17,Promise.all(x);case 17:e.next=13;break;case 19:if(null!=d||a||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."),w=l.filter((function(e){return!EV(e)&&!mW(e.name,v,n)})).map((function(e){return e.name})),!(w.length>0)){e.next=25;break}throw k="",null!=d&&(k="Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs ["+f+"]"),new Error("Cannot compute the outputs ["+w+"] from the provided inputs ["+i+"]. Consider providing the following inputs: ["+h+"]. "+k);case 25:return e.abrupt("return",v);case 26:case"end":return e.stop()}}),e,this)})));return function(t,n,r,a){return e.apply(this,arguments)}}(),t.processStack=function(e,t,n,r,a,i,o,s,u){for(var l=this,c=[],p=function(){var e=t.pop();n.currentContext=e.contexts;var p="";if("Enter"===e.node.op&&fW("isConstant",e.node,r,n)){var h=gW(e.node.name,n);p=h[0]}if(null==r[e.node.name]){var d=xV(e.node,r,n,l._resourceManager);if(!p){var f=gW(e.node.name,n);p=f[0]}var m=n.currentContext;Tg(d)?c.push(d.then((function(c){return r[p]=c,l.keepIntermediateTensors&&(l.clonedTensorsMap[p]=l.cloneTensorList(c)),n.currentContext=m,l.checkTensorForDisposal(p,e.node,r,n,i,o,s),l.processChildNodes(e.node,t,n,r,a,u),c}))):(r[p]=d,l.keepIntermediateTensors&&(l.clonedTensorsMap[p]=l.cloneTensorList(d)),l.checkTensorForDisposal(p,e.node,r,n,i,o,s),l.processChildNodes(e.node,t,n,r,a,u))}else l.processChildNodes(e.node,t,n,r,a,u)};t.length>0;)p();return c},t.processChildNodes=function(e,t,n,r,a,i){e.children.forEach((function(e){var o=gW(e.name,n)[0];!a[o]&&i.has(e.name)&&("Merge"===e.op?e.inputNames.some((function(e){return!!mW(e,r,n)}))&&(a[o]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((function(e){return!!mW(e,r,n)}))&&(a[o]=!0,t.push({contexts:n.currentContext,node:e})))}))},t.dispose=function(){var e=this;Object.keys(this.weightMap).forEach((function(t){return e.weightMap[t].forEach((function(e){return e.dispose()}))}))},t.checkInputShapeAndType=function(e){var t=this;Object.keys(e).forEach((function(n){var r=e[n],a=bW(n)[0],i=t.graph.nodes[a];if(i.attrParams.shape&&i.attrParams.shape.value){var o=i.attrParams.shape.value,s=o.length===r.shape.length&&r.shape.every((function(e,t){return-1===o[t]||o[t]===e}));Hv(s,(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&&Hv(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}))}))},t.mapInputs=function(e){var t,n,r={};for(var a in e){var i=null===(n=null===(t=this._signature)||void 0===t?void 0:t.inputs)||void 0===n?void 0:n[a];null!=i?r[i.name]=e[a]:r[a]=e[a]}return r},t.checkInputs=function(e){var t=this,n=Object.keys(e).filter((function(e){var n=bW(e)[0];return null==t.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")},t.mapOutputs=function(e){var t=this;return e.map((function(e){var n,r,a=null===(r=null===(n=t._signature)||void 0===n?void 0:n.outputs)||void 0===r?void 0:r[e];return null!=a?a.name:e}),{})},t.checkOutputs=function(e){var t=this;e.forEach((function(e){var n=bW(e)[0];if(!t.graph.nodes[n])throw new Error("The output '"+e+"' is not found in the graph")}))},Tv(e,[{key:"weightIds",get:function(){return this.parent?this.parent.weightIds:this._weightIds}},{key:"functionExecutorMap",get:function(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}},{key:"weightMap",get:function(){return this.parent?this.parent.weightMap:this._weightMap},set:function(e){var t,n=Object.keys(e).map((function(t){return e[t].map((function(e){return e.id}))}));this._weightIds=(t=[]).concat.apply(t,n),this._weightMap=e}},{key:"resourceManager",set:function(e){this._resourceManager=e}},{key:"inputs",get:function(){return this._inputs.map((function(e){return{name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}}))}},{key:"outputs",get:function(){return this._outputs.map((function(e){return{name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}}))}},{key:"inputNodes",get:function(){return this._inputs.map((function(e){return e.signatureKey||e.name}))}},{key:"outputNodes",get:function(){return this._outputs.map((function(e){var t=e.signatureKey||e.name;return e.defaultOutput?t+":"+e.defaultOutput:t}))}},{key:"functions",get:function(){var e=this;return Object.keys(this._functions).reduce((function(t,n){return t[n]=e._functions[n].signature,t}),{})}}]),e}(),FV=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.hashTableNameToHandle=e,this.hashTableMap=t}var t=e.prototype;return t.addHashTable=function(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t},t.getHashTableHandleByName=function(e){return this.hashTableNameToHandle[e]},t.getHashTableById=function(e){return this.hashTableMap[e]},t.dispose=function(){for(var e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(var t in this.hashTableNameToHandle)this.hashTableNameToHandle[t].dispose(),delete this.hashTableNameToHandle[t]},e}(),OV=function(){function e(e,t,n){void 0===t&&(t={}),void 0===n&&(n=GR),this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=n,null==t&&(this.loadOptions={}),this.resourceManager=new FV}var t=e.prototype;return t.findIOHandler=function(){var e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{var t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error("Found more than one ("+t.length+") load handlers for URL '"+[e]+"'");this.handler=t[0]}},t.load=function(){var e=this;if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");var t=this.handler.load();return Tg(t)?t.then((function(t){return e.loadSync(t)})):this.loadSync(t)},t.loadSync=function(e){this.artifacts=e;var t=this.artifacts.modelTopology,n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){var r=this.artifacts.userDefinedMetadata;null!=r.signature&&(n=r.signature),null!=r.structuredOutputKeys&&(this.structuredOutputKeys=r.structuredOutputKeys)}this.signature=n,this.version=t.versions.producer+"."+t.versions.minConsumer;var a=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new _V(VW.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(a),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){var i=VW.Instance.transformGraph(e.modelInitializer);this.initializer=new _V(i),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=e.initializerSignature}return!0},t.save=function(){var e=Iv(kv().mark((function e(t,n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=9;break}if(0!==(r=this.io.getSaveHandlers(t)).length){e.next=6;break}throw new Error("Cannot find any save handlers for URL '"+t+"'");case 6:if(!(r.length>1)){e.next=8;break}throw new Error("Found more than one ("+r.length+") save handlers for URL '"+t+"'");case 8:t=r[0];case 9:if(null!=t.save){e.next=11;break}throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");case 11:return e.abrupt("return",t.save(this.artifacts));case 12:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.addStructuredOutputNames=function(e){var t=this;if(this.structuredOutputKeys){var n={};return(e instanceof ak?[e]:e).forEach((function(e,r){return n[t.structuredOutputKeys[r]]=e})),n}return e},t.predict=function(e,t){var n=this.execute(e,this.outputNodes);return this.addStructuredOutputNames(n)},t.predictAsync=function(){var e=Iv(kv().mark((function e(t,n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeAsync(t,this.outputNodes);case 2:return r=e.sent,e.abrupt("return",this.addStructuredOutputNames(r));case 4:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.normalizeInputs=function(e){var t,n=this;if(!(e instanceof ak||Array.isArray(e))){var r=null===(t=this.signature)||void 0===t?void 0:t.inputs;if(null!=r)for(var a in r){var i=r[a];null!=i.resourceId&&(e[a]=this.resourceIdToCapturedInput[i.resourceId])}return e}e=Array.isArray(e)?e:[e];var o=Object.keys(this.resourceIdToCapturedInput).length;if(e.length+o!==this.inputNodes.length)throw new Error("Input tensor count mismatch, the graph model has "+(this.inputNodes.length-o)+" non-resource placeholders, while there are "+e.length+" input tensors provided.");var s=0;return this.inputNodes.reduce((function(t,r){var a,i,o,u=null===(o=null===(i=null===(a=n.signature)||void 0===a?void 0:a.inputs)||void 0===i?void 0:i[r])||void 0===o?void 0:o.resourceId;return t[r]=null!=u?n.resourceIdToCapturedInput[u]:e[s++],t}),{})},t.normalizeOutputs=function(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]},t.executeInitializerGraph=function(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))},t.executeInitializerGraphAsync=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.initializer){e.next=2;break}return e.abrupt("return",[]);case 2:if(null!=this.initializerSignature){e.next=6;break}return e.abrupt("return",this.initializer.executeAsync({},[]));case 6:return e.abrupt("return",this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs)));case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setResourceIdToCapturedInput=function(e){if(this.resourceIdToCapturedInput={},this.initializerSignature)for(var t=this.initializerSignature.outputs,n=Object.keys(t),r=0;r<n.length;r++){var a=t[n[r]];this.resourceIdToCapturedInput[a.resourceId]=e[r]}},t.execute=function(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);var n=this.executor.execute(e,t);return n.length>1?n:n[0]},t.executeAsync=function(){var e=Iv(kv().mark((function e(t,n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.resourceIdToCapturedInput){e.next=6;break}return e.t0=this,e.next=4,this.executeInitializerGraphAsync();case 4:e.t1=e.sent,e.t0.setResourceIdToCapturedInput.call(e.t0,e.t1);case 6:return t=this.normalizeInputs(t),n=this.normalizeOutputs(n),e.next=10,this.executor.executeAsync(t,n);case 10:return r=e.sent,e.abrupt("return",r.length>1?r:r[0]);case 12:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.getIntermediateTensors=function(){return this.executor.getIntermediateTensors()},t.disposeIntermediateTensors=function(){this.executor.disposeIntermediateTensors()},t.convertTensorMapToTensorsMap=function(e){return Object.keys(e).reduce((function(t,n){return t[n]=[e[n]],t}),{})},t.dispose=function(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&tI(this.resourceIdToCapturedInput)),this.resourceManager.dispose()},Tv(e,[{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}},{key:"metadata",get:function(){return this.artifacts.userDefinedMetadata}},{key:"modelSignature",get:function(){return this.signature}},{key:"modelStructuredOutputKeys",get:function(){return this.structuredOutputKeys}}]),e}();function DV(){return DV=Iv(kv().mark((function e(t,n,r){var a;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n={}),void 0===r&&(r=GR),null!=t){e.next=4;break}throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");case 4:return null==n&&(n={}),n.fromTFHub&&"string"==typeof t&&(t=MV(t)),a=new OV(t,n,r),e.next=9,a.load();case 9:return e.abrupt("return",a);case 10:case"end":return e.stop()}}),e)}))),DV.apply(this,arguments)}function MV(e){return e.endsWith("/")||(e+="/"),e+"model.json?tfjs-format=file"}var LV="4.3.0";function zV(e,t,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==e)return null;if("function"==typeof Blob&&e instanceof Blob)return e.slice();if(r.has(e))throw new Error("Circular references are not supported.");if(n.has(e))return n.get(e);var a=t(e);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(GV(e)){var i=Array.isArray(e)?[]:{};for(var o in r.add(e),e){var s=zV(e[o],t,n,r);i[o]=s}return r.delete(e),e.__proto__&&(i.__proto__=e.__proto__),i}throw new Error("Can't recurse into non-iterable type: "+e)}return n.set(e,a.value),a.value}function PV(e,t){return void 0===t&&(t=WV),BV(e,t)}function BV(e,t,n){void 0===n&&(n=new Set);var r=e[0];if(n.has(r))throw new Error("Circular references are not supported.");var a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(a.recurse){if(GV(r)){var i=Array.isArray(r)?[]:{};n.add(r);var o=function(r){var a=BV(e.map((function(e){return e[r]})),t,n);i[r]=a};for(var s in r)o(s);return n.delete(r),i}throw new Error("Can't recurse into non-iterable type: "+r)}return a.value}function WV(e){return null===e?null:GV(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}function VV(e,t){return UV.apply(this,arguments)}function UV(){return UV=Iv(kv().mark((function e(t,n){var r,a,i,o,s,u,l;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Map,zV(t,n,r),a=0,i=Array.from(r.keys());case 3:if(!(a<i.length)){e.next=14;break}if(o=i[a],!Tg(s=r.get(o))){e.next=11;break}return e.next=9,s;case 9:u=e.sent,r.set(o,u);case 11:a++,e.next=3;break;case 14:return l=zV(t,n,r),e.abrupt("return",l);case 16:case"end":return e.stop()}}),e)}))),UV.apply(this,arguments)}function GV(e){var t=!1;Fg().get("IS_BROWSER")?t=e instanceof TextDecoder:t=e instanceof require("string_decoder").StringDecoder;return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof ak)&&!(e instanceof Promise)&&!t)}function jV(e){return function(e,t){return zV(e,t)}(e,HV)}function HV(e){return e instanceof ak?{value:e.clone(),recurse:!1}:GV(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}var qV=function(){function e(e){if(this.capacity=e,this.begin=0,this.end=0,null==e)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(e),this.doubledCapacity=2*e}var t=e.prototype;return t.wrap=function(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity},t.get=function(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]},t.set=function(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t},t.length=function(){var e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e},t.isFull=function(){return this.length()===this.capacity},t.isEmpty=function(){return 0===this.length()},t.push=function(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)},t.pushAll=function(e){for(var t,n=Lv(e);!(t=n()).done;){var r=t.value;this.push(r)}},t.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var e=this.get(this.end);return this.set(this.end,void 0),e},t.unshift=function(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)},t.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e},t.shuffleExcise=function(e){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.wrap(this.begin+e),n=this.get(t);return this.set(t,this.pop()),n},e}(),KV=function(e){function t(){return e.call(this,t.INITIAL_CAPACITY)||this}Cv(t,e);var n=t.prototype;return n.isFull=function(){return!1},n.push=function(t){e.prototype.isFull.call(this)&&this.expand(),e.prototype.push.call(this,t)},n.unshift=function(t){e.prototype.isFull.call(this)&&this.expand(),e.prototype.unshift.call(this,t)},n.expand=function(){for(var e=2*this.capacity,t=new Array(e),n=this.length(),r=0;r<n;r++)t[r]=this.get(this.wrap(this.begin+r));this.data=t,this.capacity=e,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},t}(qV);function XV(e){return new eU(e)}function YV(e){return new tU(e)}function JV(e,t){return new hU(e,t)}function ZV(e,t){return void 0===t&&(t=QV.FAIL),new dU(e,t)}KV.INITIAL_CAPACITY=32;var QV,$V=function(){function e(){}var t=e.prototype;return t.toArray=function(){var e=Iv(kv().mark((function e(){var t,n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,this.next();case 3:n=e.sent;case 4:if(n.done){e.next=11;break}return t.push(n.value),e.next=8,this.next();case 8:n=e.sent,e.next=4;break;case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.toArrayForTest=function(){var e=Iv(kv().mark((function e(){var t,n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.prefetch(100),n=[],e.next=4,t.next();case 4:r=e.sent;case 5:if(r.done){e.next=12;break}return n.push(r.value),e.next=9,t.next();case 9:r=e.sent,e.next=5;break;case 12:return e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.resolveFully=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.next();case 2:t=e.sent;case 3:if(t.done){e.next=9;break}return e.next=6,this.next();case 6:t=e.sent,e.next=3;break;case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.resolveWhile=function(){var e=Iv(kv().mark((function e(t){var n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.next();case 2:n=e.sent,r=t(n.value);case 4:if(n.done||!r){e.next=11;break}return e.next=7,this.next();case 7:n=e.sent,r=t(n.value),e.next=4;break;case 11:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.handleErrors=function(e){return new uU(this,e)},t.filter=function(e){return new oU(this,e)},t.map=function(e){return new sU(this,e)},t.mapAsync=function(e){return new lU(this,e)},t.serialMapAsync=function(e){return new lU(this,e).serial()},t.flatmap=function(e){return new pU(this,e)},t.forEachAsync=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.map(t).resolveFully());case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.serialForEach=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.serialMapAsync(t).resolveWhile((function(e){return!0===e})));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.rowMajorBatch=function(e,t){return void 0===t&&(t=!0),new iU(this,e,t)},t.columnMajorBatch=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=WV),this.rowMajorBatch(e,t).map((function(e){return PV(e,n)}))},t.concatenate=function(e,t){return new hU(XV([this,e]),t)},t.take=function(e){return e<0||null==e?this:new aU(this,e)},t.skip=function(e){return e<0||null==e?this:new rU(this,e)},t.prefetch=function(e){return new fU(this,e)},t.shuffle=function(e,t){return new mU(this,e,t)},t.serial=function(){return new nU(this)},e}(),eU=function(e){function t(t){var n;return(n=e.call(this)||this).items=t,n.trav=0,n}Cv(t,e);var n=t.prototype;return n.summary=function(){return"Array of "+this.items.length+" items"},n.next=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.trav>=this.items.length)){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:return t=this.items[this.trav],this.trav++,e.abrupt("return",{value:jV(t),done:!1});case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),tU=function(e){function t(t){var n;return(n=e.call(this)||this).nextFn=t,n}Cv(t,e);var n=t.prototype;return n.summary=function(){return"Function call"},n.next=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.abrupt("return",this.nextFn());case 4:throw e.prev=4,e.t0=e.catch(0),e.t0.message="Error thrown while iterating through a dataset: "+e.t0.message,e.t0;case 8:case"end":return e.stop()}}),e,this,[[0,4]])})));return function(){return e.apply(this,arguments)}}(),t}($V),nU=function(e){function t(t){var n;return(n=e.call(this)||this).upstream=t,n.lastRead=Promise.resolve({value:null,done:!1}),n}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Serial"},n.next=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.upstream.next());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),rU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Skip"},n.next=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.count++<this.maxCount)){e.next=9;break}return e.next=3,this.upstream.next();case 3:if(!(t=e.sent).done){e.next=6;break}return e.abrupt("return",t);case 6:tI(t.value),e.next=0;break;case 9:return e.abrupt("return",this.upstream.next());case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),aU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.maxCount=n,r.count=0,r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Take"},n.next=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.count++>=this.maxCount)){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:return e.abrupt("return",this.upstream.next());case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),iU=function(e){function t(t,n,r){var a;return void 0===r&&(r=!0),(a=e.call(this)||this).upstream=t,a.batchSize=n,a.enableSmallLastBatch=r,a.lastRead=Promise.resolve({value:null,done:!1}),a}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},n.next=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Iv(kv().mark((function e(){var t,n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[];case 1:if(!(t.length<this.batchSize)){e.next=12;break}return e.next=4,this.upstream.next();case 4:if(!(n=e.sent).done){e.next=9;break}if(!(this.enableSmallLastBatch&&t.length>0)){e.next=8;break}return e.abrupt("return",{value:t,done:!1});case 8:return e.abrupt("return",{value:null,done:!0});case 9:t.push(n.value),e.next=1;break;case 12:return e.abrupt("return",{value:t,done:!1});case 13:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),oU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Filter"},n.next=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,this.upstream.next();case 3:if(!(t=e.sent).done&&!this.predicate(t.value)){e.next=6;break}return e.abrupt("return",t);case 6:tI(t.value),e.next=0;break;case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),sU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.transform=n,r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Map"},n.next=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o,s;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=5;break}return e.abrupt("return",{value:null,done:!0});case 5:for(n=xk(t.value),r=this.transform(t.value),a=xk(r),i=Lv(n);!(o=i()).done;)bk(s=o.value,a)||s.dispose();return e.abrupt("return",{value:r,done:!1});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),uU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> handleErrors"},n.next=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=1,e.next=4,this.upstream.next();case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(1),this.handler(e.t0)){e.next=11;break}return e.abrupt("return",{value:null,done:!0});case 11:e.next=0;break;case 13:case"end":return e.stop()}}),e,this,[[1,7]])})));return function(){return e.apply(this,arguments)}}(),t}($V),lU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.transform=n,r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> AsyncMap"},n.next=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o,s;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=5;break}return e.abrupt("return",{value:null,done:!0});case 5:return n=xk(t.value),e.next=8,this.transform(t.value);case 8:for(r=e.sent,a=xk(r),i=Lv(n);!(o=i()).done;)bk(s=o.value,a)||s.dispose();return e.abrupt("return",{value:r,done:!1});case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),cU=function(e){function t(){var t;return(t=e.call(this)||this).outputQueue=new KV,t.lastRead=Promise.resolve({value:null,done:!1}),t}Cv(t,e);var n=t.prototype;return n.next=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.outputQueue.length()){e.next=7;break}return e.next=3,this.pump();case 3:if(e.sent){e.next=5;break}return e.abrupt("return",{value:null,done:!0});case 5:e.next=0;break;case 7:return e.abrupt("return",{value:this.outputQueue.shift(),done:!1});case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),pU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.transform=n,r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Flatmap"},n.pump=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o,s;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=5;break}return e.abrupt("return",!1);case 5:for(n=xk(t.value),r=this.transform(t.value),a=xk(r),this.outputQueue.pushAll(r),i=Lv(n);!(o=i()).done;)bk(s=o.value,a)||s.dispose();return e.abrupt("return",!0);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(cU),hU=function(e){function t(t,n){var r;return(r=e.call(this)||this).baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=t,r}Cv(t,e);var n=t.prototype;return n.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},n.next=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.readFromChain(this.lastRead),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.readFromChain=function(){var e=Iv(kv().mark((function e(t){var n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t;case 2:if(null!=this.iterator){e.next=10;break}return e.next=5,this.moreIterators.next();case 5:if(!(n=e.sent).done){e.next=8;break}return e.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 e.next=12,this.iterator.next();case 12:if(!(r=e.sent).done){e.next=16;break}return this.iterator=null,e.abrupt("return",this.readFromChain(t));case 16:return e.abrupt("return",r);case 17:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}($V);!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(QV||(QV={}));var dU=function(e){function t(t,n){var r;return void 0===n&&(n=QV.FAIL),(r=e.call(this)||this).iterators=t,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}Cv(t,e);var n=t.prototype;return n.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},n.nextState=function(){var e=Iv(kv().mark((function e(t){var n,r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=function(e){return e instanceof $V?{value:e.next().then((function(e){return n++,e.done&&r++,e.value})),recurse:!1}:{value:null,recurse:!0}},e.next=3,t;case 3:return n=0,r=0,e.next=7,VV(this.iterators,a);case 7:if(i=e.sent,n!==r){e.next=10;break}return e.abrupt("return",{value:null,done:!0});case 10:if(!(r>0)){e.next=16;break}e.t0=this.mismatchMode,e.next=e.t0===QV.FAIL?14:e.t0===QV.SHORTEST?15:(e.t0,QV.LONGEST,16);break;case 14:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case 15:return e.abrupt("return",{value:null,done:!0});case 16:return this.count++,e.abrupt("return",{value:i,done:!1});case 18:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.next=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentPromise=this.nextState(this.currentPromise),e.abrupt("return",this.currentPromise);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}($V),fU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.bufferSize=n,r.buffer=new qV(n),r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Prefetch"},n.refill=function(){for(;!this.buffer.isFull();){var e=this.upstream.next();this.buffer.push(e)}},n.next=function(){return this.refill(),this.buffer.shift()},t}($V),mU=function(e){function t(t,n,r){var a;return(a=e.call(this,t,n)||this).upstream=t,a.windowSize=n,a.upstreamExhausted=!1,a.random=xC(r||Vw().toString()),a.lastRead=Promise.resolve({value:null,done:!1}),a}Cv(t,e);var n=t.prototype;return n.next=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.randomInt=function(e){return Math.floor(this.random()*e)},n.chooseIndex=function(){return this.randomInt(this.buffer.length())},n.serialNext=function(){var e=Iv(kv().mark((function e(){var t,n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.upstreamExhausted||this.refill();case 1:if(this.buffer.isEmpty()){e.next=14;break}return t=this.chooseIndex(),e.next=5,this.buffer.shuffleExcise(t);case 5:if(!(n=e.sent).done){e.next=10;break}this.upstreamExhausted=!0,e.next=12;break;case 10:return this.refill(),e.abrupt("return",n);case 12:e.next=1;break;case 14:return e.abrupt("return",{value:null,done:!0});case 15:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(fU),vU=function(){function e(){this.size=null}var t=e.prototype;return t.batch=function(e,t){void 0===t&&(t=!0);var n,r=this;return Hv(e>0,(function(){return"batchSize needs to be positive, but it is\n "+e})),n=this.size===1/0||null==this.size?this.size:t?Math.ceil(this.size/e):Math.floor(this.size/e),gU(Iv(kv().mark((function n(){return kv().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(e,t,yU));case 3:case"end":return n.stop()}}),n)}))),n)},t.concatenate=function(e){var t,n=this;return t=this.size===1/0||e.size===1/0?1/0:null!=this.size&&null!=e.size?this.size+e.size:null,gU(Iv(kv().mark((function t(){return kv().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.next=5,e.iterator();case 5:return t.t1=t.sent,t.abrupt("return",t.t0.concatenate.call(t.t0,t.t1));case 7:case"end":return t.stop()}}),t)}))),t)},t.filter=function(e){var t,n=this;return t=this.size===1/0?1/0:null,gU(Iv(kv().mark((function t(){return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.iterator();case 2:return t.abrupt("return",t.sent.filter((function(t){return eI((function(){return e(t)}))})));case 3:case"end":return t.stop()}}),t)}))),t)},t.forEachAsync=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.iterator();case 2:return e.abrupt("return",e.sent.forEachAsync(t));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.map=function(e){var t=this;return gU(Iv(kv().mark((function n(){return kv().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.iterator();case 2:return n.abrupt("return",n.sent.map((function(t){return eI((function(){return e(t)}))})));case 3:case"end":return n.stop()}}),n)}))),this.size)},t.mapAsync=function(e){var t=this;return gU(Iv(kv().mark((function n(){return kv().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.iterator();case 2:return n.abrupt("return",n.sent.mapAsync(e));case 3:case"end":return n.stop()}}),n)}))),this.size)},t.prefetch=function(e){if(null==e)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var t=this;return gU(Iv(kv().mark((function n(){return kv().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.iterator();case 2:return n.abrupt("return",n.sent.prefetch(e));case 3:case"end":return n.stop()}}),n)}))),this.size)},t.repeat=function(e){var t,n=this;return t=null!=this.size&&e>0?this.size*e:0===e?0:null!=this.size&&(void 0===e||e<0)?1/0:null,gU(Iv(kv().mark((function t(){var r;return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=YV(Iv(kv().mark((function e(){return kv().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.abrupt("return",{value:e.t0,done:!1});case 4:case"end":return e.stop()}}),e)})))),t.abrupt("return",JV(r.take(e)));case 2:case"end":return t.stop()}}),t)}))),t)},t.skip=function(e){var t,n=this;return t=null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size<e||void 0===e||e<0)?0:null,gU(Iv(kv().mark((function t(){return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.iterator();case 2:return t.abrupt("return",t.sent.skip(e));case 3:case"end":return t.stop()}}),t)}))),t)},t.shuffle=function(e,t,n){if(void 0===n&&(n=!0),null==e||e<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=xC(t||Vw().toString());return gU(Iv(kv().mark((function t(){var i;return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.int32(),n&&(i+=a.int32()),t.next=4,r.iterator();case 4:return t.abrupt("return",t.sent.shuffle(e,i.toString()));case 5:case"end":return t.stop()}}),t)}))),this.size)},t.take=function(e){var t,n=this;return t=null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null,gU(Iv(kv().mark((function t(){return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.iterator();case 2:return t.abrupt("return",t.sent.take(e));case 3:case"end":return t.stop()}}),t)}))),t)},t.toArray=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.size!==1/0){e.next=2;break}throw new Error("Can not convert infinite data stream to array.");case 2:return e.next=4,this.iterator();case 4:return e.abrupt("return",e.sent.toArray());case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.toArrayForTest=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.size!==1/0){e.next=2;break}throw new Error("Can not convert infinite data stream to array.");case 2:return e.next=4,this.iterator();case 4:return e.abrupt("return",e.sent.toArrayForTest());case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}();function gU(e,t){return void 0===t&&(t=null),new(function(n){function r(){var e;return(e=n.apply(this,arguments)||this).size=t,e}return Cv(r,n),r.prototype.iterator=function(){var t=Iv(kv().mark((function t(){return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e());case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),r}(vU))}function yU(e){return null===e?null:function(e){return null==e||null===(t=e)||"object"!=typeof t&&"function"!=typeof t||Array.isArray(e)||"object"==typeof e&&e instanceof ak||Hw(e);var t}(e[0])?{value:function(e){if(0===e.length)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof ak?pE(e):Gk(e)}(e),recurse:!1}:{value:null,recurse:!0}}vU.MAX_BUFFER_SIZE=1e4;var bU=function(e){function t(t){var n;return(n=e.call(this)||this).input=t,n}return Cv(t,e),t.prototype.iterator=function(){var e=Iv(kv().mark((function e(){var t,n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.input.iterator();case 2:return t=e.sent,n=t.decodeUTF8(),r=n.split("\n").map((function(e){return e.endsWith("\r")&&(e=e.slice(0,-1)),e})),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(vU),xU='"',wU=Symbol("out"),kU=Symbol("field"),NU=Symbol("quote"),IU=Symbol("quoteafterquote"),SU=Symbol("quoteinquote"),TU=function(e){Cv(n,e);var t=n.prototype;function n(t,n){var r;return(r=e.call(this)||this).input=t,r.hasHeader=!0,r.fullColumnNames=null,r.columnNamesValidated=!1,r.columnConfigs=null,r.configuredColumnsOnly=!1,r.delimiter=",",r.delimWhitespace=!1,r.base=new bU(t),n||(n={}),r.hasHeader=!1!==n.hasHeader,r.fullColumnNames=n.columnNames,r.columnConfigs=n.columnConfigs,r.configuredColumnsOnly=n.configuredColumnsOnly,n.delimWhitespace?(Hv(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}return t.columnNames=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.columnNamesValidated){e.next=3;break}return e.next=3,this.setColumnNames();case 3:return e.abrupt("return",this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setColumnNames=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o,s=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.maybeReadHeaderLine();case 2:if(t=e.sent,this.fullColumnNames||t){e.next=7;break}throw new Error("Column names must be provided if there is no header line.");case 7:this.fullColumnNames&&t&&Hv(t.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 ("+t.length.toString()+")."}));case 8:if(this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce((function(e,t){return e[t]=e[t]+1||1,e}),{}),Hv(0===(r=Object.keys(n).filter((function(e){return n[e]>1}))).length,(function(){return"Duplicate column names found: "+r.toString()})),!this.columnConfigs){e.next=22;break}a=0,i=Object.keys(this.columnConfigs);case 14:if(!(a<i.length)){e.next=22;break}if(o=i[a],-1!==this.fullColumnNames.indexOf(o)){e.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++,e.next=14;break;case 22:this.columnNamesValidated=!0;case 23:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.maybeReadHeaderLine=function(){var e=Iv(kv().mark((function e(){var t,n,r,a;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasHeader){e.next=14;break}return e.next=3,this.base.iterator();case 3:return t=e.sent,e.next=6,t.next();case 6:if(!(n=e.sent).done){e.next=9;break}throw new Error("No data was found for CSV parsing.");case 9:return r=n.value,a=this.parseRow(r,!1),e.abrupt("return",a);case 14:return e.abrupt("return",null);case 15:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.iterator=function(){var e=Iv(kv().mark((function e(){var t,n=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.columnNamesValidated){e.next=3;break}return e.next=3,this.setColumnNames();case 3:return e.next=5,this.base.iterator();case 5:return t=e.sent,this.hasHeader&&(t=t.skip(1)),e.abrupt("return",t.map((function(e){return n.makeDataElement(e)})));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.makeDataElement=function(e){for(var t=this.parseRow(e),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=t[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: "+e);u=void 0}else{var l=Number(s);if(isNaN(l))u=o&&"bool"===o.dtype?this.getBoolean(s):s;else if(o&&o.dtype)switch(o.dtype){case"float32":default:u=l;break;case"int32":u=Math.floor(l);break;case"bool":u=this.getBoolean(s)}else u=l}o&&o.isLabel?r[i]=u:n[i]=u}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},t.getBoolean=function(e){return"1"===e||"true"===e.toLowerCase()?1:0},t.parseRow=function(e,t){void 0===t&&(t=!0);for(var n=[],r=0,a=e.length,i=wU,o=0;o<a;o++)switch(i){case wU:switch(e.charAt(o)){case xU:r=o+1,i=NU;break;case this.delimiter:if(r=o+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),i=wU;break;default:i=kU,r=o}break;case kU:if(e.charAt(o)===this.delimiter)n.push(e.substring(r,o)),i=wU,r=o+1;break;case NU:if(e.charAt(o)===xU)i=IU;break;case IU:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(r,o-1)),i=wU,r=o+1;break;case xU:i=NU;break;default:i=SU}break;case SU:if(e.charAt(o)===xU)i=NU}if(i===IU?n.push(e.substring(r,a-1)):n.push(e.substring(r)),t&&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},n}(vU),CU=function(e){function t(t){var n;(n=e.call(this)||this).microphoneConfig=t,n.isClosed=!1,n.fftSize=t.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=t.numFramesPerSpectrogram||43,n.sampleRateHz=t.sampleRateHz,n.columnTruncateLength=t.columnTruncateLength||n.fftSize,n.audioTrackConstraints=t.audioTrackConstraints,n.smoothingTimeConstant=t.smoothingTimeConstant||0,n.includeSpectrogram=!1!==t.includeSpectrogram,n.includeWaveform=!0===t.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}Cv(t,e);var n=t.prototype;return n.summary=function(){return"microphone"},t.create=function(){var e=Iv(kv().mark((function e(n){var r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n={}),Fg().get("IS_BROWSER")){e.next=3;break}throw new Error("microphone API is only supported in browser environment.");case 3:return r=new t(n),e.next=6,r.start();case 6:return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.start=function(){var e=Iv(kv().mark((function e(){var t,n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1});case 3:this.stream=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new Error("Error thrown while initializing video stream: "+e.t0.message);case 9:if(this.stream){e.next=11;break}throw new Error("Could not obtain audio from microphone.");case 11:if(t=window.AudioContext||window.webkitAudioContext,this.audioContext=new t,this.sampleRateHz){e.next=17;break}this.sampleRateHz=this.audioContext.sampleRate,e.next=19;break;case 17:if(this.audioContext.sampleRate===this.sampleRateHz){e.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),e.abrupt("return");case 27:case"end":return e.stop()}}),e,this,[[0,6]])})));return function(){return e.apply(this,arguments)}}(),n.next=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isClosed){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:return e.next=4,this.getAudioData();case 4:return r=e.sent,this.includeSpectrogram&&(a=this.flattenQueue(r.freqDataQueue),t=this.getTensorFromAudioDataArray(a,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(r.timeDataQueue),n=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),e.abrupt("return",{value:{spectrogram:t,waveform:n},done:!1});case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.capture=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.next();case 2:return e.abrupt("return",e.sent.value);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.getAudioData=function(){var e=Iv(kv().mark((function e(){var t,n,r,a=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],n=[],r=0,e.abrupt("return",new Promise((function(e){var i=setInterval((function(){a.includeSpectrogram&&(a.analyser.getFloatFrequencyData(a.freqData),a.freqData[0]===-1/0&&e({freqDataQueue:t,timeDataQueue:n}),t.push(a.freqData.slice(0,a.columnTruncateLength))),a.includeWaveform&&(a.analyser.getFloatTimeDomainData(a.timeData),n.push(a.timeData.slice())),++r===a.numFrames&&(clearInterval(i),e({freqDataQueue:t,timeDataQueue:n}))}),a.fftSize/a.sampleRateHz*1e3)})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.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(e){var t=e[0].length,n=new Float32Array(e.length*t);return e.forEach((function(e,r){return n.set(e,r*t)})),n},n.getTensorFromAudioDataArray=function(e,t){var n=new Float32Array(Xv(t));return n.set(e,n.length-e.length),Gk(n,t)},t}($V),EU=function(e){function t(t,n){var r;if((r=e.call(this)||this).webcamVideoElement=t,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=mE([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,l=i+s;r.cropBox=vE([s,o,l,u],[1,4])}else r.cropBox=vE([0,0,1,1],[1,4]);return r}Cv(t,e);var n=t.prototype;return n.summary=function(){return"webcam"},t.create=function(){var e=Iv(kv().mark((function e(n,r){var a;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r={}),Fg().get("IS_BROWSER")){e.next=3;break}throw new Error("tf.data.webcam is only supported in browser environment.");case 3:if(n){e.next=9;break}if(n=document.createElement("video"),r.resizeWidth&&r.resizeHeight){e.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 t(n,r),e.next=12,a.start();case 12:return e.abrupt("return",a);case 13:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),n.start=function(){var e=Iv(kv().mark((function e(){var t=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.webcamConfig.facingMode&&Hv("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(function(){return"Invalid webcam facing mode: "+t.webcamConfig.facingMode+". Please provide 'user' or 'environment'"})),e.prev=1,e.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=e.sent,e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(1),e.t0.message="Error thrown while initializing video stream: "+e.t0.message,e.t0;case 11:if(this.stream){e.next=13;break}throw new Error("Could not obtain video from webcam.");case 13:try{this.webcamVideoElement.srcObject=this.stream}catch(e){console.log(e),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,e.abrupt("return",new Promise((function(e){t.webcamVideoElement.onloadedmetadata=function(){e()}})));case 17:case"end":return e.stop()}}),e,this,[[1,7]])})));return function(){return e.apply(this,arguments)}}(),n.next=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isClosed){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:e.prev=2,t=JR(this.webcamVideoElement),e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(2),new Error("Error thrown converting video to pixels: "+JSON.stringify(e.t0));case 9:if(!this.resize){e.next=22;break}return e.prev=10,e.abrupt("return",{value:this.cropAndResizeFrame(t),done:!1});case 14:throw e.prev=14,e.t1=e.catch(10),new Error("Error thrown cropping the video: "+e.t1.message);case 17:return e.prev=17,t.dispose(),e.finish(17);case 20:e.next=23;break;case 22:return e.abrupt("return",{value:t,done:!1});case 23:case"end":return e.stop()}}),e,this,[[2,6],[10,14,17,20]])})));return function(){return e.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(e){var t=this;return eI((function(){var n,r=tT(XN(e,"float32"),0),a=(n=oR.cropAndResize(r,t.cropBox,t.cropBoxInd,t.cropSize,"bilinear")).shape;return PI(n,a.slice(1))}))},n.capture=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.next();case 2:return e.abrupt("return",e.sent.value);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.stop=function(){this.stream.getTracks().forEach((function(e){return e.stop()}));try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0},n.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},t}($V),AU=function(){},RU=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.split=function(e){return new _U(this,e)},t}($V),_U=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.impl=new FU(t,n),r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.impl.summary()},n.next=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.impl.next());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(RU),FU=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.separator=n,r.carryover="",r}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},n.pump=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=9;break}if(""!==this.carryover){e.next=6;break}return e.abrupt("return",!1);case 6:return this.outputQueue.push(this.carryover),this.carryover="",e.abrupt("return",!0);case 9:for((n=t.value.split(this.separator))[0]=this.carryover+n[0],r=Lv(n.slice(0,-1));!(a=r()).done;)i=a.value,this.outputQueue.push(i);return this.carryover=n[n.length-1],e.abrupt("return",!0);case 14:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(cU),OU=function(e){function t(){return e.apply(this,arguments)||this}return Cv(t,e),t.prototype.decodeUTF8=function(){return new DU(this)},t}($V),DU=function(e){function t(t){var n;return(n=e.call(this)||this).upstream=t,n.impl=new MU(t),n}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.impl.summary()},n.next=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.impl.next());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(RU),MU=function(e){function t(t){var n;if((n=e.call(this)||this).upstream=t,Fg().get("IS_BROWSER"))n.decoder=new TextDecoder("utf-8");else{var r=require("string_decoder").StringDecoder;n.decoder=new r("utf8")}return n}Cv(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Utf8"},n.pump=function(){var e=Iv(kv().mark((function e(){var t,n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=7;break}return e.abrupt("return",!1);case 7:n=t.value;case 8:return r=Fg().get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),e.abrupt("return",!0);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(cU),LU=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this)||this).file=t,r.options=n,Hv(t instanceof Uint8Array||!!Fg().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),(function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."})),r.offset=n.offset||0,r.chunkSize=n.chunkSize||1048576,r}Cv(t,e);var n=t.prototype;return n.summary=function(){return"FileChunks "+this.file},n.next=function(){var e=Iv(kv().mark((function e(){var t,n=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:return t=new Promise((function(e,t){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)e(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 t(new TypeError("FileReader returned unknown type."));e(r)},a.onabort=function(e){return t(new Error("Aborted"))},a.onerror=function(e){return t(new Error(e.type))};var i=n.file.slice(n.offset,r);a.readAsArrayBuffer(i)}n.offset=r})),e.next=5,t;case 5:return e.t0=e.sent,e.abrupt("return",{value:e.t0,done:!1});case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(OU);function zU(e,t,n){return PU.apply(this,arguments)}function PU(){return(PU=Iv(kv().mark((function e(t,n,r){var a,i,o,s;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n={}),"string"==typeof t?a=t:(a=t.url,i=BU(t)),e.next=4,(r||Uw)(a,i);case 4:if(!(o=e.sent).ok){e.next=14;break}return e.t0=Uint8Array,e.next=9,o.arrayBuffer();case 9:return e.t1=e.sent,s=new e.t0(e.t1),e.abrupt("return",new LU(s,n));case 14:throw new Error(o.statusText);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var BU=function(e){return{method:e.method,headers:e.headers,body:e.body,mode:e.mode,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity}};function WU(e){return"string"==typeof e&&"file://"===e.slice(0,7)}var VU=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this)||this).input=t,r.options=n,r}return Cv(t,e),t.prototype.iterator=function(){var e=Iv(kv().mark((function e(){var t;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return WU(this.input)&&Fg().get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.slice(7))),e.abrupt("return",new LU(this.input,this.options));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(AU),UU=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this)||this).url=t,r.fileOptions=n,r}return Cv(t,e),t.prototype.iterator=function(){var e=Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!WU(this.url)){e.next=4;break}return e.abrupt("return",new VU(this.url,this.fileOptions).iterator());case 4:return e.abrupt("return",zU(this.url,this.fileOptions));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(AU);function GU(){return(GU=Iv(kv().mark((function e(t,n){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",EU.create(t,n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function jU(){return(jU=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",CU.create(t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var HU="4.3.0",qU={__proto__:null,array:function(e){return gU(Iv(kv().mark((function t(){return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",XV(e));case 1:case"end":return t.stop()}}),t)}))),e.length)},Dataset:vU,zip:function(e){if(!GV(e))throw new Error("The argument to zip() must be an object or array.");var t;if(Array.isArray(e))for(var n=0;n<e.length;n++)t=null==t?e[n].size:Math.min(t,e[n].size);else if(e instanceof Object)for(var r in e)t=null==t?e[r].size:Math.min(t,e[r].size);return gU(Iv(kv().mark((function t(){var n;return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,VV(e,(function(e){if(e instanceof vU)return{value:e.iterator(),recurse:!1};if(GV(e))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}));case 2:return n=t.sent,t.abrupt("return",ZV(n,QV.SHORTEST));case 4:case"end":return t.stop()}}),t)}))),t)},CSVDataset:TU,TextLineDataset:bU,csv:function(e,t){return void 0===t&&(t={}),new TU(new UU(e),t)},func:function(e){var t=YV(e);return gU(Iv(kv().mark((function e(){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))))},generator:function(e){return gU(Iv(kv().mark((function t(){var n;return kv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e();case 2:return n=t.sent,t.abrupt("return",YV((function(){return n.next()})));case 4:case"end":return t.stop()}}),t)}))))},microphone:function(e){return jU.apply(this,arguments)},webcam:function(e,t){return GU.apply(this,arguments)},FileDataSource:VU,URLDataSource:UU,version_data:HU};function KU(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){null!=e&&Hv("complex64"!==e.dtype,(function(){return t+" does not support complex64 tensors in the CPU backend."}))}))}var XU=OE,YU=function(e){Cv(n,e);var t=n.prototype;function n(){var t;return(t=e.call(this)||this).blockSize=48,t.firstUse=!0,t.data=new zv(Ov(t),QN()),t}return t.nextDataId=function(){return n.nextDataId++},t.write=function(e,t,n){this.firstUse&&(this.firstUse=!1,Fg().get("IS_NODE")&&qx("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));var r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r},t.makeTensorInfo=function(e,t,n){var r;if("string"===t&&null!=n&&n.length>0&&cg(n[0])){var a=n.map((function(e){return Gw(e)}));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}},t.refCount=function(e){return this.data.has(e)?this.data.get(e).refCount:0},t.incRef=function(e){this.data.get(e).refCount++},t.decRef=function(e){this.data.has(e)&&this.data.get(e).refCount--},t.move=function(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})},t.numDataIds=function(){return this.data.numDataIds()},t.read=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readSync(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.readSync=function(e){var t=this.data.get(e),n=t.dtype,r=t.complexTensorInfos;return"complex64"===n?G_(this.readSync(r.real.dataId),this.readSync(r.imag.dataId)):bg(this.data.get(e).values,n)},t.bufferSync=function(e){var t=this.readSync(e.dataId);if("string"===e.dtype)try{var n=t.map((function(e){return jw(e)}));return KN(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return KN(e.shape,e.dtype,t)},t.makeOutput=function(e,t,n){return QN().makeTensorFromTensorInfo(this.makeTensorInfo(t,n,e),this)},t.disposeData=function(e,t){if(void 0===t&&(t=!1),this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;var n=this.data.get(e).complexTensorInfos;null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0},t.disposeIntermediateTensorInfo=function(e){this.disposeData(e.dataId)},t.time=function(){var e=Iv(kv().mark((function e(t){var n,r;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Vw(),t(),r=Vw()-n,e.abrupt("return",{kernelMs:r});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.memory=function(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}},t.where=function(e){KU([e],"where");var t=this.readSync(e.dataId);return XU(e.shape,t)},t.dispose=function(){},t.floatPrecision=function(){return 32},t.epsilon=function(){return e.prototype.epsilon.call(this)},n}(Pv);function JU(e){for(var t=new Float32Array(e.length),n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}YU.nextDataId=0;var ZU={kernelName:Mg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs.x,n=e.backend;KU(t,"abs");var r=new Float32Array(Xv(t.shape));return r=JU(n.data.get(t.dataId).values),n.makeOutput(r,t.shape,t.dtype)}};function QU(e){return function(t,n,r,a,i){var o=TS(t,n),s=o.length,u=vg(o),l=rg(i,Xv(o)),c=t.length,p=n.length,h=vg(t),d=vg(n),f=IS(t,o),m=IS(n,o);if(f.length+m.length===0)for(var v=0;v<l.length;++v)l[v]=e(r[v%r.length],a[v%a.length]);else for(var g=function(t){var n=Sg(t,s,u),i=n.slice(-c);f.forEach((function(e){return i[e]=0}));var o=Ig(i,c,h),v=n.slice(-p);m.forEach((function(e){return v[e]=0}));var g=Ig(v,p,d);l[t]=e(r[o],a[g])},y=0;y<l.length;++y)g(y);return[l,o]}}function $U(e){var t=e.inputs,n=e.backend,r=t.real,a=t.imag,i=n.data.get(r.dataId).values,o=n.data.get(a.dataId).values,s=n.makeTensorInfo(r.shape,"complex64");return n.data.get(s.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",i),imag:n.makeTensorInfo(a.shape,"float32",o)},s}var eG={kernelName:sy,backendName:"cpu",kernelFunc:$U};function tG(e,t,n){if(void 0===n&&(n="float32"),"complex64"===n)return $U({inputs:{real:tG(e,t,"float32"),imag:tG(e,t,"float32")},backend:e});var r=wg(Xv(t),n);return e.makeTensorInfo(t,n,r)}function nG(e){var t=e.inputs,n=e.backend,r=t.x;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}var rG={kernelName:Yy,backendName:"cpu",kernelFunc:nG};function aG(e){var t=e.inputs,n=e.backend,r=t.input,a=n.data.get(r.dataId).complexTensorInfos.real,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}var iG={kernelName:Gb,backendName:"cpu",kernelFunc:aG};function oG(e,t,n,r){if("int32"===r)return[t,"int32",Int32Array.from(e)];if("bool"===r){var a=Ww([0],n),i=QU((function(e,t){return e!==t?1:0}))(t,[],e,a,"bool"),o=i[0];return[i[1],"bool",o]}throw new Error("Error in Cast: failed to cast "+n+" to "+r)}function sG(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.dtype;if("complex64"===i){if("complex64"===a.dtype)return nG({inputs:{x:a},backend:n});var o=tG(n,a.shape,a.dtype),s=sG({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),u=$U({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}if("complex64"===a.dtype){var l=aG({inputs:{input:a},backend:n}),c=sG({inputs:{x:l},backend:n,attrs:{dtype:i}});return n.disposeIntermediateTensorInfo(l),c}if(!sg(a.dtype,i)){var p=nG({inputs:{x:a},backend:n});return{dataId:p.dataId,shape:p.shape,dtype:i}}var h=oG(n.data.get(a.dataId).values,a.shape,a.dtype,i),d=h[0],f=h[1],m=h[2];return n.makeTensorInfo(d,f,m)}var uG={kernelName:ay,backendName:"cpu",kernelFunc:sG};function lG(e,t,n,r){return null==n?function(n){var a=n.inputs,i=n.backend,o=a.a,s=a.b,u=i;KU([o,s],e);var l=u.data.get(o.dataId).values,c=u.data.get(s.dataId).values,p="string"===o.dtype?wF(l):l,h="string"===o.dtype?wF(c):c,d=r||o.dtype,f=t(o.shape,s.shape,p,h,d),m=f[0],v=f[1];return u.makeTensorInfo(v,d,m)}:function(e){var a=e.inputs,i=e.backend,o=a.a,s=a.b,u=i;if("complex64"===o.dtype||"complex64"===s.dtype){var l=sG({inputs:{x:o},backend:u,attrs:{dtype:"complex64"}}),c=u.data.get(l.dataId),p=c.complexTensorInfos.real,h=c.complexTensorInfos.imag,d=u.data.get(p.dataId).values,f=u.data.get(h.dataId).values,m=sG({inputs:{x:s},backend:u,attrs:{dtype:"complex64"}}),v=u.data.get(m.dataId),g=v.complexTensorInfos.real,y=v.complexTensorInfos.imag,b=u.data.get(g.dataId).values,x=u.data.get(y.dataId).values,w=n(o.shape,s.shape,d,f,b,x),k=w[0],N=w[1],I=w[2],S=u.makeTensorInfo(I,"float32",k),T=u.makeTensorInfo(I,"float32",N),C=$U({inputs:{real:S,imag:T},backend:u});return u.disposeIntermediateTensorInfo(l),u.disposeIntermediateTensorInfo(m),u.disposeIntermediateTensorInfo(S),u.disposeIntermediateTensorInfo(T),C}var E=u.data.get(o.dataId).values,A=u.data.get(s.dataId).values,R=r||o.dtype,_=t(o.shape,s.shape,E,A,R),F=_[0],O=_[1];return u.makeTensorInfo(O,R,F)}}function cG(e){return function(t,n,r,a,i,o){var s=TS(t,n),u=Xv(s),l=s.length,c=vg(s),p=rg("float32",u),h=rg("float32",u),d=IS(t,s),f=IS(n,s),m=G_(r,a),v=G_(i,o),g=t.length,y=vg(t),b=n.length,x=vg(n);if(d.length+f.length===0)for(var w=0;w<p.length;w++){var k=w%m.length,N=w%v.length,I=e(m[2*k],m[2*k+1],v[2*N],v[2*N+1]);p[w]=I.real,h[w]=I.imag}else for(var S=function(t){var n=Sg(t,l,c),r=n.slice(-g);d.forEach((function(e){return r[e]=0}));var a=Ig(r,g,y),i=n.slice(-b);f.forEach((function(e){return i[e]=0}));var o=Ig(i,b,x),s=e(m[2*a],m[2*a+1],v[2*o],v[2*o+1]);p[t]=s.real,h[t]=s.imag},T=0;T<p.length;T++)S(T);return[p,h,s]}}var pG=QU((function(e,t){return e+t})),hG=cG((function(e,t,n,r){return{real:e+n,imag:t+r}})),dG=lG(Pg,pG,hG),fG={kernelName:Pg,backendName:"cpu",kernelFunc:dG};function mG(e,t,n,r,a){for(var i=Xv(r),o=wg(a,n),s=0;s<e.length;s++){var u=e[s];if(u<0)throw new Error("Input x must be non-negative!");u>=a||(o[u]+=i>0?t[s]:1)}return o}function vG(e,t,n,r){void 0===r&&(r=!1);for(var a=e.shape[0],i=e.shape[1],o=KN([a,n],t.dtype),s=0;s<a;s++)for(var u=0;u<i;u++){var l=e.get(s,u);if(l<0)throw new Error("Input x must be non-negative!");l>=n||(r?o.set(1,s,l):t.size>0?o.set(o.get(s,l)+t.get(s,u),s,l):o.set(o.get(s,l)+1,s,l))}return o}function gG(e){return function(t,n,r){for(var a=ag(n,t.length),i=0;i<t.length;++i)a[i]=e(t[i],r);return a}}function yG(e,t,n){return bG(e,gG(t),n)}function bG(e,t,n){return function(r){var a=r.inputs,i=r.attrs,o=r.backend,s=a.x;KU(s,e);var u,l=o,c=l.data.get(s.dataId).values;if("string"===s.dtype){if(!Array.isArray(c))throw new Error("String tensor's value was not an instance of Array");u=wF(c)}else u=c;var p=n||s.dtype,h=t(u,p,i);return l.makeTensorInfo(s.shape,p,h)}}var xG=gG((function(e){return Math.ceil(e)})),wG=bG(iy,xG),kG={kernelName:iy,backendName:"cpu",kernelFunc:wG};function NG(e,t,n,r){var a=ag(n,Xv(t));if(r&&"string"!==n){var i=0;e.forEach((function(e){var t=Xv(e.shape);a.set(e.vals,i),i+=t}))}else{var o=0;e.forEach((function(e){for(var r="string"===n?wF(e.vals):e.vals,i=0,s=0;s<e.shape[0];++s)for(var u=s*t[1]+o,l=0;l<e.shape[1];++l)a[u+l]=r[i++];o+=e.shape[1]}))}return a}var IG=QU((function(e,t){return e===t?1:0})),SG=lG(My,IG,null,"bool"),TG={kernelName:My,backendName:"cpu",kernelFunc:SG},CG=gG((function(e){return Math.exp(e)})),EG=bG(Ly,CG,"float32"),AG={kernelName:Ly,backendName:"cpu",kernelFunc:EG},RG=gG((function(e){return Math.expm1(e)})),_G=bG(Py,RG),FG={kernelName:Py,backendName:"cpu",kernelFunc:_G},OG=gG((function(e){return Math.floor(e)})),DG=bG(Uy,OG),MG={kernelName:Uy,backendName:"cpu",kernelFunc:DG},LG=QU((function(e,t){return Math.floor(e/t)})),zG=lG(Gy,LG,null,"int32"),PG={kernelName:Gy,backendName:"cpu",kernelFunc:zG};function BG(e,t,n,r,a,i,o,s,u){for(var l=KN([r,i],n),c=0;c<r;c++){for(var p=[],h=0,d=0;d<a;d++){var f=e[c*a+d];h+=f*o[d],p.push(f)}if(h<0||h>=u/i)throw new Error("Invalid indices: "+p+" does not index into "+s);for(var m=0;m<i;m++)l.values[c*i+m]=t.get.apply(t,t.indexToLoc(h*i+m))}return l}function WG(e,t,n){for(var r=KN(n,e.dtype),a=0;a<r.size;++a){var i=r.indexToLoc(a).slice(),o=i[0],s=i[2],u=t.locToIndex([o,s]);i[2]=t.values[u];var l=e.locToIndex(i);0<=l&&l<e.values.length&&(r.values[a]=e.values[l])}return r}var VG=QU((function(e,t){return e>t?1:0})),UG=lG(Ky,VG,null,"bool"),GG={kernelName:Ky,backendName:"cpu",kernelFunc:UG},jG=QU((function(e,t){return e>=t?1:0})),HG=lG(Xy,jG,null,"bool"),qG={kernelName:Xy,backendName:"cpu",kernelFunc:HG},KG=QU((function(e,t){return e<t?1:0})),XG=lG(nb,KG,null,"bool"),YG={kernelName:nb,backendName:"cpu",kernelFunc:XG},JG=QU((function(e,t){return e<=t?1:0})),ZG=lG(rb,JG,null,"bool"),QG={kernelName:rb,backendName:"cpu",kernelFunc:ZG};function $G(e,t,n){var r=(t-e)/(n-1),a=wg(n,"float32");a[0]=e;for(var i=1;i<a.length;i++)a[i]=a[i-1]+r;return a}var ej=gG((function(e){return Math.log(e)})),tj=bG(ib,ej),nj={kernelName:ib,backendName:"cpu",kernelFunc:tj};function rj(e,t,n,r){for(var a=rg(r,Xv(n)),i=0;i<a.length;++i){for(var o=i*t,s=e[o],u=0;u<t;++u){var l=e[o+u];(Number.isNaN(l)||l>s)&&(s=l)}a[i]=s}return a}var aj=QU((function(e,t){return Math.max(e,t)})),ij=lG(fb,aj),oj={kernelName:fb,backendName:"cpu",kernelFunc:ij},sj=QU((function(e,t){return Math.min(e,t)})),uj=lG(kb,sj),lj={kernelName:kb,backendName:"cpu",kernelFunc:uj},cj=QU((function(e,t){return e*t})),pj=cG((function(e,t,n,r){return{real:e*n-t*r,imag:e*r+t*n}})),hj=lG(Tb,cj,pj),dj={kernelName:Tb,backendName:"cpu",kernelFunc:hj};function fj(e,t,n){var r=Bw(-1,n);return cj([],t,r,e,n)}var mj={kernelName:Cb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x;KU(r,"neg");var a=fj(n.data.get(r.dataId).values,r.shape,r.dtype),i=a[0],o=a[1];return n.makeTensorInfo(o,r.dtype,i)}},vj=QU((function(e,t){return e!==t?1:0})),gj=lG(Eb,vj,null,"bool"),yj={kernelName:Eb,backendName:"cpu",kernelFunc:gj};function bj(e,t,n,r,a){for(var i=t.length,o=Xv(t),s=vg(t),u=vg(a),l=rg(n,Xv(a)),c=0;c<o;++c){for(var p=Sg(c,i,s),h=new Array(p.length),d=0;d<h.length;d++)h[d]=p[r[d]];l[Ig(h,i,u)]=e[c]}return l}function xj(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=n.perm;KU(a,"transpose");for(var o=a.shape.length,s=new Array(o),u=0;u<s.length;u++)s[u]=a.shape[i[u]];var l=bj(r.data.get(a.dataId).values,a.shape,a.dtype,i,s);return{dataId:r.write(l,s,a.dtype),shape:s,dtype:a.dtype}}var wj={kernelName:Mx,backendName:"cpu",kernelFunc:xj};function kj(e,t,n,r){for(var a=PS(e,r),i=a[0],o=a[1],s=dk(t,"int32"),u=wg(Xv(i),s),l=Xv(o),c=0;c<u.length;++c){for(var p=c*l,h=1,d=0;d<l;++d)h*=n[p+d];u[c]=h}return{outVals:u,outShape:i,outDtype:s}}var Nj={kernelName:Pb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims;KU(a,"prod");var s=a.shape.length,u=tg(i,a.shape),l=VS(u,s),c=u,p=a,h=[];null!=l&&(p=xj({inputs:{x:a},backend:n,attrs:{perm:l}}),h.push(p),c=GS(c.length,s));var d=n.data.get(p.dataId).values,f=kj(p.shape,p.dtype,d,c),m=f.outVals,v=f.outShape,g=f.outDtype,y=v;return o&&(y=BS(v,u)),h.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(y,g,m)}};function Ij(e,t,n,r){var a=[],i=0,o=t.length-1+n.length,s=new Array(o).fill(null).map((function(){return[0]}));!function(e,t){for(var n=0;n<e.length;++n){var r=e[n],a=n===e.length-1?t:e[n+1].length;if(0===r.length)throw new Error("Ragged splits may not be empty");if(r[0]<0)throw new Error("Ragged splits must be non-negative");if(r[r.length-1]>a)throw new Error("Ragged splits must not point past values");for(var i=1;i<r.length;++i)if(r[i-1]>r[i])throw new Error("Ragged splits must be sorted in ascending order")}}(n,r);for(var u=1,l=0;l<t.length-1;++l){u*=t[l];for(var c=t[l+1],p=1;p<u+1;++p)s[l].push(p*c)}for(var h=0;h<e.length;++h){for(var d=e[h],f=e[h]+1,m=0;m<n.length;++m){var v=n[m],g=m+t.length-1;if(g>=0)for(var y=s[g],b=y[y.length-1]-v[d],x=d;x<f;++x)s[g].push(v[x+1]+b);d=v[d],f=v[f]}f!==d&&(a.push([d,f]),i+=f-d)}return{outSplits:s,valueSlices:a,numValues:i}}function Sj(e,t){for(var n=e.slice(0,t);n.length<t;)n.push(1);for(var r=t;r<e.length;r++)n[t-1]*=e[r];return n}function Tj(e,t,n,r,a){var i=t.slice();i[0]=a;var o=ag(n,Xv(i)),s=e.length;return function(e,t,n,r,a,i){for(var o,s=Sj(t,2)[1],u=Sj(i,2)[1],l=0,c=Lv(n);!(o=c()).done;)for(var p=o.value,h=p[0];h<p[1];++h){for(var d=0;d<r;++d)a[l*u+d]=e[h*s+d];++l}}(e,t,r,0===s?0:s/t[0],o,i),[o,i]}function Cj(e,t,n,r,a,i,o,s){if(0===e.length)throw new Error("paramsNestedSplits must be non empty");if(0===t[0].length)throw new Error("Split tensors must not be scalars");if(function(e,t,n){e.forEach((function(e,r){if(e<0||e>=n){var a=Sg(r,t.length,vg(t)).join(",");throw new Error("indices["+a+"] = "+e+" is not in [0, "+n+")")}}))}(i,o,t[0][0]-1),0===r.length)throw new Error("params.rank must be nonzero");var u=Ij(i,o,e,r[0]),l=u.outSplits,c=u.valueSlices,p=u.numValues,h=function(e){for(var t=[],n=function(n){var r=ag("int32",e[n].length);t.push(r),e[n].forEach((function(e,t){return r[t]=e}))},r=0;r<e.length;++r)n(r);return t}(l),d=Tj(n,r,a,c,p);return[h,d[0],d[1]]}var Ej=2147483647;function Aj(e,t,n,r,a,i,o){if(t.length>1)throw new Error("starts must be a scalar or vector");if(a.length>1)throw new Error("limits must be a scalar or vector");if(o.length>1)throw new Error("deltas must be a scalar or vector");var s=0===t.length,u=0===a.length,l=0===o.length,c=[];s||c.push(t[0]),u||c.push(a[0]),l||c.push(o[0]);for(var p=1;p<c.length;++p)if(c[p]!==c[p-1])throw new Error("starts, limits, and deltas must have the same shape");var h=0===c.length?1:c[0],d=ag("int32",h+1);d[0]=0;for(var f=0;f<h;++f){var m=s?e[0]:e[f],v=u?r[0]:r[f],g=l?i[0]:i[f];if(0===g)throw new Error("Requires delta != 0");var y=void 0;if(g>0&&v<m||g<0&&v>m)y=0;else if((y=Math.ceil(Math.abs((v-m)/g)))>Ej)throw new Error("Requires ((limit - start) / delta) <= 2147483647");d[f+1]=d[f]+y}for(var b=ag(n,d[h]),x=0,w=0;w<h;++w)for(var k=d[w+1]-d[w],N=s?e[0]:e[w],I=l?i[0]:i[w],S=0;S<k;++S)b[x++]=N,N+=I;return[d,b]}var Rj=m_,_j=function(){function e(e,t,n,r,a,i,o,s,u,l){this.shape=e,this.shapeShape=t,this.values=n,this.valuesShape=r,this.valuesDType=a,this.defaultValue=i,this.defaultValueShape=o,this.rowPartitionValues=s,this.rowPartitionValuesShapes=u,this.rowPartitionTypes=S_(l),this.raggedRank=T_(this.rowPartitionTypes)}var t=e.prototype;return t.getRowPartitionTypeByDimension=function(e){return this.rowPartitionTypes[0]===Rj.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]},t.getRowPartitionTensor=function(e){return this.rowPartitionTypes[0]===Rj.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]},t.getMaxWidth=function(t){var n=this.getRowPartitionTensor(t-1);switch(this.getRowPartitionTypeByDimension(t-1)){case Rj.VALUE_ROWIDS:return e.getMaxWidthValueRowID(n);case Rj.ROW_SPLITS:return e.getMaxWidthRowSplit(n);default:throw new Error("Cannot handle partition type "+Rj[this.getRowPartitionTypeByDimension(t-1)])}},e.getMaxWidthRowSplit=function(e){var t=e.length;if(0===t||1===t)return 0;for(var n=0,r=0;r<t-1;++r){var a=e[r+1]-e[r];a>n&&(n=a)}return n},e.getMaxWidthValueRowID=function(e){var t=e.length;if(0===t)return 0;for(var n=0,r=e[0],a=0,i=1;i<t;++i){var o=e[i];o!==r&&(r=o,a=Math.max(i-n,a),n=i)}return Math.max(t-n,a)},t.tensorShapeFromTensor=function(e,t,n){if(void 0===n&&(n=!0),0===t.length){if(-1===e[0])return[];throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return Oj(e,n)},t.calculateOutputSize=function(e){var t=this.valuesShape;C_(this.defaultValueShape,t);var n=this.tensorShapeFromTensor(this.shape,this.shapeShape),r=I_(this.raggedRank,n,t);r[0]<0&&(r[0]=e);for(var a=1;a<=this.raggedRank;++a)r[a]<0&&(r[a]=this.getMaxWidth(a));return r},t.calculateFirstParentOutputIndex=function(e,t,n){for(var r=Math.min(e,n),a=[],i=0,o=0;o<r;++o,i+=t)a.push(i);for(var s=r;s<e;++s)a.push(-1);return Hv(a.length===e,(function(){return"Final length of result must be equal to firstDimension."})),a},t.calculateOutputIndexRowSplit=function(e,t,n,r){for(var a=e.length,i=[],o=0;o<a-1;++o){var s=e[o+1]-e[o],u=Math.min(r,s),l=t[o];-1===l&&(u=0);for(var c=0;c<u;++c)i.push(l),l+=n;for(var p=0;p<s-u;++p)i.push(-1)}if(a>0&&i.length!==e[a-1])throw new Error("Invalid row split size.");return i},t.calculateOutputIndexValueRowID=function(e,t,n,r){var a=e.length,i=[];if(0===a)return[];var o=0,s=e[0];if(s>=t.length)throw new Error("Got currentValueRowId="+s+", which is not less than "+t.length);var u=t[s];i.push(u);for(var l=1;l<a;++l){var c=e[l];if(c===s)u>=0&&(++o<r?u+=n:u=-1);else{if(o=0,s=c,c>=t.length)throw new Error("Got nextValueRowId="+c+" which is not less than "+t.length);u=t[c]}i.push(u)}if(i.length!==e.length)throw new Error("Invalid row ids.");return i},t.calculateOutputIndex=function(e,t,n,r){var a=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case Rj.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(a,t,n,r);case Rj.ROW_SPLITS:if(a.length-1>t.length)throw new Error("Row partition size is greater than output size: "+(a.length-1)+" > "+t.length);return this.calculateOutputIndexRowSplit(a,t,n,r);default:throw new Error("Unsupported partition type: "+Rj[i])}},t.getFirstDimensionSize=function(){var e=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw new Error("No row_partition_types given.");var t=this.rowPartitionTypes[0];switch(t){case Rj.FIRST_DIM_SIZE:return e[0];case Rj.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case Rj.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error("Cannot handle type "+Rj[t])}},t.compute=function(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");var e=this.getFirstDimensionSize(),t=this.calculateOutputSize(e),n=new Array(this.raggedRank+1);n[n.length-1]=1;for(var r=n.length-2;r>=0;--r)n[r]=n[r+1]*t[r+1];var a=Oj(t,!1),i=ag(this.valuesDType,Xv(a));if(n[0]*t[0]>0){for(var o=this.calculateFirstParentOutputIndex(e,n[0],t[0]),s=1;s<=this.raggedRank;++s){o=this.calculateOutputIndex(s-1,o,n[s],t[s])}this.setOutput(this.raggedRank,o,i,a)}return[a,i]},t.setOutput=function(e,t,n,r){if(0!==n.length){var a=this.values,i=n,o=r.slice(),s=Xv(o=o.slice(e+1)),u=t.length,l=this.defaultValue;if(l.length!==s&&1!==l.length){var c=this.defaultValueShape;eI((function(){var e=PI(l,c),t=eS(e,o);l=t.dataSync()}))}for(var p=0,h=0,d=0,f=0;f<=u;++f){var m=f<u?t[f]:-1;if(m!==d){if(h<d){var v=a.subarray(p*s);Fj(i.subarray(h*s),v,(d-h)*s)}if(f>=u){var g=n.length;m=Math.floor(g/s)}if(m>d)if(1===this.defaultValue.length)i.subarray(d*s,m*s).fill(this.defaultValue[0]),d=m;else for(;m>d;){Fj(i.slice(d*s),l,s),++d}m<0?(p=f+1,h=d):(p=f,d=(h=d)+1)}else++d}}},e}();function Fj(e,t,n){for(var r=0;r<n;r++)e[r]=t[r]}function Oj(e,t){for(var n,r=[],a=Lv(e);!(n=a()).done;){var i=n.value;if(i<0){if(!t)throw new Error("Dimension "+i+" must be >= 0");if(i<-1)throw new Error("Dimension "+i+" must be >= -1");i=-1}r.push(i)}return r}function Dj(e,t,n,r,a,i,o,s,u,l){return new _j(e,t,n,r,a,i,o,s,u,l).compute()}function Mj(e,t,n,r){if(e===t||e<t&&n<0||t<e&&n>1)return wg(0,r);var a=wg(Math.abs(Math.ceil((t-e)/n)),r);t<e&&1===n&&(n=-1),a[0]=e;for(var i=1;i<a.length;i++)a[i]=a[i-1]+n;return a}var Lj=gG((function(e){return 1/Math.sqrt(e)})),zj=bG(ex,Lj),Pj={kernelName:ex,backendName:"cpu",kernelFunc:zj};function Bj(e,t,n,r,a,i,o,s,u,l){var c=[r/a,a],p=e.values,h=t.values;if(0===r)return KN(n,t.dtype);var d=u instanceof tk?u:KN(c,t.dtype);"string"==typeof u||"number"==typeof u?d.values.fill(u):"boolean"==typeof u&&d.values.fill(+u);for(var f=0;f<i;f++){for(var m=[],v=0,g=0;g<o;g++){var y=p[f*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++)l?d.values[v*a+b]+=h[f*a+b]:d.values[v*a+b]=0===t.rank?h[0]:h[f*a+b]}return d}var Wj=gG((function(e){return 1/(1+Math.exp(-e))})),Vj=yG(cx,(function(e){return 1/(1+Math.exp(-e))})),Uj={kernelName:cx,backendName:"cpu",kernelFunc:Vj};function Gj(e,t,n,r,a){var i=c_(r,t,n),o=Xv(n),s=vg(r);if(i){var u=p_(t,s);return"string"===a?e.slice(u,u+o):e.subarray(u,u+o)}for(var l=KN(r,a,"string"===a?wF(e):e),c=KN(n,a),p=0;p<c.size;++p){var h=c.indexToLoc(p),d=h.map((function(e,n){return e+t[n]}));c.set.apply(c,[l.get.apply(l,d)].concat(h))}return"string"===a?kF(c.values):c.values}function jj(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.begin,o=r.size;KU(a,"slice");var s=h_(a,i,o),u=s[0],l=s[1];e_(a,u,l);var c=Gj(n.data.get(a.dataId).values,u,l,a.shape,a.dtype);return n.makeTensorInfo(l,a.dtype,c)}var Hj={kernelName:ox,backendName:"cpu",kernelFunc:jj};function qj(e,t,n,r,a,i,o){var s=t[0],u=i[0],l=new Array(u),c=new Array(s),p=t[1];if(0===u){if(0!==s)throw new Error(oF(s));return[ag(n,0),[0,p],ag(a,0),l,c]}for(var h=!0,d=0,f=new Array(u).fill(0),m=0;m<s;++m){var v=e[m*p];if(v<0)throw new Error(sF(m,v));if(v>=u)throw new Error(uF(m,v,u));++f[v],h=h&&v>=d,d=v}for(var g=!0,y=0;y<u;++y){var b=0===f[y];l[y]=b,g=g&&!b,f[y]=Math.max(f[y],1),y>0&&(f[y]+=f[y-1])}if(g&&h){for(var x=e,w=r,k=0;k<s;++k)c[k]=k;return[x,[s,p],w,l,c]}for(var N=f[u-1],I=ag(n,N*p),S=ag(a,N),T=new Array(u).fill(0),C=0;C<s;++C){var E=e[C*p],A=T[E],R=(0===E?0:f[E-1])+A;T[E]++;for(var _=0;_<p;++_)I[R*p+_]=e[C*p+_];S[R]=r[C],c[C]=R}for(var F=0;F<u;++F){if(0===T[F]){var O=0===F?0:f[F-1];I[O*p+0]=F;for(var D=1;D<p;++D)I[O*p+D]=0;S[O]=o}}return[I,[N,p],S,l,c]}function Kj(e,t,n,r,a){for(var i=Xv(r),o=t[0],s=a.length,u=[],l=1,c=-1,p=0;p<s;++p){var h=a[p];if(-1===h){if(-1!==c)throw new Error(lF(c,p));c=p,u.push(1)}else{if(h<0)throw new Error(cF(p,h));l*=h,u.push(h)}}if(-1!==c){if(l<=0)throw new Error("reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero");var d=Math.trunc(i/l);if(l*d!==i)throw new Error(hF(r,u));u[c]=d}if(Xv(u)!==i)throw new Error(dF(r,u));var f=r.length,m=[];if(f>0){m[f-1]=1;for(var v=f-2;v>=0;--v)m[v]=m[v+1]*r[v+1]}var g=[];if(s>0){g[s-1]=1;for(var y=s-2;y>=0;--y)g[y]=g[y+1]*u[y+1]}for(var b=ag(n,o*s),x=0;x<o;++x){for(var w=0,k=0;k<f;++k)w+=e[x*f+k]*m[k];for(var N=0;N<s;++N)b[x*s+N]=Math.trunc(w/g[N]),w%=g[N]}return[b,[o,s],u]}function Xj(e,t,n,r,a,i,o){void 0===i&&(i=!1),void 0===o&&(o=0);var s=r.length,u=[t[0],e.length/t[0]],l=u[1],c=s>0?a[s-1]+1:0;if(c<0)throw new Error("segment ids must be >= 0");var p=t.slice();p[0]=c;var h=ag(n,p.reduce((function(e,t){return e*t}),1));if(0===s)return c>0&&h.fill(o),[h,p];if(c<=0)throw new Error("segment ids must be >= 0");for(var d=0,f=1,m=0,v=a[d];;){var g=0;if(f<s){if(v===(g=a[f])){++f;continue}if(v>=g)throw new Error("segment ids are not increasing")}if(v<0||v>=c)throw new Error(vF(v,c));v>m&&h.fill(o,m*l,v*l);for(var y=d;y<f;++y){var b=r[y];if(b<0||b>=u[0])throw new Error(gF(y,r[y],u[0]));for(var x=0;x<l;x++)h[v*l+x]+=e[b*l+x]}if(i)for(var w=0;w<l;w++)h[v*l+w]/=f-d;if(d=f,m=v+1,v=g,++f>s)break}return m<c&&h.fill(o,m*l,c*l),[h,p]}var Yj=gG((function(e){return Math.sqrt(e)})),Jj=yG(hx,(function(e){return Math.sqrt(e)})),Zj={kernelName:hx,backendName:"cpu",kernelFunc:Jj},Qj=QU((function(e,t){var n=e-t;return n*n})),$j=lG(kx,Qj),eH={kernelName:kx,backendName:"cpu",kernelFunc:$j},tH=gG((function(e,t){var n=t.pattern,r=t.replaceGlobal,a=t.rewrite;return e.replace(new RegExp(n,r?"g":""),a)})),nH=bG(Ix,tH),rH={kernelName:Ix,backendName:"cpu",kernelFunc:nH};function aH(e,t,n,r){for(var a=KN(e,t.dtype),i=0;i<a.size;i++){for(var o=a.indexToLoc(i),s=new Array(o.length),u=0;u<s.length;u++)s[u]=o[u]*n[u]+r[u];a.set.apply(a,[t.get.apply(t,s)].concat(o))}return a}var iH=function(){function e(e,t,n,r,a,i){this.separator=Gw(e),this.nGramWidths=t,this.leftPad=Gw(n),this.rightPad=Gw(r),this.padWidth=a,this.preserveShort=i}var t=e.prototype;return t.getPadWidth=function(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)},t.getNumNGrams=function(e,t){var n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)},t.createNGrams=function(e,t,n,r,a,i){for(var o=this,s=function(s){var u=o.getPadWidth(i),l=Math.max(0,u-s),c=Math.max(0,u-(a-(s+1))),p=i-(l+c),h=t+(l>0?0:s-u),d=0;d+=l*o.leftPad.length;for(var f=0;f<p;++f)d+=e[h+f].length;d+=c*o.rightPad.length,d+=(l+c+p-1)*o.separator.length,n[r+s]=new Uint8Array(d);for(var m=n[r+s],v=0,g=function(e){return e.forEach((function(e){return m[v++]=e}))},y=0;y<l;++y)g(o.leftPad),g(o.separator);for(var b=0;b<p-1;++b)g(e[h+b]),g(o.separator);if(p>0){g(e[h+p-1]);for(var x=0;x<c;++x)g(o.separator),g(o.rightPad)}else{for(var w=0;w<c-1;++w)g(o.rightPad),g(o.separator);g(o.rightPad)}},u=0;u<a;++u)s(u)},t.compute=function(e,t){var n=this,r=e.length,a=t.length;if(a>0){var i=t[0];if(0!==i)throw new Error("First split value must be 0, got "+i);for(var o=1;o<a;++o){var s=t[o]>=i;if(!(s=s&&t[o]<=r))throw new Error("Invalid split value "+t[o]+", must be in ["+i+", "+r+"]");i=t[o]}if(i!==r)throw new Error("Last split value must be data size. Expected "+r+", got "+i)}var u=a-1,l=ag("int32",a);if(0===r||0===a){for(var c=new Array(r),p=0;p<=u;++p)l[p]=0;return[c,l]}l[0]=0;for(var h=function(e){var r=t[e]-t[e-1],a=0;n.nGramWidths.forEach((function(e){a+=n.getNumNGrams(r,e)})),n.preserveShort&&r>0&&0===a&&(a=1),l[e]=l[e-1]+a},d=1;d<=u;++d)h(d);for(var f=new Array(l[u]),m=function(r){var a=t[r],i=l[r];if(n.nGramWidths.forEach((function(o){var s=t[r+1]-t[r],u=n.getNumNGrams(s,o);n.createNGrams(e,a,f,i,u,o),i+=u})),n.preserveShort&&i===l[r]){var o=t[r+1]-t[r];if(0===o)return"continue";var s=o+2*n.padWidth;n.createNGrams(e,a,f,i,1,s)}},v=0;v<u;++v)m(v);return[f,l]},e}();function oH(e,t,n,r,a,i,o,s){return new iH(n,r,a,i,o,s).compute(e,t)}function sH(e,t,n,r){if(e.length)if(0!==t.length)if(1!==t.length){for(var a=0,i=0;i<e.length+1;i++)if(i===e.length||-1!==t.indexOf(e[i])){var o=e.subarray(a,i);n&&0===o.length||r.push(o),a=i+1}}else{for(var s=t[0],u=e.indexOf(s);-1!==u;){var l=e.subarray(0,u);n&&0===l.length||r.push(l),u=(e=e.subarray(u+1)).indexOf(s)}n&&0===e.length||r.push(e)}else for(var c=0;c<e.length;++c)r.push(e.subarray(c,c+1))}function uH(e,t,n){for(var r=e.length,a=[],i=0,o=0,s=new Array(r),u=0;u<r;++u){var l=a.length;sH(e[u],t,n,a);var c=a.length-l;s[u]=c,i+=c,o=Math.max(o,c)}for(var p=ag("int32",2*i),h=new Array(i),d=[r,o],f=0,m=0;m<r;++m)for(var v=0;v<s[m];++v)p[2*f]=m,p[2*f+1]=v,h[f]=a[f],++f;return[p,h,d]}function lH(e,t){for(var n=ag("int32",e.length),r=0;r<e.length;++r)n[r]=Pw(e[r]).modulo(t).getLowBitsUnsigned();return n}var cH=QU((function(e,t){return e-t})),pH=cG((function(e,t,n,r){return{real:e-n,imag:t-r}})),hH=lG(Ax,cH,pH),dH={kernelName:Ax,backendName:"cpu",kernelFunc:hH};function fH(e,t){for(var n=new Array(e.rank),r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];for(var a=KN(n,e.dtype),i=0;i<a.values.length;++i){for(var o=a.indexToLoc(i),s=new Array(e.rank),u=0;u<s.length;u++)s[u]=o[u]%e.shape[u];var l=e.locToIndex(s);a.values[i]=e.values[l]}return a}var mH=function(e,t){var n=t.value-e.value;return 0===n?e.index-t.index:n};function vH(e,t,n,r){for(void 0===n&&(n=0),void 0===r&&(r=e.length-1);r>n;){if(r-n>600){var a=r-n+1,i=t-n+1,o=Math.log(a),s=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*s*(a-s)/a)*Math.sign(i-a/2);vH(e,t,Math.max(n,Math.floor(t-i*s/a+u)),Math.min(r,Math.floor(t+(a-i)*s/a+u)))}var l=e[t],c=n,p=r;for(Gv(e,n,t),mH(e[r],l)>0&&Gv(e,n,r);c<p;){for(Gv(e,c,p),c++,p--;mH(e[c],l)<0;)c+=1;for(;mH(e[p],l)>0;)p-=1}0===mH(e[n],l)?Gv(e,n,p):Gv(e,p+=1,r),p<=t&&(n=p+1),t<=p&&(r=p-1)}}function gH(e,t,n,r,a){for(var i=t[t.length-1],o=e.length/i,s=i,u=rg(n,o*r),l=rg("int32",o*r),c=function(t){var n=t*s,i=e.subarray(n,n+s),o=new Array(i.length);i.forEach((function(e,t){return o[t]={value:e,index:t}})),r<o.length&&(vH(o,r),o=o.slice(0,r)),a&&o.sort(mH);for(var c=t*r,p=u.subarray(c,c+r),h=l.subarray(c,c+r),d=0;d<r;d++)p[d]=o[d].value,h[d]=o[d].index},p=0;p<o;p++)c(p);var h=t.slice();return h[h.length-1]=r,[KN(h,n,u),KN(h,"int32",l)]}function yH(e,t,n,r){for(var a=tg(t,n)[0],i=[1,n[0],1],o=0;o<a;o++)i[0]*=n[o];i[1]=n[a];for(var s=a+1;s<n.length;s++)i[2]*=n[s];for(var u=new Map,l=new Int32Array(n[a]),c=new tk(i,r,e),p=[],h=1===i[0]&&1===i[2],d=0;d<n[a];d++){var f=void 0;if(h)f=e[d].toString();else{for(var m=[],v=0;v<i[0];v++)for(var g=0;g<i[2];g++)m.push(c.get(v,d,g));f=m.join(",")}var y=u.get(f);if(null!=y)l[d]=y;else{var b=u.size;u.set(f,b),l[d]=b,p.push(d)}}var x=i.slice();x[1]=u.size;var w=new tk(x,r);p.forEach((function(e,t){for(var n=0;n<i[0];n++)for(var r=0;r<i[2];r++)w.set(c.get(n,e,r),n,t,r)}));var k=n.slice();return k[a]=x[1],{outputValues:w.values,outputShape:k,indices:l}}var bH={__proto__:null,simpleAbsImpl:JU,addImpl:pG,bincountImpl:mG,bincountReduceImpl:vG,castImpl:oG,ceilImpl:xG,concatImpl:NG,equalImpl:IG,expImpl:CG,expm1Impl:RG,floorImpl:OG,floorDivImpl:LG,gatherNdImpl:BG,gatherV2Impl:WG,greaterImpl:VG,greaterEqualImpl:jG,lessImpl:KG,lessEqualImpl:JG,linSpaceImpl:$G,logImpl:ej,maxImpl:rj,maximumImpl:aj,minimumImpl:sj,multiplyImpl:cj,negImpl:fj,notEqualImpl:vj,prodImpl:kj,raggedGatherImpl:Cj,raggedRangeImpl:Aj,raggedTensorToTensorImpl:Dj,rangeImpl:Mj,rsqrtImpl:Lj,scatterImpl:Bj,sigmoidImpl:Wj,sliceImpl:Gj,sparseFillEmptyRowsImpl:qj,sparseReshapeImpl:Kj,sparseSegmentReductionImpl:Xj,sqrtImpl:Yj,squaredDifferenceImpl:Qj,staticRegexReplaceImpl:tH,stridedSliceImpl:aH,stringNGramsImpl:oH,stringSplitImpl:uH,stringToHashBucketFastImpl:lH,subImpl:cH,tileImpl:fH,topKImpl:gH,transposeImpl:bj,uniqueImpl:yH},xH="4.3.0";aI("cpu",(function(){return new YU}),1);var wH=yG(Fy,(function(e){return e>=0?e:Math.exp(e)-1})),kH={kernelName:Fy,backendName:"cpu",kernelFunc:wH};function NH(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.alpha;KU([a],"leakyRelu");for(var o=Xv(a.shape),s=n.data.get(a.dataId).values,u=rg("float32",o),l=0;l<s.length;l++)u[l]=s[l]<0?i*s[l]:s[l];return n.makeTensorInfo(a.shape,"float32",u)}var IH={kernelName:tb,backendName:"cpu",kernelFunc:NH},SH=QU((function(e,t){return e<0?t*e:e}));function TH(e){var t=e.inputs,n=e.backend,r=t.x,a=t.alpha;KU([r,a],"prelu");var i=n.data.get(r.dataId).values,o=n.data.get(a.dataId).values,s=SH(r.shape,a.shape,i,o,"float32"),u=s[0],l=s[1];return n.makeTensorInfo(l,"float32",u)}var CH={kernelName:zb,backendName:"cpu",kernelFunc:TH},EH=yG(Hb,(function(e){return Math.max(0,e)})),AH={kernelName:Hb,backendName:"cpu",kernelFunc:EH},RH=yG(Zb,(function(e){return Math.min(Math.max(0,e),6)})),_H={kernelName:Zb,backendName:"cpu",kernelFunc:RH};function FH(e,t,n,r,a){if("linear"===n)return nG({inputs:{x:t},backend:e});if("relu"===n)return EH({inputs:{x:t},backend:e});if("elu"===n)return wH({inputs:{x:t},backend:e});if("relu6"===n)return RH({inputs:{x:t},backend:e});if("prelu"===n)return TH({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return NH({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return Vj({inputs:{x:t},backend:e});throw new Error("Activation "+n+" has not been implemented for the CPU backend.")}function OH(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.shape,o=Xv(a.shape),s=eg(i,o),u=Xv(s);Hv(o===u,(function(){return"The new shape ("+s+") has "+u+" elements and the old shape ("+a.shape+") has "+o+" elements. The new shape and old shape must have the same number of elements."})),n.incRef(a.dataId);var l=n.data.get(a.dataId);if(null!=l.complexTensorInfos){var c=l.complexTensorInfos.real,p=l.complexTensorInfos.imag;c.shape=s,p.shape=s}return{dataId:a.dataId,shape:s,dtype:a.dtype}}var DH={kernelName:qb,backendName:"cpu",kernelFunc:OH};function MH(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.a,i=t.b,o=r.transposeA,s=r.transposeB;KU([a,i],"matMul");var u=a.shape.length,l=i.shape.length,c=o?a.shape[u-2]:a.shape[u-1],p=s?i.shape[l-1]:i.shape[l-2],h=o?a.shape[u-1]:a.shape[u-2],d=s?i.shape[l-2]:i.shape[l-1],f=a.shape.slice(0,-2),m=i.shape.slice(0,-2),v=Xv(f),g=Xv(m),y=TS(a.shape.slice(0,-2),i.shape.slice(0,-2)).concat([h,d]);Hv(c===p,(function(){return"Error in matMul: inner shapes ("+c+") and ("+p+") of Tensors with shapes "+a.shape+" and "+i.shape+" and transposeA="+o+" and transposeB="+s+" must match."}));for(var b=s?[g,d,p]:[g,p,d],x=OH({inputs:{x:a},backend:n,attrs:{shape:o?[v,c,h]:[v,h,c]}}),w=OH({inputs:{x:i},backend:n,attrs:{shape:b}}),k=o?x.shape[1]:x.shape[2],N=o?x.shape[2]:x.shape[1],I=s?w.shape[1]:w.shape[2],S=Math.max(v,g),T=n.data.get(x.dataId).values,C=n.data.get(w.dataId).values,E=vg(x.shape),A=vg(w.shape),R=o?[E[0],1,E[1]]:[E[0],E[1],1],_=R[0],F=R[1],O=R[2],D=s?[1,A[1],A[0]]:[A[1],1,A[0]],M=D[0],L=D[1],z=D[2],P=N*I,B=KN([S,N,I],x.dtype),W=B.values,V=n.blockSize,U=0;U<S;U++)for(var G=U%v,j=U%g,H=0;H<N;H+=V)for(var q=Math.min(H+V,N),K=0;K<I;K+=V)for(var X=Math.min(K+V,I),Y=0;Y<k;Y+=V)for(var J=Math.min(Y+V,k),Z=H;Z<q;Z++)for(var Q=K;Q<X;Q++){for(var $=0,ee=Y;ee<J;ee++){$+=T[G*_+Z*F+ee*O]*C[ee*M+Q*L+j*z]}W[U*P+(Z*I+Q)]+=$}return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(w),n.makeTensorInfo(y,B.dtype,B.values)}var LH={kernelName:$g,backendName:"cpu",kernelFunc:MH};var zH={kernelName:Gx,backendName:"cpu",kernelFunc:function(e){var t,n,r,a=e.inputs,i=e.backend,o=e.attrs,s=a.a,u=a.b,l=a.bias,c=a.preluActivationWeights,p=o.transposeA,h=o.transposeB,d=o.activation,f=o.leakyreluAlpha,m=[];t=MH({inputs:{a:s,b:u},attrs:{transposeA:p,transposeB:h},backend:i}),l&&(n=dG({inputs:{a:t,b:l},backend:i}),m.push(t),t=n),d&&(r=FH(i,t,d,c,f),m.push(t),t=r);for(var v=0,g=m;v<g.length;v++){var y=g[v];i.disposeIntermediateTensorInfo(y)}return t}},PH=yG(Lg,(function(e){return Math.acos(e)})),BH={kernelName:Lg,backendName:"cpu",kernelFunc:PH},WH=yG(zg,(function(e){return Math.acosh(e)})),VH={kernelName:zg,backendName:"cpu",kernelFunc:WH};var UH={kernelName:Bg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t;KU(t,"addN");for(var a=r.map((function(e){return n.data.get(e.dataId).values})),i=KN(r[0].shape,r[0].dtype),o=i.values,s=0;s<r.length;s++)for(var u=a[s],l=0;l<o.length;l++)o[l]+=u[l];return n.makeTensorInfo(i.shape,i.dtype,i.values)}};var GH={kernelName:Wg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims;KU(a,"all");var s=tg(i,a.shape),u=s,l=VS(u,a.shape.length),c=a;null!=l&&(c=xj({inputs:{x:a},backend:n,attrs:{perm:l}}),u=GS(u.length,a.shape.length)),WS("all",u,c.shape.length);for(var p=PS(c.shape,u),h=p[0],d=Xv(p[1]),f=wg(Xv(h),c.dtype),m=n.data.get(c.dataId).values,v=0;v<f.length;++v){for(var g=v*d,y=m[g],b=0;b<d;++b){var x=m[g+b];y=y&&x}f[v]=y}null!=l&&n.disposeIntermediateTensorInfo(c);var w=n.makeTensorInfo(h,c.dtype,f);if(o){var k=OH({inputs:{x:w},backend:n,attrs:{shape:BS(h,s)}});return n.disposeIntermediateTensorInfo(w),k}return w}};var jH={kernelName:Vg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims;KU(a,"any");var s=tg(i,a.shape),u=s,l=VS(u,a.shape.length),c=a;null!=l&&(c=xj({inputs:{x:a},backend:n,attrs:{perm:l}}),u=GS(u.length,a.shape.length)),WS("any",u,c.shape.length);for(var p=PS(c.shape,u),h=p[0],d=Xv(p[1]),f=wg(Xv(h),c.dtype),m=n.data.get(c.dataId).values,v=0;v<f.length;++v){for(var g=v*d,y=m[g],b=0;b<d;++b){var x=m[g+b];y=y||x}f[v]=y}null!=l&&n.disposeIntermediateTensorInfo(c);var w=n.makeTensorInfo(h,c.dtype,f);if(o){var k=OH({inputs:{x:w},backend:n,attrs:{shape:BS(h,s)}});return n.disposeIntermediateTensorInfo(w),k}return w}};var HH={kernelName:Ug,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis;KU(a,"argMax");var o=tg(i,a.shape),s=VS(o,a.shape.length),u=a,l=[];null!=s&&(u=xj({inputs:{x:a},backend:n,attrs:{perm:s}}),l.push(u),o=GS(o.length,u.shape.length)),WS("argMax",o=[o[0]],u.shape.length);for(var c=PS(u.shape,o),p=c[0],h=c[1],d=wg(Xv(p),"int32"),f=Xv(h),m=n.data.get(u.dataId).values,v=0;v<d.length;++v){for(var g=v*f,y=m[g],b=0,x=0;x<f;++x){var w=m[g+x];w>y&&(y=w,b=x)}d[v]=b}return l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(p,"int32",d)}};var qH={kernelName:Gg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis;KU(a,"argMin");var o=tg(i,a.shape),s=VS(o,a.shape.length),u=a,l=[];null!=s&&(u=xj({inputs:{x:a},backend:n,attrs:{perm:s}}),l.push(u),o=GS(o.length,u.shape.length)),WS("argMin",o=[o[0]],u.shape.length);for(var c=PS(u.shape,o),p=c[0],h=c[1],d=wg(Xv(p),"int32"),f=Xv(h),m=n.data.get(u.dataId).values,v=0;v<d.length;++v){for(var g=v*f,y=m[g],b=0,x=0;x<f;++x){var w=m[g+x];w<y&&(y=w,b=x)}d[v]=b}return l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(p,"int32",d)}},KH=yG(jg,(function(e){return Math.asin(e)})),XH={kernelName:jg,backendName:"cpu",kernelFunc:KH},YH=yG(Hg,(function(e){return Math.asinh(e)})),JH={kernelName:Hg,backendName:"cpu",kernelFunc:YH},ZH=yG(qg,(function(e){return Math.atan(e)})),QH={kernelName:qg,backendName:"cpu",kernelFunc:ZH},$H=QU((function(e,t){return Math.atan2(e,t)})),eq=lG(Xg,$H),tq={kernelName:Xg,backendName:"cpu",kernelFunc:eq},nq=yG(Kg,(function(e){return Math.atanh(e)})),rq={kernelName:Kg,backendName:"cpu",kernelFunc:nq};function aq(e,t,n,r,a,i){for(var o=a.strideHeight,s=a.strideWidth,u=a.dilationHeight,l=a.dilationWidth,c=a.effectiveFilterHeight,p=a.effectiveFilterWidth,h=a.padInfo.top,d=a.padInfo.left,f="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=KN(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],N=0;N<a.inChannels;++N)for(var I=0;I<a.outHeight;++I)for(var S=I*o-h,T=Math.max(0,S),C=Math.min(a.inHeight,c+S),E=w+I*y,A=0;A<a.outWidth;++A){for(var R=A*s-d,_=Math.max(0,R),F=Math.min(a.inWidth,p+R),O=f,D=0,M=0,L=T;L<C;L+=u){for(var z=k+L*r[1],P=_;P<F;P+=l){var B=e[z+P*r[2]+N];"max"===i&&B>O?O=B:"avg"===i&&(D+=B,M++)}if(isNaN(O))break}v[E+A*b+N]="avg"===i?D/M:O}return m}function iq(e,t,n,r,a,i){void 0===a&&(a=!1),void 0===i&&(i=!1);for(var o=KN(r.outShape,"int32"),s=r.strideHeight,u=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,p=r.effectiveFilterHeight,h=r.effectiveFilterWidth,d=r.padInfo.top,f=r.padInfo.left,m=KN(t,n,e),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-d,x=b;x<0;)x+=l;for(var w=Math.min(r.inHeight,p+b),k=0;k<r.outWidth;++k){for(var N=k*u-f,I=N;I<0;)I+=c;for(var S=Math.min(r.inWidth,h+N),T=Number.NEGATIVE_INFINITY,C=-1,E=x;E<w;E+=l)for(var A=E-b,R=I;R<S;R+=c){var _=R-N,F=m.get(v,E,R,g);F>T&&(T=F,C=a?i?((v*r.inHeight+E)*r.inWidth+R)*r.inChannels+g:(E*r.inWidth+R)*r.inChannels+g:A*h+_)}o.set(C,v,y,k,g)}}return o}function oq(e,t,n,r,a,i){for(var o=a.strideDepth,s=a.strideHeight,u=a.strideWidth,l=a.dilationDepth,c=a.dilationHeight,p=a.dilationWidth,h=a.effectiveFilterDepth,d=a.effectiveFilterHeight,f=a.effectiveFilterWidth,m=a.padInfo.front,v=a.padInfo.top,g=a.padInfo.left,y="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,b=KN(a.outShape,n),x=b.values,w=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],k=a.outShape[2]*a.outShape[3]*a.outShape[4],N=a.outShape[3]*a.outShape[4],I=a.outShape[4],S=0;S<a.batchSize;++S)for(var T=S*w,C=S*r[0],E=0;E<a.inChannels;++E)for(var A=0;A<a.outDepth;++A){for(var R=A*o-m,_=R;_<0;)_+=l;for(var F=Math.min(a.inDepth,h+R),O=T+A*k,D=0;D<a.outHeight;++D){for(var M=D*s-v,L=M;L<0;)L+=c;for(var z=Math.min(a.inHeight,d+M),P=O+D*N,B=0;B<a.outWidth;++B){for(var W=B*u-g,V=W;V<0;)V+=p;for(var U=Math.min(a.inWidth,f+W),G=P+B*I,j=y,H=0,q=0,K=_;K<F;K+=l){for(var X=C+K*r[1],Y=L;Y<z;Y+=c){for(var J=X+Y*r[2],Z=V;Z<U;Z+=p){var Q=e[J+Z*r[3]+E];if("max"===i&&Q>j?j=Q:"avg"===i&&(H+=Q,q++),isNaN(j))break}if(isNaN(j))break}if(isNaN(j))break}x[G+E]="avg"===i?H/Math.max(q,1):j}}}return b}var sq={kernelName:Yg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;KU(a,"avgPool");var i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode;Hv(DI(o,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '1'"}));var l,c=II(a.shape,i,o,1,s,u);if(1===c.filterWidth&&1===c.filterHeight&&Yv(c.inShape,c.outShape))l=nG({inputs:{x:a},backend:n});else{var p=n.data.get(a.dataId).values,h=vg(a.shape),d=aq(p,a.shape,a.dtype,h,c,"avg");l=n.makeTensorInfo(c.outShape,a.dtype,d.values)}return l}};var uq={kernelName:Zg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode,l=r.dataFormat;KU(a,"avgPool3d");var c=SI(a.shape,i,o,1,s,u,l),p=oq(n.data.get(a.dataId).values,a.shape,a.dtype,vg(a.shape),c,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}};var lq={kernelName:Qg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=r.filterSize,s=r.strides,u=r.pad,l=r.dimRoundingMode;KU([a,i],"avgPool3DGrad");for(var c=SI(i.shape,o,s,1,u,l),p=c.strideDepth,h=c.strideHeight,d=c.strideWidth,f=c.filterDepth,m=c.filterHeight,v=c.filterWidth,g=c.dilationDepth,y=c.dilationHeight,b=c.dilationWidth,x=c.effectiveFilterDepth,w=c.effectiveFilterHeight,k=c.effectiveFilterWidth,N=x-1-c.padInfo.front,I=k-1-c.padInfo.left,S=w-1-c.padInfo.top,T=KN(i.shape,"float32"),C=1/(f*m*v),E=n.bufferSync(a),A=0;A<c.batchSize;++A)for(var R=0;R<c.inChannels;++R)for(var _=0;_<c.inDepth;++_)for(var F=0;F<c.inHeight;++F)for(var O=0;O<c.inWidth;++O){for(var D=_-N,M=F-S,L=O-I,z=0,P=0;P<x;P+=g){var B=(D+P)/p;if(!(B<0||B>=c.outDepth||Math.floor(B)!==B))for(var W=0;W<w;W+=y){var V=(M+W)/h;if(!(V<0||V>=c.outHeight||Math.floor(V)!==V))for(var U=0;U<k;U+=b){var G=(L+U)/d;if(!(G<0||G>=c.outWidth||Math.floor(G)!==G))z+=E.get(A,B,V,G,R)}}}T.set(z*C,A,_,F,O,R)}return n.makeTensorInfo(T.shape,T.dtype,T.values)}};var cq={kernelName:Jg,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=i;KU([a,i],"avgPoolGrad");for(var s=r.filterSize,u=r.strides,l=r.pad,c=II(o.shape,s,u,1,l),p=c.strideHeight,h=c.strideWidth,d=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,v=c.dilationWidth,g=c.effectiveFilterHeight,y=c.effectiveFilterWidth,b=y-1-c.padInfo.left,x=g-1-c.padInfo.top,w=KN(o.shape,"float32"),k=1/(d*f),N=n.data.get(a.dataId).values,I=KN(a.shape,"float32",N),S=0;S<c.batchSize;++S)for(var T=0;T<c.inChannels;++T)for(var C=0;C<c.inHeight;++C)for(var E=0;E<c.inWidth;++E){for(var A=C-x,R=E-b,_=0,F=0;F<g;F+=m){var O=(A+F)/p;if(!(O<0||O>=c.outHeight||Math.floor(O)!==O))for(var D=0;D<y;D+=v){var M=(R+D)/h;if(!(M<0||M>=c.outWidth||Math.floor(M)!==M))_+=I.get(S,O,M,T)}}w.set(_*k,S,C,E,T)}return n.makeTensorInfo(w.shape,w.dtype,w.values)}};var pq={kernelName:jy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.scale,o=t.offset,s=t.mean,u=t.variance;Hv(s.shape.length===u.shape.length,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),Hv(null==o||s.shape.length===o.shape.length,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),Hv(null==i||s.shape.length===i.shape.length,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."})),KU([a,s,u,i,o],"batchNorm");var l=r.varianceEpsilon;null==l&&(l=.001);for(var c=n.data.get(a.dataId).values,p=n.data.get(s.dataId).values,h=n.data.get(u.dataId).values,d=i?n.data.get(i.dataId).values:new Float32Array([1]),f=o?n.data.get(o.dataId).values:new Float32Array([0]),m=new Float32Array(c.length),v=f.length,g=d.length,y=h.length,b=p.length,x=0,w=0,k=0,N=0,I=0;I<c.length;++I)m[I]=f[x++]+(c[I]-p[w++])*d[k++]/Math.sqrt(h[N++]+l),x>=v&&(x=0),w>=b&&(w=0),k>=g&&(k=0),N>=y&&(N=0);return n.makeTensorInfo(a.shape,a.dtype,m)}};var hq={kernelName:ey,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockShape,o=r.crops;KU([a],"batchToSpaceND");var s=i.reduce((function(e,t){return e*t})),u=R_(a.shape,i,s),l=__(u.length,i.length),c=F_(a.shape,i,s),p=O_(o,i.length),h=D_(c,o,i.length),d=OH({inputs:{x:a},backend:n,attrs:{shape:u}}),f=xj({inputs:{x:d},backend:n,attrs:{perm:l}}),m=OH({inputs:{x:f},backend:n,attrs:{shape:c}}),v=jj({inputs:{x:m},backend:n,attrs:{begin:p,size:h}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),v}};var dq={kernelName:ty,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.weights,o=r.size,s=mG(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,s)}};var fq={kernelName:ry,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.s0,a=t.s1,i=n.data.get(r.dataId).values,o=n.data.get(a.dataId).values,s=TS(Array.from(i),Array.from(o));return n.makeTensorInfo([s.length],"int32",Int32Array.from(s))}},mq=yG(oy,(function(e,t){var n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e})),vq={kernelName:oy,backendName:"cpu",kernelFunc:mq},gq={kernelName:uy,backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs.x,n=e.backend,r=new Float32Array(Xv(t.shape)),a=n.data.get(t.dataId),i=a.complexTensorInfos.real,o=a.complexTensorInfos.imag,s=n.data.get(i.dataId).values,u=n.data.get(o.dataId).values,l=0;l<s.length;l++){var c=s[l],p=u[l];r[l]=Math.hypot(c,p)}return n.makeOutput(r,t.shape,"float32")}};function yq(e){var t=e.inputs,n=e.backend,r=t.input,a=n.data.get(r.dataId).complexTensorInfos.imag,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}var bq={kernelName:Zy,backendName:"cpu",kernelFunc:yq};function xq(e){var t=e.inputs,n=e.backend,r=tg(e.attrs.axis,t[0].shape)[0];k_(t.map((function(e){return e.shape})),r);var a=N_(t.map((function(e){return e.shape})),r);if(0===Xv(a))return n.makeTensorInfo(a,t[0].dtype,[]);var i=t.filter((function(e){return Xv(e.shape)>0}));if(1===i.length)return nG({inputs:{x:i[0]},backend:n});if("complex64"===i[0].dtype){var o=i.map((function(e){return aG({inputs:{input:e},backend:n})})),s=i.map((function(e){return yq({inputs:{input:e},backend:n})})),u=xq({inputs:o,backend:n,attrs:{axis:r}}),l=xq({inputs:s,backend:n,attrs:{axis:r}}),c=$U({inputs:{real:u,imag:l},backend:n});return o.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),s.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(l),c}var p=i.map((function(e){var t=Xv(e.shape.slice(r));return OH({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),h=p.map((function(e){return{vals:n.data.get(e.dataId).values,shape:e.shape}}));a=N_(p.map((function(e){return e.shape})),1);var d=1===p[0].shape[0],f=NG(h,a,t[0].dtype,d),m=N_(i.map((function(e){return e.shape})),r),v=n.makeTensorInfo(m,t[0].dtype,f);return p.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),v}var wq={kernelName:ly,backendName:"cpu",kernelFunc:xq};function kq(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dataFormat,l=r.dilations,c=r.dimRoundingMode;KU([a,i],"conv2d");for(var p=LI(u),h=TI(a.shape,i.shape,o,l,s,c,!1,p),d=h.filterHeight,f=h.filterWidth,m=h.dilationHeight,v=h.dilationWidth,g=h.padInfo.left,y=h.padInfo.top,b="channelsLast"===h.dataFormat,x=new tk(h.outShape,a.dtype),w=vg(a.shape),k=vg(i.shape),N=w[0],I=b?w[1]:w[2],S=b?w[2]:1,T=b?1:w[1],C=x.strides[0],E=b?x.strides[1]:x.strides[2],A=b?x.strides[2]:1,R=b?1:x.strides[1],_=n.data.get(a.dataId).values,F=n.data.get(i.dataId).values,O=x.values,D=0;D<h.batchSize;++D)for(var M=D*N,L=D*C,z=0;z<h.outHeight;++z)for(var P=L+z*E,B=z*h.strideHeight-y,W=0;W<d;++W){var V=B+W*m;if(!(V<0||V>=h.inHeight))for(var U=W*k[0],G=M+V*I,j=0;j<h.outWidth;++j)for(var H=P+j*A,q=j*h.strideWidth-g,K=0;K<f;++K){var X=q+K*v;if(!(X<0||X>=h.inWidth))for(var Y=G+X*S,J=U+K*k[1],Z=0;Z<h.inChannels;++Z){for(var Q=_[Y+Z*T],$=0;$<h.outChannels;++$)O[H+$*R]+=Q*F[J+$];J+=h.outChannels}}}return n.makeTensorInfo(x.shape,x.dtype,O)}var Nq={kernelName:cy,backendName:"cpu",kernelFunc:kq};var Iq={kernelName:py,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.pad,u=r.dataFormat,l=r.dimRoundingMode,c=r.filterShape;KU([a,i],"conv2dBackpropFilter");for(var p=LI(u),h=TI(a.shape,c,o,1,s,l,!1,p),d=h.strideHeight,f=h.strideWidth,m=h.filterHeight,v=h.filterWidth,g="channelsLast"===h.dataFormat,y=new tk(h.filterShape,"float32"),b=h.padInfo.left,x=h.padInfo.top,w=n.data.get(a.dataId).values,k=n.data.get(i.dataId).values,N=new tk(a.shape,a.dtype,w),I=new tk(i.shape,i.dtype,k),S=0;S<m;++S)for(var T=Math.max(0,Math.ceil((x-S)/d)),C=Math.min(h.outHeight,(h.inHeight+x-S)/d),E=0;E<v;++E)for(var A=Math.max(0,Math.ceil((b-E)/f)),R=Math.min(h.outWidth,(h.inWidth+b-E)/f),_=0;_<h.inChannels;++_)for(var F=0;F<h.outChannels;++F){for(var O=0,D=0;D<h.batchSize;++D)for(var M=T;M<C;++M)for(var L=S+M*d-x,z=A;z<R;++z){var P=E+z*f-b;O+=g?N.get(D,L,P,_)*I.get(D,M,z,F):N.get(D,_,L,P)*I.get(D,F,M,z)}y.set(O,S,E,_,F)}return n.makeTensorInfo(y.shape,y.dtype,y.values)}};var Sq={kernelName:hy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.inputShape,s=r.strides,u=r.pad,l=r.dataFormat,c=r.dimRoundingMode;KU([a,i],"conv2dBackpropInput");var p=vg(i.shape),h=vg(a.shape),d=LI(l),f=TI(o,i.shape,s,1,u,c,!1,d),m=new tk(f.inShape,"float32"),v=m.values,g=n.data.get(a.dataId).values,y=n.data.get(i.dataId).values,b=p[0],x=p[1],w=p[2],k=f.batchSize,N=f.filterHeight,I=f.filterWidth,S=f.inChannels,T=f.inHeight,C=f.inWidth,E=f.outChannels,A=f.outHeight,R=f.outWidth,_=f.strideHeight,F=f.strideWidth;d=f.dataFormat;for(var O=N-1-f.padInfo.top,D=I-1-f.padInfo.left,M="channelsLast"===d,L=m.strides[0],z=M?m.strides[1]:m.strides[2],P=M?m.strides[2]:1,B=M?1:m.strides[1],W=h[0],V=M?h[1]:h[2],U=M?h[2]:1,G=M?1:h[1],j=0;j<k;++j)for(var H=0;H<S;++H)for(var q=0;q<T;++q)for(var K=q-O,X=Math.max(0,Math.ceil(K/_)),Y=Math.min(A,(N+K)/_),J=0;J<C;++J){for(var Z=J-D,Q=Math.max(0,Math.ceil(Z/F)),$=Math.min(R,(I+Z)/F),ee=0,te=X;te<Y;++te)for(var ne=te*_-K,re=Q;re<$;++re)for(var ae=W*j+V*te+U*re,ie=b*(N-1-ne)+x*(I-1-(re*F-Z))+w*H,oe=0;oe<E;++oe){ee+=g[ae+G*oe]*y[ie+oe]}v[L*j+z*q+P*J+B*H]=ee}return n.makeTensorInfo(m.shape,m.dtype,m.values)}};var Tq={kernelName:dy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations;KU([a,i],"conv3d");for(var l=CI(a.shape,i.shape,o,u,s),c=l.filterDepth,p=l.filterHeight,h=l.filterWidth,d=l.dilationDepth,f=l.dilationHeight,m=l.dilationWidth,v=l.padInfo,g=v.front,y=v.left,b=v.top,x=new tk(l.outShape,a.dtype),w=n.data.get(a.dataId).values,k=n.data.get(i.dataId).values,N=x.values,I=vg(a.shape),S=vg(i.shape),T=0;T<l.batchSize;++T)for(var C=T*I[0],E=T*x.strides[0],A=0;A<l.outDepth;++A)for(var R=E+A*x.strides[1],_=A*l.strideDepth-g,F=0;F<c;++F){var O=_+F*d;if(!(O<0||O>=l.inDepth))for(var D=F*S[0],M=C+O*I[1],L=0;L<l.outHeight;++L)for(var z=R+L*x.strides[2],P=L*l.strideHeight-b,B=0;B<p;++B){var W=P+B*f;if(!(W<0||W>=l.inHeight))for(var V=D+B*S[1],U=M+W*I[2],G=0;G<l.outWidth;++G)for(var j=z+G*l.outChannels,H=G*l.strideWidth-y,q=0;q<h;++q){var K=H+q*m;if(!(K<0||K>=l.inWidth))for(var X=V+q*S[2],Y=U+K*l.inChannels,J=X,Z=0;Z<l.inChannels;++Z){for(var Q=w[Y+Z],$=0;$<l.outChannels;++$)N[j+$]+=Q*k[J+$];J+=l.outChannels}}}}return n.makeTensorInfo(x.shape,x.dtype,x.values)}};var Cq={kernelName:fy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.pad,u=r.filterShape;KU([a,i],"conv3dBackpropFilterV2");for(var l=vg(a.shape),c=vg(i.shape),p=CI(a.shape,u,o,1,s),h=p.strideDepth,d=p.strideHeight,f=p.strideWidth,m=p.filterDepth,v=p.filterHeight,g=p.filterWidth,y=new tk(p.filterShape,"float32"),b=y.values,x=y.strides,w=x[0],k=x[1],N=x[2],I=x[3],S=n.data.get(i.dataId).values,T=c[0],C=c[1],E=c[2],A=c[3],R=n.data.get(a.dataId).values,_=l[0],F=l[1],O=l[2],D=l[3],M=p.padInfo.front,L=p.padInfo.left,z=p.padInfo.top,P=0;P<m;++P)for(var B=Math.max(0,Math.ceil((M-P)/h)),W=Math.min(p.outDepth,(p.inDepth+M-P)/h),V=P*w,U=0;U<v;++U)for(var G=Math.max(0,Math.ceil((z-U)/d)),j=Math.min(p.outHeight,(p.inHeight+z-U)/d),H=U*k+V,q=0;q<g;++q)for(var K=Math.max(0,Math.ceil((L-q)/f)),X=Math.min(p.outWidth,(p.inWidth+L-q)/f),Y=q*N+H,J=0;J<p.inChannels;++J)for(var Z=J*I+Y,Q=0;Q<p.outChannels;++Q){for(var $=0,ee=0;ee<p.batchSize;++ee)for(var te=ee*_,ne=ee*T,re=B;re<W;++re)for(var ae=(P+re*h-M)*F+te,ie=re*C+ne,oe=G;oe<j;++oe)for(var se=(U+oe*d-z)*O+ae,ue=oe*E+ie,le=K;le<X;++le){var ce=le*A+ue;$+=R[(q+le*f-L)*D+se+J]*S[ce+Q]}b[Z+Q]=$}return n.makeTensorInfo(y.shape,y.dtype,y.values)}};var Eq={kernelName:my,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.pad,s=r.strides,u=r.inputShape;KU([a],"conv3dBackpropInputV2");for(var l=vg(a.shape),c=vg(i.shape),p=CI(u,i.shape,s,1,o),h=new tk(p.inShape,"float32"),d=h.values,f=h.strides,m=f[0],v=f[1],g=f[2],y=f[3],b=n.data.get(a.dataId).values,x=l[0],w=l[1],k=l[2],N=l[3],I=n.data.get(i.dataId).values,S=c[0],T=c[1],C=c[2],E=c[3],A=p.batchSize,R=p.filterDepth,_=p.filterHeight,F=p.filterWidth,O=p.inChannels,D=p.inDepth,M=p.inHeight,L=p.inWidth,z=p.outChannels,P=p.outDepth,B=p.outHeight,W=p.outWidth,V=p.strideDepth,U=p.strideHeight,G=p.strideWidth,j=R-1-p.padInfo.front,H=_-1-p.padInfo.top,q=F-1-p.padInfo.left,K=0;K<A;++K)for(var X=0;X<O;++X)for(var Y=0;Y<D;++Y)for(var J=Y-j,Z=Math.max(0,Math.ceil(J/V)),Q=Math.min(P,(R+J)/V),$=0;$<M;++$)for(var ee=$-H,te=Math.max(0,Math.ceil(ee/U)),ne=Math.min(B,(_+ee)/U),re=0;re<L;++re){for(var ae=re-q,ie=Math.max(0,Math.ceil(ae/G)),oe=Math.min(W,(F+ae)/G),se=0,ue=Z;ue<Q;++ue)for(var le=ue*V-J,ce=te;ce<ne;++ce)for(var pe=ce*U-ee,he=ie;he<oe;++he)for(var de=x*K+w*ue+k*ce+N*he,fe=S*(R-1-le)+T*(_-1-pe)+C*(F-1-(he*G-ae))+E*X,me=0;me<z;++me){se+=b[de+me]*I[fe+me]}d[m*K+v*Y+g*$+y*re+X]=se}return n.makeTensorInfo(h.shape,h.dtype,h.values)}},Aq=yG(vy,(function(e){return Math.cos(e)})),Rq={kernelName:vy,backendName:"cpu",kernelFunc:Aq},_q=yG(gy,(function(e){return Math.cosh(e)})),Fq={kernelName:gy,backendName:"cpu",kernelFunc:_q};var Oq={kernelName:xy,backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=e.backend,r=e.attrs,a=t.image,i=t.boxes,o=t.boxInd,s=r.cropSize,u=r.method,l=r.extrapolationValue,c=a.shape,p=c[0],h=c[1],d=c[2],f=c[3],m=i.shape[0],v=s[0],g=s[1],y=KN([m,v,g,f],"float32"),b=n.data.get(i.dataId).values,x=n.data.get(o.dataId).values,w=n.data.get(a.dataId).values,k=vg(a.shape),N=vg(y.shape),I=0;I<m;I++){var S=4*I,T=b[S],C=b[S+1],E=b[S+2],A=b[S+3],R=x[I];if(!(R>=p))for(var _=v>1?(E-T)*(h-1)/(v-1):0,F=g>1?(A-C)*(d-1)/(g-1):0,O=0;O<v;O++){var D=v>1?T*(h-1)+O*_:.5*(T+E)*(h-1);if(D<0||D>h-1)for(var M=0;M<g;M++)for(var L=0;L<f;L++){var z=L+M*N[2]+O*N[1]+I*N[0];y.values[z]=l}else if("bilinear"===u)for(var P=Math.floor(D),B=Math.ceil(D),W=D-P,V=0;V<g;V++){var U=g>1?C*(d-1)+V*F:.5*(C+A)*(d-1);if(U<0||U>d-1)for(var G=0;G<f;G++){var j=G+V*N[2]+O*N[1]+I*N[0];y.values[j]=l}else for(var H=Math.floor(U),q=Math.ceil(U),K=U-H,X=0;X<f;X++){var Y=X+H*k[2]+P*k[1]+R*k[0],J=w[Y],Z=w[Y=X+q*k[2]+P*k[1]+R*k[0]],Q=w[Y=X+H*k[2]+B*k[1]+R*k[0]],$=J+(Z-J)*K,ee=Q+(w[Y=X+q*k[2]+B*k[1]+R*k[0]]-Q)*K;Y=X+V*N[2]+O*N[1]+I*N[0],y.values[Y]=$+(ee-$)*W}}else for(var te=0;te<g;++te){var ne=g>1?C*(d-1)+te*F:.5*(C+A)*(d-1);if(ne<0||ne>d-1)for(var re=0;re<f;re++){var ae=re+te*N[2]+O*N[1]+I*N[0];y.values[ae]=l}else for(var ie=Math.round(ne),oe=Math.round(D),se=0;se<f;se++){var ue=se+ie*k[2]+oe*k[1]+R*k[0],le=se+te*N[2]+O*N[1]+I*N[0];y.values[le]=w[ue]}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}};var Dq={kernelName:yy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.exclusive,s=r.reverse;KU(a,"cumprod");var u=VS([i],a.shape.length),l=a;null!=u&&(l=xj({inputs:{x:a},backend:n,attrs:{perm:u}}));var c=GS(1,a.shape.length)[0];if(c!==l.shape.length-1)throw new Error("backend.cumprod in CPU expects an inner-most axis="+(l.shape.length-1)+" but got axis="+c);for(var p=dk(l.dtype,"int32"),h=xg(Xv(l.shape),p),d=n.data.get(l.dataId).values,f=l.shape[l.shape.length-1],m=s?function(e,t){return e+f-t-1}:function(e,t){return e+t},v=0;v<d.length;v+=f)for(var g=0;g<f;g++){var y=m(v,g);if(0===g)h[y]=o?1:d[y];else{var b=m(v,g-1);h[y]=o?d[b]*h[b]:d[y]*h[b]}}var x=n.makeTensorInfo(l.shape,p,h);if(null!=u){var w=xj({inputs:{x:x},backend:n,attrs:{perm:US(u)}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(l),w}return x}};var Mq={kernelName:by,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.exclusive,s=r.reverse;KU(a,"cumsum");var u=VS([i],a.shape.length),l=a;null!=u&&(l=xj({inputs:{x:a},backend:n,attrs:{perm:u}}));var c=GS(1,a.shape.length)[0];if(c!==l.shape.length-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(l.shape.length-1)+" but got axis="+c);for(var p=dk(l.dtype,"int32"),h=wg(Xv(l.shape),p),d=n.data.get(l.dataId).values,f=l.shape[l.shape.length-1],m=s?function(e,t){return e+f-t-1}:function(e,t){return e+t},v=0;v<d.length;v+=f)for(var g=0;g<f;g++){var y=m(v,g);if(0===g)h[y]=o?0:d[y];else{var b=m(v,g-1);h[y]=o?d[b]+h[b]:d[y]+h[b]}}var x=n.makeTensorInfo(l.shape,p,h);if(null!=u){var w=xj({inputs:{x:x},backend:n,attrs:{perm:US(u)}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(l),w}return x}};var Lq={kernelName:wy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.weights,o=r.size,s=r.binaryOutput;if(1===a.shape.length){var u=mG(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,u)}if(2===a.shape.length){var l=vG(n.bufferSync(a),n.bufferSync(i),o,s);return n.makeTensorInfo(l.shape,i.dtype,l.values)}throw new Error("Error in denseBincount: input must be at most rank 2, but got rank"+a.shape.length+".")}};var zq={kernelName:ky,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockSize,o=r.dataFormat;Hv("NHWC"===o,(function(){return"Only NHWC dataFormat supported on CPU for depthToSpace. Got "+o}));for(var s=a.shape[0],u=a.shape[1],l=a.shape[2],c=a.shape[3],p=u*i,h=l*i,d=c/(i*i),f=n.data.get(a.dataId).values,m=new Float32Array(s*p*h*d),v=0,g=0;g<s;++g)for(var y=0;y<p;++y)for(var b=Math.floor(y/i),x=y%i,w=0;w<h;++w)for(var k=Math.floor(w/i),N=(x*i+w%i)*d,I=0;I<d;++I){var S=I+N+c*(k+l*(b+u*g));m[v++]=f[S]}return n.makeTensorInfo([s,p,h,d],a.dtype,m)}};function Pq(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations,l=r.dimRoundingMode;KU([a,i],"depthwiseConv2DNative");var c=vg(a.shape),p=vg(i.shape),h=u;null==h&&(h=[1,1]),Hv(DI(o,h),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+h+"'"}));for(var d=TI(a.shape,i.shape,o,h,s,l,!0),f=d.filterHeight,m=d.filterWidth,v=d.dilationHeight,g=d.dilationWidth,y=d.padInfo,b=y.left,x=y.top,w=d.outChannels/d.inChannels,k=new tk(d.outShape,a.dtype),N=n.data.get(a.dataId).values,I=n.data.get(i.dataId).values,S=k.values,T=0;T<d.batchSize;++T)for(var C=T*c[0],E=T*k.strides[0],A=0;A<d.outHeight;++A)for(var R=E+A*k.strides[1],_=A*d.strideHeight-x,F=0;F<f;++F){var O=_+F*v;if(!(O<0||O>=d.inHeight))for(var D=F*p[0],M=C+O*c[1],L=0;L<d.outWidth;++L)for(var z=R+L*k.strides[2],P=L*d.strideWidth-b,B=0;B<m;++B){var W=P+B*g;if(!(W<0||W>=d.inWidth))for(var V=D+B*p[1],U=M+W*d.inChannels,G=z,j=V,H=0;H<d.inChannels;++H){for(var q=N[U+H],K=0;K<w;++K)S[G+K]+=q*I[j+K];G+=w,j+=w}}}return n.makeTensorInfo(k.shape,k.dtype,k.values)}var Bq={kernelName:Ny,backendName:"cpu",kernelFunc:Pq};var Wq={kernelName:Iy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.dilations,u=r.pad,l=r.dimRoundingMode,c=r.filterShape;KU([a,i],"depthwiseConv2dNativeBackpropFilter");for(var p=TI(a.shape,c,o,s,u,l,!0),h=p.strideHeight,d=p.strideWidth,f=p.filterHeight,m=p.filterWidth,v=new tk(p.filterShape,"float32"),g=p.padInfo.left,y=p.padInfo.top,b=p.outChannels/p.inChannels,x=n.data.get(a.dataId).values,w=new tk(a.shape,a.dtype,x),k=n.data.get(i.dataId).values,N=new tk(i.shape,i.dtype,k),I=0;I<f;++I)for(var S=Math.max(0,Math.ceil((y-I)/h)),T=Math.min(p.outHeight,(p.inHeight+y-I)/h),C=0;C<m;++C)for(var E=Math.max(0,Math.ceil((g-C)/d)),A=Math.min(p.outWidth,(p.inWidth+g-C)/d),R=0;R<p.outChannels;++R){for(var _=Math.trunc(R/b),F=R%b,O=0,D=0;D<p.batchSize;++D)for(var M=S;M<T;++M)for(var L=I+M*h-y,z=E;z<A;++z){var P=C+z*d-g;O+=w.get(D,L,P,_)*N.get(D,M,z,R)}v.set(O,I,C,_,F)}return n.makeTensorInfo(v.shape,v.dtype,v.values)}};var Vq={kernelName:Sy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.strides,s=r.dilations,u=r.pad,l=r.dimRoundingMode,c=r.inputShape;KU([a,i],"depthwiseConv2DNativeBackpropInput");for(var p=vg(a.shape),h=vg(i.shape),d=TI(c,i.shape,o,s,u,l,!0),f=new tk(d.inShape,"float32"),m=f.values,v=f.strides,g=v[0],y=v[1],b=v[2],x=n.data.get(a.dataId).values,w=p[0],k=p[1],N=p[2],I=n.data.get(i.dataId).values,S=h[0],T=h[1],C=h[2],E=d.batchSize,A=d.filterHeight,R=d.filterWidth,_=d.inChannels,F=d.inHeight,O=d.inWidth,D=d.outChannels,M=d.outHeight,L=d.outWidth,z=d.strideHeight,P=d.strideWidth,B=A-1-d.padInfo.top,W=R-1-d.padInfo.left,V=D/_,U=0;U<E;++U)for(var G=0;G<_;++G)for(var j=0;j<F;++j)for(var H=j-B,q=Math.max(0,Math.ceil(H/z)),K=Math.min(M,(A+H)/z),X=0;X<O;++X){for(var Y=X-W,J=Math.max(0,Math.ceil(Y/P)),Z=Math.min(L,(R+Y)/P),Q=0,$=q;$<K;++$)for(var ee=$*z-H,te=J;te<Z;++te)for(var ne=w*U+k*$+N*te,re=S*(A-1-ee)+T*(R-1-(te*P-Y))+C*G,ae=0;ae<V;++ae){Q+=x[ne+(G*V+ae)]*I[re+ae]}m[g*U+y*j+b*X+G]=Q}return n.makeTensorInfo(f.shape,f.dtype,f.values)}};var Uq={kernelName:Ty,backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=e.backend,r=t.x,a=Xv(r.shape),i=n.data.get(r.dataId).values,o=KN([a,a],r.dtype),s=o.values,u=0;u<i.length;u++)s[u*a+u]=i[u];var l=[].concat(r.shape,r.shape);return n.makeTensorInfo(l,o.dtype,o.values)}},Gq={kernelName:Cy,backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations,l=n,c=l.data.get(a.dataId).values,p=a.shape.length,h=l.data.get(i.dataId).values,d=i.shape.length,f=NI(a.shape,i.shape,o,s,"NHWC",u),m=f.batchSize,v=f.inHeight,g=f.inWidth,y=f.inChannels,b=f.outHeight,x=f.outWidth,w=f.padInfo,k=f.strideHeight,N=f.strideWidth,I=f.filterHeight,S=f.filterWidth,T=f.dilationHeight,C=f.dilationWidth,E=f.outShape,A=Xv(E),R=E.length,_=ag(a.dtype,A),F=0;F<m;++F)for(var O=0;O<b;++O)for(var D=O*k-w.top,M=0;M<x;++M)for(var L=M*N-w.left,z=0;z<y;++z){for(var P=Number.MIN_SAFE_INTEGER,B=0;B<I;++B){var W=D+B*T;if(W>=0&&W<v)for(var V=0;V<S;++V){var U=L+V*C;if(U>=0&&U<g){var G=Ig([F,W,U,z],p,vg(a.shape)),j=Ig([B,V,z],d,vg(i.shape)),H=c[G]+h[j];H>P&&(P=H)}}}_[Ig([F,O,M,z],R,vg(E))]=P}return{dataId:l.write(Ww(_,a.dtype),E,a.dtype),shape:E,dtype:a.dtype}}},jq={kernelName:Ay,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.dy,s=r.strides,u=r.pad,l=r.dilations,c=n,p=yg(a.shape,c.data.get(a.dataId).values),h=yg(i.shape,c.data.get(i.dataId).values),d=NI(a.shape,i.shape,s,u,"NHWC",l),f=d.batchSize,m=d.inHeight,v=d.inWidth,g=d.inChannels,y=d.outHeight,b=d.outWidth,x=d.padInfo,w=d.strideHeight,k=d.strideWidth,N=d.filterHeight,I=d.filterWidth,S=d.dilationHeight,T=d.dilationWidth,C=d.outShape;Hv(o.rank===C.length,(function(){return"Error in Dilation2DBackpropFilter, dy must have the same rank as output "+C.length+", but got "+o.rank}));for(var E=yg(C,c.data.get(o.dataId).values),A=kg(i.shape,i.dtype),R=0;R<f;++R)for(var _=0;_<y;++_)for(var F=_*w-x.top,O=0;O<b;++O)for(var D=O*k-x.left,M=0;M<g;++M){for(var L=Number.MIN_SAFE_INTEGER,z=0,P=0,B=0;B<N;++B){var W=F+B*S;if(W>=0&&W<m)for(var V=0;V<I;++V){var U=D+V*T;if(U>=0&&U<v){var G=p[R][W][U][M]+h[B][V][M];G>L&&(L=G,z=B,P=V)}}}A[z][P][M]+=E[R][_][O][M]}return{dataId:c.write(Ww(A,a.dtype),i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}},Hq={kernelName:Ey,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.dy,s=r.strides,u=r.pad,l=r.dilations,c=n,p=yg(a.shape,c.data.get(a.dataId).values),h=yg(i.shape,c.data.get(i.dataId).values),d=NI(a.shape,i.shape,s,u,"NHWC",l),f=d.batchSize,m=d.inHeight,v=d.inWidth,g=d.inChannels,y=d.outHeight,b=d.outWidth,x=d.padInfo,w=d.strideHeight,k=d.strideWidth,N=d.filterHeight,I=d.filterWidth,S=d.dilationHeight,T=d.dilationWidth,C=d.outShape;Hv(o.rank===C.length,(function(){return"Error in Dilation2DBackpropInput, dy must have the same rank as output "+C.length+", but got "+o.rank}));for(var E=yg(C,c.data.get(o.dataId).values),A=kg(a.shape,a.dtype),R=0;R<f;++R)for(var _=0;_<y;++_)for(var F=_*w-x.top,O=0;O<b;++O)for(var D=O*k-x.left,M=0;M<g;++M){for(var L=Number.MIN_SAFE_INTEGER,z=F<0?0:F,P=D<0?0:D,B=0;B<N;++B){var W=F+B*S;if(W>=0&&W<m)for(var V=0;V<I;++V){var U=D+V*T;if(U>=0&&U<v){var G=p[R][W][U][M]+h[B][V][M];G>L&&(L=G,z=W,P=U)}}}A[R][z][P][M]+=E[R][_][O][M]}return{dataId:c.write(Ww(A,a.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}};function qq(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.axis,s=a.keepDims;KU(i,"sum");var u=(t="bool"===i.dtype?sG({inputs:{x:i},backend:r,attrs:{dtype:"int32"}}):nG({inputs:{x:i},backend:r})).shape.length,l=tg(o,t.shape),c=VS(l,u),p=l,h=t;null!=c&&(h=xj({inputs:{x:t},backend:r,attrs:{perm:c}}),p=GS(p.length,u)),WS("sum",p,h.shape.length);for(var d=PS(h.shape,p),f=d[0],m=d[1],v=tG(r,f,dk(h.dtype,"int32")),g=Xv(m),y=r.data.get(v.dataId).values,b=r.data.get(h.dataId).values,x=0;x<y.length;++x){for(var w=x*g,k=0,N=0;N<g;++N)k+=b[w+N];y[x]=k}if(s){var I=v;v=OH({inputs:{x:v},backend:r,attrs:{shape:BS(v.shape,l)}}),r.disposeIntermediateTensorInfo(I)}return r.disposeIntermediateTensorInfo(t),null!=c&&r.disposeIntermediateTensorInfo(h),v}var Kq={kernelName:dx,backendName:"cpu",kernelFunc:qq};var Xq={kernelName:_y,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t,a=$_(e.attrs.equation,r.length),i=a.allDims,o=a.summedDims,s=a.idDims;tF(i.length,s,r);for(var u=nF(o,s),l=u.path,c=u.steps,p=c.length,h=null,d=i.length,f=[],m=0;m<p;++m){for(var v,g=Lv(c[m]);!(v=g()).done;){var y=v.value,b=eF(d,s[y]),x=b.permutationIndices,w=b.expandDims,k=void 0;rF(x)?k=r[y]:(k=xj({inputs:{x:r[y]},backend:n,attrs:{perm:x}}),f.push(k));for(var N=k.shape.slice(),I=0;I<w.length;++I)N.splice(w[I],0,1);Yv(k.shape,N)||(k=OH({inputs:{x:k},backend:n,attrs:{shape:N}}),f.push(k)),null===h?h=k:(h=hj({inputs:{a:k,b:h},backend:n}),f.push(h))}m<p-1&&(l[m]>=0&&(h=qq({inputs:{x:h},backend:n,attrs:{axis:l[m]-(i.length-d),keepDims:!1}}),f.push(h)),d--)}for(var S=0,T=f;S<T.length;S++){var C=T[S];C!==h&&n.disposeIntermediateTensorInfo(C)}return h}};var Yq={kernelName:Oy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.dy,a=t.y;KU([r,a],"eluGrad");for(var i=new Float32Array(Xv(a.shape)),o=n.data.get(a.dataId).values,s=n.data.get(r.dataId).values,u=0;u<o.length;++u){var l=o[u];i[u]=l>=0?s[u]:s[u]*(l+1)}return n.makeTensorInfo(a.shape,"float32",i)}},Jq=yG(Dy,(function(e){var t=Math.sign(e),n=Math.abs(e),r=1/(1+.3275911*n);return t*(1-((((1.061405429*r-1.453152027)*r+1.421413741)*r-.284496736)*r+.254829592)*r*Math.exp(-n*n))})),Zq={kernelName:Dy,backendName:"cpu",kernelFunc:Jq};function Qq(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.input,i=r.dim,o=a.shape.length,s=a.shape.slice(),u=i;return i<0&&(Hv(-(o+1)<=i,(function(){return"Axis must be in the interval ["+-(o+1)+", "+o+"]"})),u=o+i+1),s.splice(u,0,1),OH({inputs:{x:a},backend:n,attrs:{shape:s}})}var $q={kernelName:zy,backendName:"cpu",kernelFunc:Qq},eK=QU((function(e,t){return e/t})),tK=lG(Ry,eK),nK={kernelName:Ry,backendName:"cpu",kernelFunc:tK};function rK(e,t,n){for(var r=e.shape,a=r[0],i=r[1],o=n.data.get(e.dataId),s=o.complexTensorInfos.real,u=o.complexTensorInfos.imag,l=[a,i],c=Xv(l),p=rg("float32",c),h=rg("float32",c),d=0;d<a;d++){for(var f=jj({inputs:{x:s},backend:n,attrs:{begin:[d,0],size:[1,i]}}),m=jj({inputs:{x:u},backend:n,attrs:{begin:[d,0],size:[1,i]}}),v=$U({inputs:{real:f,imag:m},backend:n}),g=aK(v,t,n),y=G_(g.real,g.imag),b=0;b<i;b++){var x=K_(y,b);p[d*i+b]=x.real,h[d*i+b]=x.imag}n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v)}var w=n.makeTensorInfo(l,"float32",p),k=n.makeTensorInfo(l,"float32",h),N=$U({inputs:{real:w,imag:k},backend:n});return n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(k),N}function aK(e,t,n){var r=Xv(e.shape),a=n.data.get(e.dataId),i=n.data.get(a.complexTensorInfos.real.dataId).values,o=n.data.get(a.complexTensorInfos.imag.dataId).values;if(0==((g=r)&g-1)){var s=iK(i,o,r,t,n),u=[e.shape[0],e.shape[1]];if(t){var l=n.makeTensorInfo(u,"float32",s.real),c=n.makeTensorInfo(u,"float32",s.imag),p=n.makeTensorInfo([],"float32",Bw(r,"float32")),h=nG({inputs:{x:p},backend:n}),d=nK.kernelFunc({inputs:{a:l,b:p},backend:n}),f=nK.kernelFunc({inputs:{a:c,b:h},backend:n}),m=n.data.get(d.dataId).values,v=n.data.get(f.dataId).values;return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),{real:m,imag:v}}return s}var g,y=function(e,t,n){for(var r=new Float32Array(2*t),a=0;a<t;a++){for(var i=0,o=0,s=0;s<t;s++){var u=J_(a*s,t,n),l=K_(e,s);i+=l.real*u.real-l.imag*u.imag,o+=l.real*u.imag+l.imag*u.real}n&&(i/=t,o/=t),X_(r,i,o,a)}return r}(G_(i,o),r,t);return j_(y)}function iK(e,t,n,r,a){if(1===n)return{real:e,imag:t};var i=G_(e,t),o=n/2,s=H_(i),u=s.real,l=s.imag,c=[u.length],p=a.makeTensorInfo(c,"float32",u),h=a.makeTensorInfo(c,"float32",l),d=$U({inputs:{real:p,imag:h},backend:a}),f=q_(i),m=f.real,v=f.imag,g=[m.length],y=a.makeTensorInfo(g,"float32",m),b=a.makeTensorInfo(g,"float32",v),x=$U({inputs:{real:y,imag:b},backend:a}),w=iK(u,l,o,r,a),k=w.real,N=w.imag,I=[k.length],S=a.makeTensorInfo(I,"float32",k),T=a.makeTensorInfo(I,"float32",N),C=$U({inputs:{real:S,imag:T},backend:a}),E=iK(m,v,o,r,a),A=E.real,R=E.imag,_=[A.length],F=a.makeTensorInfo(_,"float32",A),O=a.makeTensorInfo(_,"float32",R),D=$U({inputs:{real:F,imag:O},backend:a}),M=Y_(n,r),L=[M.real.length],z=a.makeTensorInfo(L,"float32",M.real),P=a.makeTensorInfo(L,"float32",M.imag),B=$U({inputs:{real:z,imag:P},backend:a}),W=hj({inputs:{a:B,b:D},backend:a}),V=dG({inputs:{a:C,b:W},backend:a}),U=hH({inputs:{a:C,b:W},backend:a}),G=aG({inputs:{input:V},backend:a}),j=aG({inputs:{input:U},backend:a}),H=yq({inputs:{input:V},backend:a}),q=yq({inputs:{input:U},backend:a}),K=xq({inputs:[G,j],backend:a,attrs:{axis:0}}),X=xq({inputs:[H,q],backend:a,attrs:{axis:0}}),Y=a.data.get(K.dataId).values,J=a.data.get(X.dataId).values;return a.disposeIntermediateTensorInfo(p),a.disposeIntermediateTensorInfo(h),a.disposeIntermediateTensorInfo(d),a.disposeIntermediateTensorInfo(y),a.disposeIntermediateTensorInfo(b),a.disposeIntermediateTensorInfo(x),a.disposeIntermediateTensorInfo(S),a.disposeIntermediateTensorInfo(T),a.disposeIntermediateTensorInfo(C),a.disposeIntermediateTensorInfo(F),a.disposeIntermediateTensorInfo(O),a.disposeIntermediateTensorInfo(D),a.disposeIntermediateTensorInfo(z),a.disposeIntermediateTensorInfo(P),a.disposeIntermediateTensorInfo(B),a.disposeIntermediateTensorInfo(W),a.disposeIntermediateTensorInfo(V),a.disposeIntermediateTensorInfo(U),a.disposeIntermediateTensorInfo(G),a.disposeIntermediateTensorInfo(H),a.disposeIntermediateTensorInfo(j),a.disposeIntermediateTensorInfo(q),a.disposeIntermediateTensorInfo(K),a.disposeIntermediateTensorInfo(X),{real:Y,imag:J}}var oK={kernelName:By,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.input,a=Xv(r.shape),i=r.shape[r.shape.length-1],o=OH({inputs:{x:r},backend:n,attrs:{shape:[a/i,i]}}),s=rK(o,!1,n),u=OH({inputs:{x:s},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}};function sK(e){var t=e.backend,n=e.attrs,r=n.shape,a=n.value,i=n.dtype||dg(a),o=ag(i,Xv(r));return function(e,t,n){e.fill(t)}(o,a),t.makeTensorInfo(r,i,o)}var uK={kernelName:Wy,backendName:"cpu",kernelFunc:sK};var lK={kernelName:Vy,backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=(e.attrs,e.backend),r=t.image,a=n,i=rg(r.dtype,Xv(r.shape)),o=r.shape,s=o[0],u=o[1],l=o[2],c=o[3],p=a.data.get(r.dataId).values,h=0;h<s;h++)for(var d=h*l*u*c,f=0;f<u;f++)for(var m=f*(l*c),v=0;v<l;v++)for(var g=v*c,y=0;y<c;y++){var b=Math.round(l-v-1),x=d+m+g+y,w=p[x];if(b>=0&&b<l)w=p[d+m+b*c+y];i[x]=w}return{dataId:a.write(i,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};var cK={kernelName:jx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.bias,s=t.preluActivationWeights,u=r.strides,l=r.pad,c=r.dataFormat,p=r.dilations,h=r.dimRoundingMode,d=r.activation,f=r.leakyreluAlpha,m=kq({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h}});if(o){var v=m;if("NCHW"===c&&1===o.shape.length&&1!==o.shape[0]){var g=OH({inputs:{x:o},backend:n,attrs:{shape:[o.shape[0],1,1]}});m=dG({inputs:{a:m,b:g},backend:n}),n.disposeIntermediateTensorInfo(g)}else m=dG({inputs:{a:m,b:o},backend:n});n.disposeIntermediateTensorInfo(v)}if(d){var y=m;if("NCHW"===c&&"prelu"===d&&1===s.shape.length&&1!==s.shape[0]){var b=OH({inputs:{x:s},backend:n,attrs:{shape:[s.shape[0],1,1]}});m=FH(n,m,d,b,f),n.disposeIntermediateTensorInfo(b)}else m=FH(n,m,d,s,f);n.disposeIntermediateTensorInfo(y)}return m}};var pK={kernelName:Hx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.bias,s=t.preluActivationWeights,u=r.strides,l=r.pad,c=r.dataFormat,p=r.dilations,h=r.dimRoundingMode,d=r.activation,f=r.leakyreluAlpha,m=Pq({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h}});if(o){var v=m;m=dG({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(v)}if(d){var g=m;m=FH(n,m,d,s,f),n.disposeIntermediateTensorInfo(g)}return m}};var hK={kernelName:qy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.params,a=t.indices,i=Xv(r.shape),o=a.shape,s=o[o.length-1],u=QR(r,a),l=u[0],c=u[1],p=u[2],h=u[3];if(0===c)return n.makeTensorInfo(l,r.dtype,[]);var d=BG(n.data.get(a.dataId).values,n.bufferSync(r),r.dtype,c,s,p,h,r.shape,i);return n.makeTensorInfo(l,r.dtype,d.values)}};var dK={kernelName:Hy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.indices,o=r.axis,s=r.batchDims;KU([a,i],"gatherV2");for(var u=tg(o,a.shape)[0],l=n.data.get(i.dataId).values,c=a.shape[u],p=function(e){var t=l[e];Hv(t<=c-1&&t>=0,(function(){return"GatherV2: the index value "+t+" is not in [0, "+(c-1)+"]"}))},h=0;h<l.length;++h)p(h);var d=s;null==s&&(d=0);var f=Xv(i.shape),m=xF(a,i,u,d),v=OH({inputs:{x:a},backend:n,attrs:{shape:[m.batchSize,m.outerSize,m.dimSize,m.sliceSize]}}),g=OH({inputs:{x:i},backend:n,attrs:{shape:[m.batchSize,f/m.batchSize]}}),y=[m.batchSize,m.outerSize,f/m.batchSize,m.sliceSize],b=n.bufferSync(g),x=WG(n.bufferSync(v),b,y);return n.disposeIntermediateTensorInfo(v),n.disposeIntermediateTensorInfo(g),n.makeTensorInfo(m.outputShape,x.dtype,x.values)}};var fK={kernelName:Jy,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.input,a=Xv(r.shape),i=r.shape[r.shape.length-1],o=OH({inputs:{x:r},backend:n,attrs:{shape:[a/i,i]}}),s=rK(o,!0,n),u=OH({inputs:{x:s},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}},mK=yG(Qy,(function(e){return Number.isFinite(e)?1:0}),"bool"),vK={kernelName:Qy,backendName:"cpu",kernelFunc:mK},gK=yG($y,(function(e){return Math.abs(e)===1/0?1:0}),"bool"),yK={kernelName:$y,backendName:"cpu",kernelFunc:gK},bK=yG(eb,(function(e){return Number.isNaN(e)?1:0}),"bool"),xK={kernelName:eb,backendName:"cpu",kernelFunc:bK};var wK={kernelName:ab,backendName:"cpu",kernelFunc:function(e){var t=e.backend,n=e.attrs,r=$G(n.start,n.stop,n.num);return t.makeTensorInfo([r.length],"float32",r)}},kK=yG(ob,(function(e){return Math.log1p(e)})),NK={kernelName:ob,backendName:"cpu",kernelFunc:kK},IK=QU((function(e,t){return e&&t})),SK=lG(sb,IK,null,"bool"),TK={kernelName:sb,backendName:"cpu",kernelFunc:SK},CK=yG(ub,(function(e){return e?0:1}),"bool"),EK={kernelName:ub,backendName:"cpu",kernelFunc:CK},AK=QU((function(e,t){return e||t})),RK=lG(lb,AK,null,"bool"),_K={kernelName:lb,backendName:"cpu",kernelFunc:RK};var FK={kernelName:pb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.depthRadius,o=r.bias,s=r.alpha,u=r.beta;KU(a,"LRN");var l=a.shape[3],c=l-1,p=n.data.get(a.dataId).values,h=Xv(a.shape),d=new Float32Array(h);function f(e){for(var t=e%l,n=e-t+Math.max(0,t-i),r=e-t+Math.min(t+i,c),a=0;n<=r;n++){var o=p[n];a+=o*o}return a}for(var m=0;m<h;m++){var v=f(m),g=p[m]*Math.pow(o+s*v,-u);d[m]=g}return n.makeTensorInfo(a.shape,a.dtype,d)}};var OK={kernelName:hb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.y,o=t.dy,s=r.depthRadius,u=r.bias,l=r.alpha,c=r.beta;KU(o,"LRNGrad");for(var p=Xv(o.shape),h=o.shape[3],d=n.data.get(o.dataId).values,f=n.data.get(a.dataId).values,m=n.data.get(i.dataId).values,v=new Float32Array(p),g=p,y=0;y<g;y++){for(var b=y%h,x=y-b+Math.max(0,b-s),w=y-b+Math.min(h,b+s+1),k=0,N=x;N<w;N++)k+=Math.pow(f[N],2);k=l*k+u;for(var I=x;I<w;I++){var S=-2*l*c*f[I]*m[y]/k;y===I&&(S+=Math.pow(k,-c)),S*=d[y],v[I]+=S}}return n.makeTensorInfo(o.shape,a.dtype,v)}};function DK(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.reductionIndices,o=r.keepDims,s=n,u=a.shape,l=u.length,c=tg(i,u),p=c,h=VS(p,l),d=s.data.get(a.dataId).values;if(null!=h){for(var f=new Array(l),m=0;m<f.length;m++)f[m]=u[h[m]];d=bj(d,u,a.dtype,h,f),p=GS(p.length,l),u=f}KU(a,"max"),WS("max",p,l);var v=PS(u,p),g=v[0],y=rj(d,Xv(v[1]),g,a.dtype),b=s.write(y,g,a.dtype),x=g;o&&(x=f=BS(g,c));return{dataId:b,shape:x,dtype:a.dtype}}var MK={kernelName:db,backendName:"cpu",kernelFunc:DK};var LK={kernelName:mb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;KU(a,"maxPool");var i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode;Hv(DI(o,1),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '1'"}));var l,c=II(a.shape,i,o,1,s,u);if(1===c.filterWidth&&1===c.filterHeight&&Yv(c.inShape,c.outShape))l=nG({inputs:{x:a},backend:n});else{var p=n.data.get(a.dataId).values,h=vg(a.shape),d=aq(p,a.shape,a.dtype,h,c,"max");l=n.makeTensorInfo(c.outShape,a.dtype,d.values)}return l}};var zK={kernelName:gb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode,l=r.dataFormat;KU(a,"maxPool3d");var c=SI(a.shape,i,o,1,s,u,l),p=oq(n.data.get(a.dataId).values,a.shape,a.dtype,vg(a.shape),c,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}};var PK={kernelName:yb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=r.filterSize,s=r.strides,u=r.pad,l=r.dimRoundingMode;KU([a,i],"maxPool3DGrad");for(var c=SI(i.shape,o,s,1,u,l),p=function(e,t){for(var n=KN(t.outShape,"int32"),r=t.strideDepth,a=t.strideHeight,i=t.strideWidth,o=t.dilationDepth,s=t.dilationHeight,u=t.dilationWidth,l=t.effectiveFilterDepth,c=t.effectiveFilterHeight,p=t.effectiveFilterWidth,h=t.padInfo.front,d=t.padInfo.top,f=t.padInfo.left,m=0;m<t.batchSize;++m)for(var v=0;v<t.inChannels;++v)for(var g=0;g<t.outDepth;++g){for(var y=g*r-h,b=y;b<0;)b+=o;for(var x=Math.min(t.inDepth,l+y),w=0;w<t.outHeight;++w){for(var k=w*a-d,N=k;N<0;)N+=s;for(var I=Math.min(t.inHeight,c+k),S=0;S<t.outWidth;++S){for(var T=S*i-f,C=T;C<0;)C+=u;for(var E=Math.min(t.inWidth,p+T),A=Number.NEGATIVE_INFINITY,R=-1,_=b;_<x;_+=o)for(var F=_-y,O=N;O<I;O+=s)for(var D=O-k,M=C;M<E;M+=u){var L=M-T,z=e.get(m,_,O,M,v);z>=A&&(A=z,R=F*c*p+D*c+L)}n.set(R,m,g,w,S,v)}}}return n}(n.bufferSync(i),c),h=c.strideDepth,d=c.strideHeight,f=c.strideWidth,m=c.dilationDepth,v=c.dilationHeight,g=c.dilationWidth,y=c.effectiveFilterDepth,b=c.effectiveFilterHeight,x=c.effectiveFilterWidth,w=y-1-c.padInfo.front,k=x-1-c.padInfo.left,N=b-1-c.padInfo.top,I=KN(i.shape,"float32"),S=n.bufferSync(a),T=0;T<c.batchSize;++T)for(var C=0;C<c.inChannels;++C)for(var E=0;E<c.inDepth;++E)for(var A=0;A<c.inHeight;++A)for(var R=0;R<c.inWidth;++R){for(var _=E-w,F=A-N,O=R-k,D=0,M=0;M<y;M+=m){var L=(_+M)/h;if(!(L<0||L>=c.outDepth||Math.floor(L)!==L))for(var z=0;z<b;z+=v){var P=(F+z)/d;if(!(P<0||P>=c.outHeight||Math.floor(P)!==P))for(var B=0;B<x;B+=g){var W=(O+B)/f;if(!(W<0||W>=c.outWidth||Math.floor(W)!==W)){var V=y*b*x-1-p.get(T,L,P,W,C)===M*b*x+z*x+B?1:0;if(0!==V)D+=S.get(T,L,P,W,C)*V}}}}I.set(D,T,E,A,R,C)}return n.makeTensorInfo(I.shape,I.dtype,I.values)}};var BK={kernelName:vb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=i;KU([i,t.output],"maxPoolGrad");for(var s=r.filterSize,u=r.strides,l=r.pad,c=r.dimRoundingMode,p=II(o.shape,s,u,1,l,c),h=n.data.get(o.dataId).values,d=KN(p.outShape,o.dtype,iq(h,o.shape,o.dtype,p).values),f=p.strideHeight,m=p.strideWidth,v=p.dilationHeight,g=p.dilationWidth,y=p.effectiveFilterHeight,b=p.effectiveFilterWidth,x=b-1-p.padInfo.left,w=y-1-p.padInfo.top,k=KN(o.shape,"float32"),N=n.data.get(a.dataId).values,I=KN(a.shape,"float32",N),S=0;S<p.batchSize;++S)for(var T=0;T<p.inChannels;++T)for(var C=0;C<p.inHeight;++C)for(var E=0;E<p.inWidth;++E){for(var A=C-w,R=E-x,_=0,F=0;F<y;F+=v){var O=(A+F)/f;if(!(O<0||O>=p.outHeight||Math.floor(O)!==O))for(var D=0;D<b;D+=g){var M=(R+D)/m;if(!(M<0||M>=p.outWidth||Math.floor(M)!==M)){var L=y*b-1-d.get(S,O,M,T)===F*b+D?1:0;if(0!==L)_+=I.get(S,O,M,T)*L}}}k.set(_,S,C,E,T)}return n.makeTensorInfo(k.shape,k.dtype,k.values)}};var WK={kernelName:bb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=n.filterSize,o=n.strides,s=n.pad,u=n.includeBatchInIndex,l=r;KU(a,"MaxPoolWithArgmax");var c=l.data.get(a.dataId).values,p=II(a.shape,i,o,[1,1],s),h=function(e,t,n,r,a){var i=aq(e,0,n,vg(t),a,"max"),o=iq(e,t,n,a,!0,r);return[i.values,o.values]}(c,a.shape,a.dtype,u,p),d=h[0],f=h[1],m=l.write(d,p.outShape,a.dtype),v=l.write(f,p.outShape,a.dtype);return[{dataId:m,shape:p.outShape,dtype:a.dtype},{dataId:v,shape:p.outShape,dtype:"int32"}]}};var VK={kernelName:xb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims,s=tg(i,a.shape),u=Xv(PS(a.shape,s)[1]),l=[],c=n.makeTensorInfo([],"float32",new Float32Array([u]));l.push(c);var p=sG({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});l.push(p);var h=tK({inputs:{a:p,b:c},backend:n});l.push(h);var d=qq({inputs:{x:h},backend:n,attrs:{axis:i,keepDims:o}});return l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),d}};var UK={kernelName:wb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims;KU(a,"min");var s=tg(i,a.shape),u=s,l=VS(u,a.shape.length),c=a;null!=l&&(c=xj({inputs:{x:a},backend:n,attrs:{perm:l}}),u=GS(u.length,a.shape.length)),WS("min",u,c.shape.length);for(var p=PS(c.shape,u),h=p[0],d=Xv(p[1]),f=wg(Xv(h),c.dtype),m=n.data.get(c.dataId).values,v=0;v<f.length;++v){for(var g=v*d,y=m[g],b=0;b<d;++b){var x=m[g+b];(Number.isNaN(x)||x<y)&&(y=x)}f[v]=y}null!=l&&n.disposeIntermediateTensorInfo(c);var w=n.makeTensorInfo(h,c.dtype,f);if(o){var k=OH({inputs:{x:w},backend:n,attrs:{shape:BS(h,s)}});return n.disposeIntermediateTensorInfo(w),k}return w}};var GK={kernelName:Nb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.paddings,o=r.mode;KU(a,"mirrorPad");for(var s=i.map((function(e,t){return e[0]+a.shape[t]+e[1]})),u=i.map((function(e){return e[0]})),l=i.map((function(e,t){return e[0]+a.shape[t]})),c="reflect"===o?0:1,p=n.data.get(a.dataId).values,h=a.shape.length,d=vg(a.shape),f=Xv(s),m=s.length,v=vg(s),g=rg(a.dtype,f),y=0;y<f;y++){for(var b=Sg(y,m,v),x=0;x<m;x++)b[x]<u[x]?b[x]=2*u[x]-b[x]-c:b[x]>=l[x]&&(b[x]=2*(l[x]-1)-b[x]+c);b=b.map((function(e,t){return e-u[t]}));var w=Ig(b,h,d);g[y]=p[w]}return{dataId:n.write(g,s,a.dtype),shape:s,dtype:a.dtype}}},jK=QU((function(e,t){var n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),HK=lG(Ib,jK),qK={kernelName:Ib,backendName:"cpu",kernelFunc:HK};function KK(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,i=r.dim,o=a.shape.length,s=i;if(-1===s&&(s=o-1),s!==o-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+o+" and dim was "+s);var u=tg([s],a.shape),l=DK({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),c=BS(l.shape,u),p=OH({inputs:{x:l},backend:n,attrs:{shape:c}}),h=hH({inputs:{a:a,b:p},backend:n}),d=EG({inputs:{x:h},backend:n}),f=qq({inputs:{x:d},backend:n,attrs:{axis:u,keepDims:!1}}),m=OH({inputs:{x:f},backend:n,attrs:{shape:c}}),v=tK({inputs:{a:d,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),v}var XK={kernelName:vx,backendName:"cpu",kernelFunc:KK};var YK={kernelName:Sb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,i=r.numSamples,o=r.seed,s=r.normalized;KU(a,"multinomial");for(var u=s?a:KK({inputs:{logits:a},backend:n,attrs:{dim:-1}}),l=u.shape[0],c=u.shape[1],p=n.data.get(u.dataId).values,h=[l,i],d=wg(Xv(h),"int32"),f=0;f<l;++f){var m=f*c,v=new Float32Array(c-1);v[0]=p[m];for(var g=1;g<v.length;++g)v[g]=v[g-1]+p[m+g];for(var y=xC(o.toString()),b=f*i,x=0;x<i;++x){var w=y();d[b+x]=v.length;for(var k=0;k<v.length;k++)if(w<v[k]){d[b+x]=k;break}}}return s||n.disposeIntermediateTensorInfo(u),n.makeTensorInfo(h,"int32",d)}},JK=gA;var ZK={kernelName:Ab,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold;KU(a,"NonMaxSuppression");var l=n.data.get(a.dataId).values,c=n.data.get(i.dataId).values,p=JK(l,c,o,s,u).selectedIndices;return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},QK=yA;var $K={kernelName:Rb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=r.padToMaxOutputSize;KU(a,"NonMaxSuppressionPadded");var c=n.data.get(a.dataId).values,p=n.data.get(i.dataId).values,h=QK(c,p,o,s,u,l),d=h.selectedIndices,f=h.validOutputs;return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([f]))]}},eX=bA;var tX={kernelName:_b,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=r.softNmsSigma;KU(a,"NonMaxSuppressionWithScore");var c=n.data.get(a.dataId).values,p=n.data.get(i.dataId).values,h=eX(c,p,o,s,u,l),d=h.selectedIndices,f=h.selectedScores;return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([f.length],"float32",new Float32Array(f))]}};var nX={kernelName:Ob,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,i=r.dtype,o=r.depth,s=r.onValue,u=r.offValue;KU(a,"oneHot");var l=Xv(a.shape),c=new Float32Array(l*o);c.fill(u);for(var p=n.data.get(a.dataId).values,h=0;h<l;++h)p[h]>=0&&p[h]<o&&(c[h*o+p[h]]=s);return n.makeTensorInfo([].concat(a.shape,[o]),i,c)}};function rX(e){var t=e.inputs,n=e.backend,r=t.x;if("string"===r.dtype)throw new Error("zerosLike is not supported for string tensors");if("complex64"===r.dtype){var a=aG({inputs:{input:r},backend:n}),i=rX({inputs:{x:a},backend:n}),o=yq({inputs:{input:r},backend:n}),s=rX({inputs:{x:o},backend:n}),u=$U({inputs:{real:i,imag:s},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}return sK({backend:n,attrs:{shape:r.shape,value:0,dtype:r.dtype}})}var aX={kernelName:Bx,backendName:"cpu",kernelFunc:rX};var iX={kernelName:Fb,backendName:"cpu",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=n.x;if("string"===a.dtype)throw new Error("onesLike is not supported for string tensors");if("complex64"===a.dtype){var i=aG({inputs:{input:a},backend:r}),o=e({inputs:{x:i},backend:r}),s=yq({inputs:{input:a},backend:r}),u=rX({inputs:{x:s},backend:r}),l=$U({inputs:{real:o,imag:u},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(u),l}return sK({backend:r,attrs:{shape:a.shape,value:1,dtype:a.dtype}})}};function oX(e){var t=e.inputs,n=e.backend,r=e.attrs.axis;if(1===t.length)return Qq({inputs:{input:t[0]},backend:n,attrs:{dim:r}});var a=t[0].shape,i=t[0].dtype;t.forEach((function(e){qv(a,e.shape,"All tensors passed to stack must have matching shapes"),Hv(i===e.dtype,(function(){return"All tensors passed to stack must have matching dtypes"}))}));var o=[],s=xq({inputs:t.map((function(e){var t=Qq({inputs:{input:e},backend:n,attrs:{dim:r}});return o.push(t),t})),backend:n,attrs:{axis:r}});return o.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),s}var sX={kernelName:Db,backendName:"cpu",kernelFunc:oX};var uX={kernelName:Mb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.paddings,o=r.constantValue;KU(a,"pad");var s=i.map((function(e,t){return e[0]+a.shape[t]+e[1]})),u=i.map((function(e){return e[0]})),l=n.data.get(a.dataId).values,c=Xv(a.shape),p=a.shape.length,h=vg(a.shape),d=Xv(s),f=s.length,m=vg(s),v=rg(a.dtype,d);0!==o&&v.fill(o);for(var g=0;g<c;g++){v[Ig(Sg(g,p,h).map((function(e,t){return e+u[t]})),f,m)]=l[g]}return{dataId:n.write(v,s,a.dtype),shape:s,dtype:a.dtype}}},lX=QU((function(e,t){return Math.pow(e,t)})),cX=lG(Lb,lX),pX={kernelName:Lb,backendName:"cpu",kernelFunc:cX};var hX={kernelName:Bb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.paramsNestedSplits,i=t.paramsDenseValues,o=t.indices,s=(r.outputRaggedRank,a.map((function(e){return n.data.get(e.dataId).values}))),u=a.map((function(e){return e.shape})),l=n.data.get(i.dataId).values,c=n.data.get(o.dataId).values,p=Cj(s,u,l,i.shape,i.dtype,c,o.shape),h=p[0],d=p[1],f=p[2],m=h.map((function(e){return n.makeTensorInfo([e.length],"int32",e)})),v=n.makeTensorInfo(f,i.dtype,d);return m.concat([v])}};var dX={kernelName:Wb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.starts,a=t.limits,i=t.deltas,o=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,u=n.data.get(i.dataId).values,l=Aj(o,r.shape,r.dtype,s,a.shape,u,i.shape),c=l[0],p=l[1];return[n.makeTensorInfo([c.length],"int32",c),n.makeTensorInfo([p.length],r.dtype,p)]}};var fX={kernelName:Vb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.shape,i=t.values,o=t.defaultValue,s=t.rowPartitionTensors,u=r.rowPartitionTypes,l=n.data.get(a.dataId).values,c=n.data.get(i.dataId).values,p=n.data.get(o.dataId).values,h=s.map((function(e){return n.data.get(e.dataId).values})),d=s.map((function(e){return e.shape})),f=Dj(l,a.shape,c,i.shape,i.dtype,p,o.shape,h,d,u),m=f[0],v=f[1];return n.makeTensorInfo(m,i.dtype,v)}};var mX={kernelName:Ub,backendName:"cpu",kernelFunc:function(e){var t=e.backend,n=e.attrs,r=n.start,a=n.stop,i=n.dtype,o=Mj(r,a,n.step,i);return t.makeTensorInfo([o.length],i,o)}},vX=yG(jb,(function(e){return 1/e})),gX={kernelName:jb,backendName:"cpu",kernelFunc:vX};var yX={kernelName:Yb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=r.alignCorners,o=r.halfPixelCenters,s=r.size;KU(a,"resizeBilinear");for(var u=vg(a.shape),l=s[0],c=s[1],p=a.shape,h=p[0],d=p[1],f=p[2],m=p[3],v=n.data.get(a.dataId).values,g=new Float32Array(Xv([h,l,c,m])),y=[i&&l>1?d-1:d,i&&c>1?f-1:f],b=[i&&l>1?l-1:l,i&&c>1?c-1:c],x=0,w=y[0]/b[0],k=y[1]/b[1],N=0;N<h;N++)for(var I=0;I<l;I++){var S=void 0;S=o?w*(I+.5)-.5:w*I;for(var T=Math.max(0,Math.floor(S)),C=S-T,E=Math.min(d-1,Math.ceil(S)),A=N*u[0]+T*u[1],R=N*u[0]+E*u[1],_=0;_<c;_++){var F=void 0;F=o?k*(_+.5)-.5:k*_;for(var O=Math.max(0,Math.floor(F)),D=F-O,M=Math.min(f-1,Math.ceil(F)),L=A+O*u[2],z=R+O*u[2],P=A+M*u[2],B=R+M*u[2],W=0;W<m;W++){var V=v[L+W],U=v[z+W],G=V+(v[P+W]-V)*D,j=G+(U+(v[B+W]-U)*D-G)*C;g[x++]=j}}}return n.makeTensorInfo([h,l,c,m],"float32",g)}};var bX={kernelName:Jb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=t.dy,o=r.alignCorners;KU([i,a],"resizeBilinearGrad");for(var s=vg(a.shape),u=a.shape,l=u[0],c=u[1],p=u[2],h=u[3],d=i.shape,f=d[1],m=d[2],v=new Float32Array(l*c*p*h),g=[o&&f>1?c-1:c,o&&m>1?p-1:p],y=[o&&f>1?f-1:f,o&&m>1?m-1:m],b=g[0]/y[0],x=g[1]/y[1],w=n.data.get(i.dataId).values,k=0,N=0;N<l;N++)for(var I=N*s[0],S=0;S<f;S++)for(var T=S*b,C=Math.floor(T),E=Math.min(Math.ceil(T),c-1),A=I+C*s[1],R=I+E*s[1],_=T-C,F=1-_,O=0;O<m;O++)for(var D=O*x,M=Math.floor(D),L=Math.min(Math.ceil(D),p-1),z=D-M,P=1-z,B=A+M*s[2],W=A+L*s[2],V=R+M*s[2],U=R+L*s[2],G=F*P,j=F*z,H=_*P,q=_*z,K=0;K<h;K++){var X=w[k++];v[B+K]+=X*G,v[W+K]+=X*j,v[V+K]+=X*H,v[U+K]+=X*q}return n.makeTensorInfo([l,p,c,h],"float32",v)}};var xX={kernelName:Kb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=r.alignCorners,o=r.halfPixelCenters,s=r.size;KU(a,"resizeNearestNeighbor");for(var u=vg(a.shape),l=s[0],c=s[1],p=a.shape,h=p[0],d=p[1],f=p[2],m=p[3],v=n.data.get(a.dataId).values,g=new Float32Array(h*l*c*m),y=[i&&l>1?d-1:d,i&&c>1?f-1:f],b=[i&&l>1?l-1:l,i&&c>1?c-1:c],x=y[0]/b[0],w=y[1]/b[1],k=0,N=0;N<h;N++)for(var I=N*u[0],S=0;S<l;S++){var T=o?x*(S+.5):x*S,C=Math.min(d-1,i?Math.round(T):Math.floor(T));o&&(C=Math.max(0,C));for(var E=I+C*u[1],A=0;A<c;A++){var R=o?w*(A+.5):w*A,_=Math.min(f-1,i?Math.round(R):Math.floor(R));o&&(_=Math.max(0,_));for(var F=E+_*u[2],O=0;O<m;O++){var D=v[F+O];g[k++]=D}}}return n.makeTensorInfo([h,l,c,m],a.dtype,g)}};var wX={kernelName:Xb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=t.dy,o=r.alignCorners;KU([i,a],"resizeNearestNeighborGrad");for(var s=vg(a.shape),u=vg(i.shape),l=a.shape,c=l[0],p=l[1],h=l[2],d=l[3],f=i.shape,m=f[1],v=f[2],g=new Float32Array(c*p*h*d),y=n.data.get(i.dataId).values,b=[o&&m>1?p-1:p,o&&v>1?h-1:h],x=[o&&m>1?m-1:m,o&&v>1?v-1:v],w=b[0]/x[0],k=b[1]/x[1],N=1/w,I=1/k,S=2*Math.ceil(N)+2,T=2*Math.ceil(I)+2,C=0;C<c;C++)for(var E=C*s[0],A=0;A<p;A++)for(var R=E+A*s[1],_=Math.floor(A*N),F=Math.floor(_-S/2),O=0;O<h;O++)for(var D=R+O*s[2],M=Math.floor(O*I),L=Math.floor(M-T/2),z=0;z<d;z++){for(var P=0,B=0;B<S;B++){var W=B+F;if(!(W<0||W>=m)){var V=E+W*u[1],U=W*w;if(A===Math.min(p-1,o?Math.round(U):Math.floor(U)))for(var G=0;G<T;G++){var j=G+L;if(!(j<0||j>=v)){var H=V+j*u[2],q=j*k;O===Math.min(h-1,o?Math.round(q):Math.floor(q))&&(P+=y[H+z])}}}}g[D+z]=P}return n.makeTensorInfo(a.shape,a.dtype,g)}};var kX={kernelName:Qb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.dims;KU(a,"reverse");var o=a.shape.length,s=tg(i,a.shape);if(0===o)return nG({inputs:{x:a},backend:n});for(var u=new tk(a.shape,a.dtype),l=n.bufferSync(a),c=function(e){var t=u.indexToLoc(e),n=t.slice();s.forEach((function(e){return n[e]=a.shape[e]-1-n[e]})),u.set.apply(u,[l.get.apply(l,n)].concat(t))},p=0;p<u.size;p++)c(p);return n.makeTensorInfo(u.shape,u.dtype,u.values)}},NX={kernelName:Ux,backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=e.attrs,r=e.backend,a=t.image,i=n.radians,o=n.fillValue,s=n.center,u=r,l=rg(a.dtype,Xv(a.shape)),c=a.shape,p=c[0],h=c[1],d=c[2],f=c[3],m=A_(s,h,d),v=m[0],g=m[1],y=Math.sin(i),b=Math.cos(i),x=u.data.get(a.dataId).values,w=0;w<p;w++)for(var k=w*d*h*f,N=0;N<h;N++)for(var I=N*(d*f),S=0;S<d;S++)for(var T=S*f,C=0;C<f;C++){var E=[p,N,S,C],A=E[2],R=E[1],_=(A-v)*b-(R-g)*y,F=(A-v)*y+(R-g)*b;_=Math.round(_+v),F=Math.round(F+g);var O=o;if("number"!=typeof o&&(O=3===C?255:o[C]),_>=0&&_<d&&F>=0&&F<h)O=x[k+F*(d*f)+_*f+C];l[k+I+T+C]=O}return{dataId:u.write(l,a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},IX=yG($b,(function(e){var t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),SX={kernelName:$b,backendName:"cpu",kernelFunc:IX};var TX={kernelName:tx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,i=t.updates,o=r.shape,s=NE(0,a,o),u=s.sliceRank,l=s.numUpdates,c=s.sliceSize,p=s.strides,h=s.outputSize,d=Bj(n.bufferSync(a),n.bufferSync(i),o,h,c,l,u,p,0,!0);return n.makeTensorInfo(o,d.dtype,d.values)}};function CX(e,t){for(var n=0,r=e.length,a=0;n<r;)e[a=Math.floor((n+r)/2)]<t?n=a+1:r=a;return r}function EX(e,t){for(var n=0,r=e.length,a=0;n<r;)e[a=Math.floor((n+r)/2)]<=t?n=a+1:r=a;return r}var AX={kernelName:rx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.sortedSequence,i=t.values,o=r.side,s=function(e,t,n,r,a,i){for(var o=ag("int32",n*a),s=0;s<n;++s)for(var u=e.slice(s*r,(s+1)*r),l=s*a,c=0;c<a;++c)o[l+c]="left"===i?CX(u,t[c+l]):EX(u,t[c+l]);return o}(n.data.get(a.dataId).values,n.data.get(i.dataId).values,a.shape[0],a.shape[1],i.shape[1],o);return n.makeTensorInfo(i.shape,"int32",s)}};var RX={kernelName:ax,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.condition,a=t.t,i=t.e;KU([r,a,i],"select");for(var o=r.shape.length,s=n.data.get(r.dataId).values,u=n.data.get(a.dataId).values,l=n.data.get(i.dataId).values,c=dk(a.dtype,i.dtype),p=wg(Xv(a.shape),c),h=0,d=0===o||o>1||1===a.shape.length?1:Xv(a.shape.slice(1)),f=0;f<s.length;f++)for(var m=0;m<d;m++)1===s[f]?p[h++]=u[f]:p[h++]=l[f];return n.makeTensorInfo(a.shape,c,p)}},_X=yG(ix,(function(e){return e>=0?1.0507009873554805*e:1.7580993408473768*(Math.exp(e)-1)})),FX={kernelName:ix,backendName:"cpu",kernelFunc:_X},OX=yG(lx,(function(e){return e<0?-1:e>0?1:0})),DX={kernelName:lx,backendName:"cpu",kernelFunc:OX},MX=yG(sx,(function(e){return Math.sin(e)})),LX={kernelName:sx,backendName:"cpu",kernelFunc:MX},zX=yG(ux,(function(e){return Math.sinh(e)})),PX={kernelName:ux,backendName:"cpu",kernelFunc:zX},BX=Math.log(1.1920928955078125e-7)+2,WX=yG(px,(function(e){var t=e>-BX,n=e<BX,r=Math.exp(e);return n?r:t?e:Math.log(1+r)})),VX={kernelName:px,backendName:"cpu",kernelFunc:WX};var UX={kernelName:fx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockShape,o=r.paddings;KU([a],"spaceToBatchND");var s=Xv(i),u=[[0,0]];u.push.apply(u,o);for(var l=1+i.length;l<a.shape.length;++l)u.push([0,0]);var c=uX.kernelFunc({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),p=R_(c.shape,i,s,!1),h=__(p.length,i.length,!1),d=F_(c.shape,i,s,!1),f=OH({inputs:{x:c},backend:n,attrs:{shape:p}}),m=xj({inputs:{x:f},backend:n,attrs:{perm:h}}),v=OH({inputs:{x:m},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),v}};var GX={kernelName:gx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.indices,a=t.values,i=t.denseShape,o=t.defaultValue;if(1!==i.shape.length)throw new Error("Dense shape must be a vector, saw:\n "+i.shape);if(2!==r.shape.length)throw new Error("Indices must be a matrix, saw:\n "+r.shape);if(1!==a.shape.length)throw new Error("Values must be a vector, saw:\n "+a.shape);if(0!==o.shape.length)throw new Error("Default value must be a scalar, saw:\n "+o.shape);var s=n.data.get(r.dataId).values,u=n.data.get(a.dataId).values,l=n.data.get(i.dataId).values,c=n.data.get(o.dataId).values[0],p=qj(s,r.shape,r.dtype,u,a.dtype,l,c),h=p[0],d=p[1],f=p[2],m=p[3],v=p[4];return[n.makeTensorInfo(d,r.dtype,h),n.makeTensorInfo([d[0]],a.dtype,f),n.makeTensorInfo([m.length],"bool",new Uint8Array(m.map((function(e){return Number(e)})))),n.makeTensorInfo([v.length],r.dtype,new Int32Array(v))]}};var jX={kernelName:yx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.inputIndices,a=t.inputShape,i=t.newShape;if(2!==r.shape.length)throw new Error("Input indices should be a matrix but received shape\n "+r.shape);if(1!==a.shape.length)throw new Error("Input shape should be a vector but received shape\n "+a.shape);if(1!==i.shape.length)throw new Error("Target shape should be a vector but received shape "+i.shape);var o=Array.from(n.data.get(a.dataId).values),s=n.data.get(r.dataId).values,u=Array.from(n.data.get(i.dataId).values),l=Kj(s,r.shape,r.dtype,o,u),c=l[0],p=l[1],h=l[2];return[n.makeTensorInfo(p,r.dtype,c),n.makeTensorInfo([h.length],i.dtype,new Int32Array(h))]}};var HX={kernelName:bx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.data,a=t.indices,i=t.segmentIds;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error("Indices should be a vector but received shape\n "+a.shape);if(1!==i.shape.length)throw new Error("Segment ids should be a vector but received shape\n "+i.shape);if(a.shape[0]!==i.shape[0])throw new Error("segmentIds and indices should have same size.");var o=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,u=n.data.get(i.dataId).values,l=Xj(o,r.shape,r.dtype,s,u,!0),c=l[0],p=l[1];return n.makeTensorInfo(p,r.dtype,c)}};var qX={kernelName:xx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.data,a=t.indices,i=t.segmentIds;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error("Indices should be a vector but received shape\n "+a.shape);if(1!==i.shape.length)throw new Error("Segment ids should be a vector but received shape\n "+i.shape);if(a.shape[0]!==i.shape[0])throw new Error("segmentIds and indices should have same size.");var o=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,u=n.data.get(i.dataId).values,l=Xj(o,r.shape,r.dtype,s,u),c=l[0],p=l[1];return n.makeTensorInfo(p,r.dtype,c)}};var KX={kernelName:wx,backendName:"cpu",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.sparseIndices,o=n.sparseValues,s=n.defaultValue,u=a.outputShape,l=NE(0,i,u),c=l.sliceRank,p=l.numUpdates,h=l.sliceSize,d=l.strides,f=l.outputSize,m=!1,v=r.bufferSync(i);switch(o.dtype){case"bool":t=Bj(v,r.bufferSync(o),u,f,h,p,c,d,Boolean(r.data.get(s.dataId).values[0]),m);break;case"float32":t=Bj(v,r.bufferSync(o),u,f,h,p,c,d,r.data.get(s.dataId).values[0],m);break;case"int32":t=Bj(v,r.bufferSync(o),u,f,h,p,c,d,r.data.get(s.dataId).values[0],m);break;case"string":t=Bj(v,r.bufferSync(o),u,f,h,p,c,d,jw(r.data.get(s.dataId).values[0]),m);break;default:throw new Error("Unsupported type "+o.dtype)}return r.makeTensorInfo(u,t.dtype,t.values)}};var XX={kernelName:mx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.numOrSizeSplits,o=tg(r.axis,a.shape)[0],s=iF(a,i,o),u=new Array(a.shape.length).fill(0),l=a.shape.slice();return s.map((function(e){var t=[].concat(l);t[o]=e;var r=jj({inputs:{x:a},backend:n,attrs:{begin:u,size:t}});return u[o]+=e,r}))}},YX={kernelName:Nx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=n;KU(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}}},JX=yG(Wx,(function(e,t){var n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),ZX={kernelName:Wx,backendName:"cpu",kernelFunc:JX};var QX={kernelName:Sx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.begin,o=r.end,s=r.strides,u=r.beginMask,l=r.endMask,c=r.ellipsisMask,p=r.newAxisMask,h=r.shrinkAxisMask;KU(a,"stridedSlice");var d,f=d_(a.shape,i,o,s,u,l,c,p,h),m=f.finalShapeSparse,v=f.finalShape,g=f.isIdentity,y=f.sliceDim0,b=f.isSimpleSlice,x=f.begin,w=f.end,k=f.strides;if(g)d=OH({inputs:{x:a},backend:n,attrs:{shape:v}});else if(y||b){Hv(a.shape.length>=1,(function(){return"Input must have rank at least 1, got: "+a.shape.length}));var N=t_(x,w,k),I=jj({inputs:{x:a},backend:n,attrs:{begin:x,size:N}});d=OH({inputs:{x:I},backend:n,attrs:{shape:v}}),n.disposeIntermediateTensorInfo(I)}else{var S=aH(m,n.bufferSync(a),k,x);d=n.makeTensorInfo(v,S.dtype,S.values)}return d}};var $X={kernelName:Tx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=r.separator,i=r.nGramWidths,o=r.leftPad,s=r.rightPad,u=r.padWidth,l=r.preserveShortSequences,c=t.data,p=t.dataSplits,h=oH(n.data.get(c.dataId).values,n.data.get(p.dataId).values,a,i,o,s,u,l),d=h[0],f=h[1];return[n.makeTensorInfo([d.length],"string",d),n.makeTensorInfo(p.shape,"int32",f)]}};var eY={kernelName:Cx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs.skipEmpty,a=t.input,i=t.delimiter;if("string"!==a.dtype)throw new Error("Input must be of datatype string");if(1!==a.shape.length)throw new Error("Input must be a vector, got shape: "+a.shape);if(0!==i.shape.length)throw new Error("Delimiter must be a scalar, got shape: "+i.shape);var o=uH(n.data.get(a.dataId).values,n.data.get(i.dataId).values[0],r),s=o[0],u=o[1],l=o[2],c=u.length;return[n.makeTensorInfo([c,2],"int32",s),n.makeTensorInfo([c],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(l))]}};var tY={kernelName:Ex,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs.numBuckets,a=t.input;if("string"!==a.dtype)throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");var i=lH(n.data.get(a.dataId).values,r);return n.makeTensorInfo(a.shape,"int32",i)}},nY=yG(Rx,(function(e){return Math.tan(e)})),rY={kernelName:Rx,backendName:"cpu",kernelFunc:nY},aY=yG(_x,(function(e){return Math.tanh(e)}));var iY={kernelName:nx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.tensor,a=t.indices,i=t.updates,o=NE(0,a,r.shape),s=o.sliceRank,u=o.numUpdates,l=o.sliceSize,c=o.strides,p=o.outputSize,h=n.bufferSync(a),d=n.bufferSync(i),f=n.bufferSync(r),m=Bj(h,d,r.shape,p,l,u,s,c,f,!1);return n.makeTensorInfo(r.shape,m.dtype,m.values)}};var oY={kernelName:Fx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.reps;KU(a,"tile");var o=fH(n.bufferSync(a),i);return n.makeTensorInfo(o.shape,o.dtype,o.values)}};var sY={kernelName:Ox,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.k,o=r.sorted;KU(a,"topk");var s=gH(n.data.get(a.dataId).values,a.shape,a.dtype,i,o),u=s[0],l=s[1];return[n.makeTensorInfo(u.shape,u.dtype,u.values),n.makeTensorInfo(l.shape,l.dtype,l.values)]}};var uY={kernelName:Dx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.image,i=t.transforms,o=n.interpolation,s=n.fillMode,u=n.fillValue,l=n.outputShape,c=a.shape,p=c[0],h=c[1],d=c[2],f=c[3],m=null!=l?l:[h,d],v=m[0],g=m[1],y=[p,v,g,f],b=vg(a.shape),x=b[0],w=b[1],k=b[2],N=vg(y),I=N[0],S=N[1],T=N[2],C=rg(a.dtype,Xv(y));C.fill(u);for(var E=r.data.get(a.dataId).values,A=r.data.get(i.dataId).values,R=0;R<p;++R){for(var _=1===i.shape[0]?A:A.subarray(8*R,8*R+8),F=0;F<v;++F)for(var O=0;O<g;++O)for(var D=0;D<f;++D){var M=void 0,L=_[6]*O+_[7]*F+1;if(0!==L){var z=(_[0]*O+_[1]*F+_[2])/L,P=(_[3]*O+_[4]*F+_[5])/L,B=lY(z,d,s),W=lY(P,h,s);switch(o){case"nearest":M=pY(E,h,d,x,w,k,R,W,B,D,u);break;case"bilinear":M=hY(E,h,d,x,w,k,R,W,B,D,u);break;default:throw new Error("Error in Transform: Expect 'nearest' or 'bilinear', but got "+o)}C[R*I+F*S+O*T+D]=M}}return r.makeTensorInfo(y,a.dtype,C)}return{dataId:r.write(C,y,a.dtype),shape:a.shape,dtype:a.dtype}}};function lY(e,t,n){switch(n){case"reflect":return function(e,t){var n=e;if(n<0)if(t<=1)n=0;else{var r=2*t;n<r&&(n=r*Math.trunc(-n/r)+n),n=n<-t?n+r:-n-1}else if(n>t-1)if(t<=1)n=0;else{var a=2*t;(n-=a*Math.trunc(n/a))>=t&&(n=a-n-1)}return Vv(0,n,t-1)}(e,t);case"wrap":return function(e,t){var n=e;if(n<0)if(t<=1)n=0;else{var r=t-1;n+=t*(Math.trunc(-n/r)+1)}else if(n>t-1)if(t<=1)n=0;else{var a=t-1;n-=t*Math.trunc(n/a)}return Vv(0,n,t-1)}(e,t);case"nearest":return function(e,t){return Vv(0,e,t-1)}(e,t);default:return function(e,t){return e}(e)}}function cY(e,t,n,r,a,i,o,s,u,l,c){return 0<=s&&s<t&&0<=u&&u<n?e[o*r+s*a+u*i+l]:c}function pY(e,t,n,r,a,i,o,s,u,l,c){return cY(e,t,n,r,a,i,o,Math.round(s),Math.round(u),l,c)}function hY(e,t,n,r,a,i,o,s,u,l,c){var p=Math.floor(s),h=Math.floor(u),d=p+1,f=h+1;return(d-s)*((f-u)*cY(e,t,n,r,a,i,o,p,h,l,c)+(u-h)*cY(e,t,n,r,a,i,o,p,f,l,c))+(s-p)*((f-u)*cY(e,t,n,r,a,i,o,d,h,l,c)+(u-h)*cY(e,t,n,r,a,i,o,d,f,l,c))}var dY={kernelName:Lx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=n.axis,i=t.x;KU(i,"unique");var o=yH(r.data.get(i.dataId).values,a,i.shape,i.dtype),s=o.outputValues,u=o.outputShape,l=o.indices;return[r.makeTensorInfo(u,i.dtype,s),r.makeTensorInfo([l.length],"int32",l)]}};var fY={kernelName:zx,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.value,i=r.axis;i<0&&(i+=a.shape.length);for(var o=a.shape.length,s=a.shape[i],u=new Array(o-1),l=0,c=0;c<o;c++)c!==i&&(u[l++]=a.shape[c]);var p=new Array(o).fill(0),h=a.shape.slice();h[i]=1;for(var d=new Array(s),f=0;f<d.length;f++){p[i]=f;var m=jj({inputs:{x:a},backend:n,attrs:{begin:p,size:h}});d[f]=OH({inputs:{x:m},backend:n,attrs:{shape:u}}),n.disposeIntermediateTensorInfo(m)}return d}};for(var mY={kernelName:Px,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.segmentIds,o=r.numSegments;KU(a,"unsortedSegmentSum");for(var s=[],u=[],l=a.shape.length-i.shape.length,c=i,p=0;p<l;++p){var h=Qq({inputs:{input:c},backend:n,attrs:{dim:p+1}});c=h,u.push(h)}for(var d=0;d<o;++d){var f=Bw(d,"int32"),m=n.makeTensorInfo([],"int32",f),v=SG({inputs:{a:m,b:c},backend:n}),g=sG({inputs:{x:v},backend:n,attrs:{dtype:"float32"}}),y=hj({inputs:{a:g,b:a},backend:n}),b=qq({inputs:{x:y},backend:n,attrs:{axis:0,keepDims:!1}});s.push(b),u.push(m),u.push(v),u.push(g),u.push(y),u.push(b)}var x=oX({inputs:s,backend:n,attrs:{axis:0}});return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),x}},vY=0,gY=[zH,ZU,BH,VH,fG,UH,GH,jH,HH,qH,XH,JH,QH,tq,rq,sq,uq,lq,cq,LH,pq,hq,dq,fq,uG,kG,vq,eG,gq,wq,Nq,Iq,Sq,Tq,Cq,Eq,Rq,Fq,Oq,Dq,Mq,Lq,zq,Bq,Wq,Vq,Uq,Gq,jq,Hq,Xq,kH,Yq,TG,Zq,AG,$q,FG,oK,uK,lK,MG,PG,cK,pK,hK,dK,GG,qG,rG,fK,bq,vK,yK,xK,IH,YG,QG,wK,nj,NK,TK,EK,_K,FK,OK,MK,oj,LK,zK,PK,BK,WK,VK,UK,lj,GK,qK,YK,dj,mj,ZK,$K,tX,yj,nX,iX,sX,uX,pX,CH,Nj,hX,dX,fX,mX,iG,nK,gX,AH,_H,DH,yX,bX,xX,wX,kX,NX,SX,Pj,TX,AX,RX,FX,Uj,DX,LX,PX,Hj,XK,VX,UX,GX,jX,HX,qX,KX,XX,Zj,YX,eH,rH,ZX,QX,$X,eY,tY,dH,Kq,rY,{kernelName:_x,backendName:"cpu",kernelFunc:aY},iY,oY,sY,uY,wj,dY,fY,mY,aX];vY<gY.length;vY++){Qx(gY[vY])}var yY,bY,xY,wY={},kY={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function NY(e,t){wY[e]=t}function IY(e,t){if(!(e in wY)||null!=t){var n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var n=null==t?function(e){if(Fg().getBool("IS_SAFARI")||"undefined"==typeof OffscreenCanvas||2!==e){if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}return new OffscreenCanvas(300,150)}(e):t;n.addEventListener("webglcontextlost",(function(t){t.preventDefault(),delete wY[e]}),!1),Fg().getBool("SOFTWARE_WEBGL_ENABLED")&&(kY.failIfMajorPerformanceCaveat=!1);if(1===e)return n.getContext("webgl",kY)||n.getContext("experimental-webgl",kY);return n.getContext("webgl2",kY)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;wY[e]=n}var r=wY[e];return null==r||r.isContextLost()?(delete wY[e],IY(e)):(r.disable(r.DEPTH_TEST),r.disable(r.STENCIL_TEST),r.disable(r.BLEND),r.disable(r.DITHER),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SAMPLE_COVERAGE),r.enable(r.SCISSOR_TEST),r.enable(r.CULL_FACE),r.cullFace(r.BACK),wY[e])}function SY(e,t){return[t,e]}function TY(e){var t=Xv(e);return Zv(Math.ceil(t/4))}function CY(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function EY(e,t){var n,r,a,i,o,s,u,l,c,p,h=e;return 2===Fg().getNumber("WEBGL_VERSION")?(n=h.R32F,r=h.R16F,a=h.RGBA16F,i=h.RGBA32F,o=h.RED,u=4,l=1,c=h.HALF_FLOAT,p=h.FLOAT,s=h.RGBA8):(n=e.RGBA,r=e.RGBA,a=e.RGBA,i=h.RGBA,o=e.RGBA,u=4,l=4,c=null!=t?t.HALF_FLOAT_OES:null,p=e.FLOAT,s=e.RGBA),{internalFormatFloat:n,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:i,textureFormatFloat:o,downloadTextureFormat:s,downloadUnpackNumChannels:u,defaultNumChannels:l,textureTypeHalfFloat:c,textureTypeFloat:p}}function AY(e,t){var n=t();return Fg().getBool("DEBUG")&&function(e){var t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+_Y(e,t))}(e),n}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(yY||(yY={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(bY||(bY={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(xY||(xY={}));function RY(e){return!!(Fg().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8<Math.abs(e)&&Math.abs(e)<65504)}function _Y(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"Unknown error code "+t}}function FY(e,t){return nJ(e,(function(){return e.getExtension(t)}),'Extension "'+t+'" not supported on this browser.')}function OY(e,t){var n=nJ(e,(function(){return e.createShader(e.VERTEX_SHADER)}),"Unable to create vertex WebGLShader.");if(AY(e,(function(){return e.shaderSource(n,t)})),AY(e,(function(){return e.compileShader(n)})),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function DY(e,t){var n=nJ(e,(function(){return e.createShader(e.FRAGMENT_SHADER)}),"Unable to create fragment WebGLShader.");if(AY(e,(function(){return e.shaderSource(n,t)})),AY(e,(function(){return e.compileShader(n)})),Fg().get("ENGINE_COMPILE_ONLY"))return n;if(!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw PY(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}var MY,LY,zY=/ERROR: [0-9]+:([0-9]+):/g;function PY(e,t){var n=zY.exec(t);if(null==n)return console.log("Couldn't parse line number in error: "+t),void console.log(e);for(var r=+n[1],a=e.split("\n"),i=a.length.toString().length+2,o=a.map((function(e,t){return Qv((t+1).toString(),i)+e})),s=0,u=0;u<o.length;u++)s=Math.max(o[u].length,s);var l=o.slice(0,r-1),c=o.slice(r-1,r),p=o.slice(r);console.log(l.join("\n")),console.log(t.split("\n")[0]),console.log("%c "+Qv(c[0],s),"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(p.join("\n"))}function BY(e){return nJ(e,(function(){return e.createProgram()}),"Unable to create WebGLProgram.")}function WY(e,t){if(AY(e,(function(){return e.linkProgram(t)})),!Fg().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}function VY(e,t){if(AY(e,(function(){return e.validateProgram(t)})),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function UY(e,t){var n=nJ(e,(function(){return e.createBuffer()}),"Unable to create WebGLBuffer");return AY(e,(function(){return e.bindBuffer(e.ARRAY_BUFFER,n)})),AY(e,(function(){return e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)})),n}function GY(e,t){var n=nJ(e,(function(){return e.createBuffer()}),"Unable to create WebGLBuffer");return AY(e,(function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)})),AY(e,(function(){return e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)})),n}function jY(e){return nJ(e,(function(){return e.createTexture()}),"Unable to create WebGLTexture.")}function HY(e,t){var n=Fg().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error("Requested texture size "+("["+e+"x"+t+"]")+" is invalid.");if(e>n||t>n)throw new Error("Requested texture size "+("["+e+"x"+t+"]")+" greater than WebGL maximum on this browser / GPU "+("["+n+"x"+n+"]")+".")}function qY(e){return nJ(e,(function(){return e.createFramebuffer()}),"Unable to create WebGLFramebuffer.")}function KY(e,t,n,r,a,i,o){var s=e.getAttribLocation(t,n);return-1!==s&&(AY(e,(function(){return e.bindBuffer(e.ARRAY_BUFFER,r)})),AY(e,(function(){return e.vertexAttribPointer(s,a,e.FLOAT,!1,i,o)})),AY(e,(function(){return e.enableVertexAttribArray(s)})),!0)}function XY(e,t,n){rJ(e,n),AY(e,(function(){return e.activeTexture(e.TEXTURE0+n)})),AY(e,(function(){return e.bindTexture(e.TEXTURE_2D,t)}))}function YY(e,t,n){return nJ(e,(function(){return e.getUniformLocation(t,n)}),'uniform "'+n+'" not present in program.')}function JY(e,t,n){return e.getUniformLocation(t,n)}function ZY(e,t,n,r){AY(e,(function(){return XY(e,t,r)})),AY(e,(function(){return e.uniform1i(n,r)}))}function QY(e,t,n){AY(e,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,n)})),AY(e,(function(){return e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}))}function $Y(e,t){AY(e,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,t)})),AY(e,(function(){return e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)}))}function eJ(e){var t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+tJ(e,t))}function tJ(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+t}}function nJ(e,t,n){var r=AY(e,(function(){return t()}));if(null==r)throw new Error(n);return r}function rJ(e,t){var n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n)throw new Error("textureUnit must be in "+("[gl.TEXTURE0, gl.TEXTURE"+n+"]")+".")}function aJ(e,t){return void 0===t&&(t=2),Xv(e.slice(0,e.length-t))}function iJ(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function oJ(e){var t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[aJ(e)].concat(iJ(e))),t}function sJ(e,t){void 0===t&&(t=!1);var n=Fg().getNumber("WEBGL_MAX_TEXTURE_SIZE"),r=Fg().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");if(r===1/0&&Fg().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(r=n/2),t&&(n*=2,r*=2,1===(e=e.map((function(t,n){return n>=e.length-2?Uv(e[n]):e[n]}))).length&&(e=[2,e[0]])),2!==e.length){var a=ng(e);e=a.newShape}var i=Xv(e),o=null;e.length<=1&&i<=n?o=[1,i]:2===e.length&&e[0]<=n&&e[1]<=n?o=e:3===e.length&&e[0]*e[1]<=n&&e[2]<=n?o=[e[0]*e[1],e[2]]:3===e.length&&e[0]<=n&&e[1]*e[2]<=n?o=[e[0],e[1]*e[2]]:4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n?o=[e[0]*e[1]*e[2],e[3]]:4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n&&(o=[e[0],e[1]*e[2]*e[3]]);var s=null!=o&&Math.max.apply(Math,o)>r&&Math.min.apply(Math,o)<=(t?2:1)&&Math.min.apply(Math,o)>0;if(null==o||s)if(t){var u=aJ(e),l=2,c=2;if(e.length){var p=iJ(e);l=p[0],c=p[1]}o=Zv(i=u*(l/2)*(c/2)).map((function(e){return 2*e}))}else o=Zv(i);return o}function uJ(e){return e%2==0}function lJ(e,t){if(Yv(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){var n=e[e.length-1],r=t[t.length-1];if(n===r)return!0;if(uJ(n)&&uJ(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&uJ(e[0])&&uJ(t[0])}function cJ(e){if(null==MY){var t=IY(e);MY=t.getParameter(t.MAX_TEXTURE_SIZE)}return MY}function pJ(e){if(null==LY){var t=IY(e);LY=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,LY)}function hJ(e){if(0===e)return 0;var t=IY(e);return dJ(t,"EXT_disjoint_timer_query_webgl2")&&2===e?2:dJ(t,"EXT_disjoint_timer_query")?1:0}function dJ(e,t){return null!=e.getExtension(t)}function fJ(e){try{if(null!=IY(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function mJ(e){if(0===e)return!1;var t=IY(e);if(1===e){if(!dJ(t,"OES_texture_float"))return!1}else if(!dJ(t,"EXT_color_buffer_float"))return!1;return gJ(t)}function vJ(e){if(0===e)return!1;var t=IY(e);if(1!==e){if(dJ(t,"EXT_color_buffer_float"))return gJ(t);var n="EXT_color_buffer_half_float";if(dJ(t,n)){var r=t.getExtension(n);return function(e,t){var n=EY(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);var a=1,i=1;e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,a,i,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);var o=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);var s=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(o),s}(t,r)}return!1}return!!dJ(t,"OES_texture_float")&&(!!dJ(t,"WEBGL_color_buffer_float")&&gJ(t))}function gJ(e){var t=EY(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);var r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);var a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),a}function yJ(e){return 2===e&&null!=IY(e).fenceSync}function bJ(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){null!=e&&Hv("complex64"!==e.dtype,(function(){return t+" does not support complex64 tensors in the WebGL backend."}))}))}var xJ={__proto__:null,callAndCheck:AY,canBeRepresented:RY,getWebGLErrorMessage:_Y,getExtensionOrThrow:FY,createVertexShader:OY,createFragmentShader:DY,logShaderSourceAndInfoLog:PY,createProgram:BY,linkProgram:WY,validateProgram:VY,createStaticVertexBuffer:UY,createStaticIndexBuffer:GY,getNumChannels:function(){return 2===Fg().getNumber("WEBGL_VERSION")?1:4},createTexture:jY,validateTextureSize:HY,createFramebuffer:qY,bindVertexBufferToProgramAttribute:KY,bindTextureUnit:XY,unbindTextureUnit:function(e,t){rJ(e,t),AY(e,(function(){return e.activeTexture(e.TEXTURE0+t)})),AY(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))},getProgramUniformLocationOrThrow:YY,getProgramUniformLocation:JY,bindTextureToProgramUniformSampler:ZY,bindCanvasToFramebuffer:function(e){AY(e,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,null)})),AY(e,(function(){return e.viewport(0,0,e.canvas.width,e.canvas.height)})),AY(e,(function(){return e.scissor(0,0,e.canvas.width,e.canvas.height)}))},bindColorTextureToFramebuffer:QY,unbindColorTextureFromFramebuffer:$Y,validateFramebuffer:eJ,getFramebufferErrorMessage:tJ,getBatchDim:aJ,getRowsCols:iJ,getShapeAs3D:oJ,getTextureShapeFromLogicalShape:sJ,isReshapeFree:lJ,getWebGLMaxTextureSize:cJ,resetMaxTextureSize:function(){MY=null},resetMaxTexturesInShader:function(){LY=null},getMaxTexturesInShader:pJ,getWebGLDisjointQueryTimerVersion:hJ,hasExtension:dJ,isWebGLVersionEnabled:fJ,isCapableOfRenderingToFloatTexture:mJ,isDownloadFloatTextureEnabled:vJ,isWebGLFenceEnabled:yJ,assertNotComplex:bJ},wJ=Fg();function kJ(){var e,t,n,r,a,i,o,s,u,l;return 2===Fg().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",i="outputColor",o="out vec4 outputColor;",s=Fg().getBool("WEBGL2_ISNAN_CUSTOM")?"\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\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="",l="\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 "):(e="",t="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 ",l="\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:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:a,output:i,defineOutput:o,defineSpecialNaN:s,defineSpecialInf:u,defineRound:l}}function NJ(e,t,n){void 0===n&&(n="index");var r=vg(t);return r.map((function(t,a){return"int "+e[a]+" = "+n+" / "+t+"; "+(a===r.length-1?"int "+e[a+1]+" = "+n+" - "+e[a]+" * "+t:"index -= "+e[a]+" * "+t)+";"})).join("")}function IJ(e,t,n){void 0===n&&(n="index");var r=vg(t);return r.map((function(t,a){return"int "+e[a]+" = "+n+" / outShapeStrides["+a+"]"+"; "+(a===r.length-1?"int "+e[a+1]+" = "+n+" - "+e[a]+" * outShapeStrides["+a+"]":"index -= "+e[a]+" * outShapeStrides["+a+"]")+";"})).join("")}function SJ(e,t,n){void 0===n&&(n="index");var r=function(e,t){var n=e.length,r=e.map((function(e){return t+"["+e+"]"})),a=new Array(n-1);a[n-2]=r[n-1];for(var i=n-3;i>=0;--i)a[i]="("+a[i+1]+" * "+r[i+1]+")";return a}(e.map((function(e,t){return t})),t);return r.map((function(t,a){return"int "+e[a]+" = "+n+" / "+r[a]+"; "+(a===r.length-1?"int "+e[a+1]+" = "+n+" - "+e[a]+" * "+r[a]:"index -= "+e[a]+" * "+r[a])+";"})).join("")}function TJ(e){var t=vg(e).map((function(e){return e.toString()}));return"\n int getFlatIndex(ivec3 coords) {\n return coords.x * "+t[0]+" + coords.y * "+t[1]+" + coords.z;\n }\n"}wJ.registerFlag("HAS_WEBGL",(function(){return wJ.getNumber("WEBGL_VERSION")>0})),wJ.registerFlag("WEBGL_VERSION",(function(){return fJ(2)?2:fJ(1)?1:0})),wJ.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(function(){return!1})),wJ.registerFlag("WEBGL_BUFFER_SUPPORTED",(function(){return 2===wJ.get("WEBGL_VERSION")})),wJ.registerFlag("WEBGL_CPU_FORWARD",(function(){return!0})),wJ.registerFlag("WEBGL_FORCE_F16_TEXTURES",(function(){return!1})),wJ.registerFlag("WEBGL_PACK",(function(){return wJ.getBool("HAS_WEBGL")})),wJ.registerFlag("WEBGL_PACK_NORMALIZATION",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_PACK_CLIP",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_PACK_DEPTHWISECONV",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_PACK_REDUCE",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_LAZILY_UNPACK",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_CONV_IM2COL",(function(){return wJ.getBool("WEBGL_PACK")})),wJ.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(function(){return cJ(wJ.getNumber("WEBGL_VERSION"))})),wJ.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(function(){return pJ(wJ.getNumber("WEBGL_VERSION"))})),wJ.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(function(){var e=wJ.getNumber("WEBGL_VERSION");return 0===e?0:hJ(e)})),wJ.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(function(){return wJ.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Rk()})),wJ.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(function(){return mJ(wJ.getNumber("WEBGL_VERSION"))})),wJ.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(function(){return!wJ.getBool("WEBGL_FORCE_F16_TEXTURES")&&wJ.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")})),wJ.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(function(){return vJ(wJ.getNumber("WEBGL_VERSION"))})),wJ.registerFlag("WEBGL_FENCE_API_ENABLED",(function(){return yJ(wJ.getNumber("WEBGL_VERSION"))})),wJ.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(function(){return wJ.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0})),wJ.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(function(){return-1}),(function(e){if(e<0&&-1!==e)throw new Error("WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got "+e+".")})),wJ.registerFlag("WEBGL_FLUSH_THRESHOLD",(function(){return Rk()?1:-1}),(function(e){if(e<0&&-1!==e)throw new Error("WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got "+e+".")})),wJ.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(function(){return 128})),wJ.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(function(){return!1})),wJ.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(function(){return 1e5})),wJ.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(function(){return 128})),wJ.registerFlag("WEBGL_EXP_CONV",(function(){return!1})),wJ.registerFlag("SOFTWARE_WEBGL_ENABLED",(function(){return wJ.getBool("IS_TEST")})),wJ.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",(function(){return 1/0})),wJ.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",(function(){return!1})),wJ.registerFlag("WEBGL2_ISNAN_CUSTOM",(function(){return!1})),wJ.registerFlag("ENGINE_COMPILE_ONLY",(function(){return!1}));var CJ="\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",EJ=IS;function AJ(e,t,n){var r=[];if(e.forEach((function(e){var t=Xv(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push("uniform float "+e.name+(t>1?"["+t+"]":"")+";"):(r.push("uniform sampler2D "+e.name+";"),r.push("uniform int offset"+e.name+";")),n.enableShapeUniforms){switch(BJ(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape).uniformShape.length){case 1:r.push("uniform int "+e.name+"Shape;");break;case 2:r.push("uniform ivec2 "+e.name+"Shape;");break;case 3:r.push("uniform ivec3 "+e.name+"Shape;");break;case 4:r.push("uniform ivec4 "+e.name+"Shape;")}r.push("uniform ivec2 "+e.name+"TexShape;")}})),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:r.push("uniform int outShape;");break;case 2:r.push("uniform ivec2 outShape;"),r.push("uniform int outShapeStrides;");break;case 3:r.push("uniform ivec3 outShape;"),r.push("uniform ivec2 outShapeStrides;");break;case 4:r.push("uniform ivec4 outShape;"),r.push("uniform ivec3 outShapeStrides;")}r.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((function(e){r.push("uniform "+e.type+" "+e.name+(e.arrayIndex?"["+e.arrayIndex+"]":"")+";")}));var a,i,o=r.join("\n"),s=e.map((function(e){return function(e,t,n,r){void 0===n&&(n=!1);var a="";a+=n?_J(e,r):RJ(e,r);var i=e.shapeInfo.logicalShape,o=t.logicalShape;i.length<=o.length&&(a+=n?function(e,t){var n,r=e.name,a=r.charAt(0).toUpperCase()+r.slice(1),i="get"+a+"AtOutCoords",o=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,u=EJ(e.shapeInfo.logicalShape,t.logicalShape),l=PJ(s),c=s-o,p=["x","y","z","w","u","v"];n=0===o?"":s<2&&u.length>=1?"coords = 0;":u.map((function(e){return"coords."+p[e+c]+" = 0;"})).join("\n");var h="";h=s<2&&o>0?"coords":e.shapeInfo.logicalShape.map((function(e,t){return"coords."+p[t+c]})).join(", ");var d="return outputValue;",f=1===Xv(e.shapeInfo.logicalShape),m=1===Xv(t.logicalShape);if(1!==o||f||m){if(f&&!m)d=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?d="return vec4(outputValue.x);":u.indexOf(v)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(g)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);")}}else d="\n return vec4(outputValue.xy, outputValue.xy);\n ";return"\n vec4 "+i+"() {\n "+l+" coords = getOutputCoords();\n "+n+"\n vec4 outputValue = get"+a+"("+h+");\n "+d+"\n }\n "}(e,t):function(e,t){var n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=t.texShape,o=e.shapeInfo.texShape,s=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&s===u&&null==e.shapeInfo.flatOffset&&Yv(o,i))return"\n float "+a+"() {\n return sampleTexture("+n+", resultUV);\n }\n ";var l,c=PJ(u),p=EJ(e.shapeInfo.logicalShape,t.logicalShape),h=u-s,d=["x","y","z","w","u","v"];l=0===s?"":u<2&&p.length>=1?"coords = 0;":p.map((function(e){return"coords."+d[e+h]+" = 0;"})).join("\n");var f="";f=u<2&&s>0?"coords":e.shapeInfo.logicalShape.map((function(e,t){return"coords."+d[t+h]})).join(", ");return"\n float "+a+"() {\n "+c+" coords = getOutputCoords();\n "+l+"\n return get"+r+"("+f+");\n }\n "}(e,t));return a}(e,t,n.packedInputs,n.enableShapeUniforms)})).join("\n"),u=t.texShape,l=kJ(),c=function(e){return"\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return "+e.texture2D+"(textureSampler, uv).r;\n }\n "}(l),p=function(e){return e.version+"\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n "+e.varyingFs+" vec2 resultUV;\n "+e.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 "+e.defineSpecialNaN+"\n "+e.defineSpecialInf+"\n "+e.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 "+FJ+"\n "+OJ+"\n "+DJ+"\n "}(l);return t.isPacked?(a=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){var r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(1===r[0])return n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":"\n int getOutputCoords() {\n return 2 * int(resultUV.x * "+r[1]+".0);\n }\n ";if(1===r[1])return n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":"\n int getOutputCoords() {\n return 2 * int(resultUV.y * "+r[0]+".0);\n }\n ";if(n)return"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ";return"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+r[0]+", "+r[1]+"));\n return 2 * (resTexRC.x * "+r[1]+" + resTexRC.y);\n }\n "}(0,t,n);case 2:return function(e,t,n){var r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(Yv(e,t))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":"\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2("+r[0]+", "+r[1]+"));\n }\n ";var a=Math.ceil(e[1]/2);if(n)return"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ";return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+r[0]+", "+r[1]+"));\n\n int index = resTexRC.x * "+r[1]+" + resTexRC.y;\n int r = 2 * (index / "+a+");\n int c = imod(index, "+a+") * 2;\n\n return ivec2(r, c);\n }\n "}(e,t,n);case 3:return function(e,t,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";var r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[2]/2),i=a*Math.ceil(e[1]/2);return"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+r[0]+", "+r[1]+"));\n int index = resTexRC.x * "+r[1]+" + resTexRC.y;\n\n int b = index / "+i+";\n index -= b * "+i+";\n\n int r = 2 * (index / "+a+");\n int c = imod(index, "+a+") * 2;\n\n return ivec3(b, r, c);\n }\n "}(e,t,n);default:return function(e,t,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";for(var r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[e.length-1]/2),i=a*Math.ceil(e[e.length-2]/2),o=i,s="",u="b, r, c",l=2;l<e.length-1;l++)s="\n int b"+l+" = index / "+(o*=e[e.length-l-1])+";\n index -= b"+l+" * "+o+";\n "+s,u="b"+l+", "+u;return"\n ivec"+e.length+" getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+r[0]+", "+r[1]+"));\n int index = resTexRC.x * "+r[1]+" + resTexRC.y;\n\n "+s+"\n\n int b = index / "+i+";\n index -= b * "+i+";\n\n int r = 2 * (index / "+a+");\n int c = imod(index, "+a+") * 2;\n\n return ivec"+e.length+"("+u+");\n }\n "}(e,t,n)}}(t.logicalShape,u,n.enableShapeUniforms),i=function(e){return"\n void setOutput(vec4 val) {\n "+e.output+" = val;\n }\n "}(l)):(a=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){if(1===t[0])return n?"\n int getOutputCoords() {\n return int(resultUV.x * float(outTexShape[1]));\n }\n ":"\n int getOutputCoords() {\n return int(resultUV.x * "+t[1]+".0);\n }\n ";if(1===t[1])return n?"\n int getOutputCoords() {\n return int(resultUV.y * float(outTexShape[0]));\n }\n ":"\n int getOutputCoords() {\n return int(resultUV.y * "+t[0]+".0);\n }\n ";if(n)return"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n return resTexRC.x * outTexShape[1] + resTexRC.y;\n }\n ";return"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n return resTexRC.x * "+t[1]+" + resTexRC.y;\n }\n "}(0,t,n);case 2:return function(e,t,n){if(Yv(e,t))return n?"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n ":"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2("+t[0]+", "+t[1]+"));\n }\n ";if(1===e[1])return n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n ":"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n return ivec2(index, 0);\n }\n ";if(1===e[0])return n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n ":"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n return ivec2(0, index);\n }\n ";if(n)return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n ";return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n int r = index / "+e[1]+";\n int c = index - r * "+e[1]+";\n return ivec2(r, c);\n }\n "}(e,t,n);case 3:return function(e,t,n){if(n){return"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n "+IJ(["r","c","d"],e)+"\n return ivec3(r, c, d);\n }\n"}var r=NJ(["r","c","d"],e);return"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n "+r+"\n return ivec3(r, c, d);\n }\n "}(e,t,n);case 4:return function(e,t,n){if(n){return"\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n "+IJ(["r","c","d","d2"],e)+"\n return ivec4(r, c, d, d2);\n }\n "}var r=NJ(["r","c","d","d2"],e);return"\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n "+r+"\n return ivec4(r, c, d, d2);\n }\n "}(e,t,n);case 5:return r=t,a=NJ(["r","c","d","d2","d3"],e),"\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2("+r[0]+",\n "+r[1]+"));\n\n int index = resTexRC.x * "+r[1]+" + resTexRC.y;\n\n "+a+"\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n ";case 6:return function(e,t){var n=NJ(["r","c","d","d2","d3","d4"],e);return"\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n\n "+n+"\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n "}(e,t);default:throw new Error(e.length+"-D output sampling is not yet supported")}var r,a}(t.logicalShape,u,n.enableShapeUniforms),i=function(e){return"\n void setOutput(float val) {\n "+e.output+" = vec4(val, 0, 0, 0);\n }\n "}(l)),n.packedInputs&&(p+=MJ),[p,c,i,o,a,s,n.userCode].join("\n")}function RJ(e,t){void 0===t&&(t=!1);var n=e.shapeInfo.logicalShape;switch(n.length){case 0:return function(e,t){var n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return"float "+r+"() {return "+n+";}";var a=e.shapeInfo.texShape,i=a[0],o=a[1];if(1===i&&1===o)return"\n float "+r+"() {\n return sampleTexture("+n+", halfCR);\n }\n ";var s=LJ(n);if(t)return"\n float "+r+"() {\n vec2 uv = uvFromFlat("+n+"TexShape[0], "+n+"TexShape[1], "+s+");\n return sampleTexture("+n+", uv);\n }\n ";var u=e.shapeInfo.texShape,l=u[0],c=u[1];return"\n float "+r+"() {\n vec2 uv = uvFromFlat("+l+", "+c+", "+s+");\n return sampleTexture("+n+", uv);\n }\n "}(e,t);case 1:return function(e,t){var n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return"\n float "+r+"(int index) {\n "+zJ(e)+"\n }\n ";var a=e.shapeInfo.texShape,i=a[0],o=a[1];if(1===o&&1===i)return"\n float "+r+"(int index) {\n return sampleTexture("+n+", halfCR);\n }\n ";var s=LJ(n);if(1===o)return t?"\n float "+r+"(int index) {\n vec2 uv = vec2(0.5, (float(index + "+s+") + 0.5) / float("+n+"TexShape[0]));\n return sampleTexture("+n+", uv);\n }\n ":"\n float "+r+"(int index) {\n vec2 uv = vec2(0.5, (float(index + "+s+") + 0.5) / "+i+".0);\n return sampleTexture("+n+", uv);\n }\n ";if(1===i)return t?"\n float "+r+"(int index) {\n vec2 uv = vec2((float(index + "+s+") + 0.5) / float("+n+"TexShape[1]), 0.5);\n return sampleTexture("+n+", uv);\n }\n ":"\n float "+r+"(int index) {\n vec2 uv = vec2((float(index + "+s+") + 0.5) / "+o+".0, 0.5);\n return sampleTexture("+n+", uv);\n }\n ";if(t)return"\n float "+r+"(int index) {\n vec2 uv = uvFromFlat("+n+"TexShape[0], "+n+"TexShape[1], index + "+s+");\n return sampleTexture("+n+", uv);\n }\n ";return"\n float "+r+"(int index) {\n vec2 uv = uvFromFlat("+i+", "+o+", index + "+s+");\n return sampleTexture("+n+", uv);\n }\n "}(e,t);case 2:return function(e,t){var n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=e.shapeInfo.texShape;if(null!=i&&Yv(n,i)){if(t)return"\n float "+a+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+r+"TexShape[1], "+r+"TexShape[0]);\n return sampleTexture("+r+", uv);\n }\n ";var o=i[0];return"\n float "+a+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+i[1]+".0, "+o+".0);\n return sampleTexture("+r+", uv);\n }\n "}var s=ng(n),u=s.newShape,l=s.keptDims,c=u;if(c.length<n.length){var p=["row","col"];return"\n "+RJ(WJ(e,c),t)+"\n float "+a+"(int row, int col) {\n return "+a+"("+VJ(p,l)+");\n }\n "}if(e.shapeInfo.isUniform)return"\n float "+a+"(int row, int col) {\n int index = round(dot(vec2(row, col), vec2("+n[1]+", 1)));\n "+zJ(e)+"\n }\n ";var h=i[0],d=i[1],f=LJ(r);if(1===d)return t?"\n float "+a+"(int row, int col) {\n float index = dot(vec3(row, col, "+f+"), vec3("+r+"Shape[1], 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / float("+r+"TexShape[0]));\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+a+"(int row, int col) {\n float index = dot(vec3(row, col, "+f+"), vec3("+n[1]+", 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / "+h+".0);\n return sampleTexture("+r+", uv);\n }\n ";if(1===h)return t?"\n float "+a+"(int row, int col) {\n float index = dot(vec3(row, col, "+f+"), vec3("+r+"Shape[1], 1, 1));\n vec2 uv = vec2((index + 0.5) / float("+r+"TexShape[1]), 0.5);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+a+"(int row, int col) {\n float index = dot(vec3(row, col, "+f+"), vec3("+n[1]+", 1, 1));\n vec2 uv = vec2((index + 0.5) / "+d+".0, 0.5);\n return sampleTexture("+r+", uv);\n }\n ";if(t)return"\n float "+a+"(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+r+"Shape[1] + col + "+f+";\n vec2 uv = uvFromFlat("+r+"TexShape[0], "+r+"TexShape[1], index);\n return sampleTexture("+r+", uv);\n }\n ";return"\n float "+a+"(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+n[1]+" + col + "+f+";\n vec2 uv = uvFromFlat("+h+", "+d+", index);\n return sampleTexture("+r+", uv);\n }\n"}(e,t);case 3:return function(e,t){var n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=n[1]*n[2],o=n[2],s=ng(n),u=s.newShape,l=s.keptDims,c=u;if(c.length<n.length){var p=["row","col","depth"];return"\n "+RJ(WJ(e,c),t)+"\n float "+a+"(int row, int col, int depth) {\n return "+a+"("+VJ(p,l)+");\n }\n "}if(e.shapeInfo.isUniform)return"\n float "+a+"(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3("+i+", "+o+", 1)));\n "+zJ(e)+"\n }\n ";var h=e.shapeInfo.texShape,d=h[0],f=h[1],m=e.shapeInfo.flatOffset;if(f===i&&null==m)return t?"\n float "+a+"(int row, int col, int depth) {\n int stride1 = "+r+"Shape[2];\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(stride1, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+r+"TexShape[1], "+r+"TexShape[0]);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+a+"(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2("+o+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+f+".0, "+d+".0);\n return sampleTexture("+r+", uv);\n }\n ";if(f===o&&null==m)return t?"\n float "+a+"(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2("+r+"Shape[1], 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+r+"TexShape[1], "+r+"TexShape[0]);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+a+"(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2("+n[1]+", 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+f+".0, "+d+".0);\n return sampleTexture("+r+", uv);\n }\n ";var v=LJ(r);if(t)return"\n float "+a+"(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int stride0 = "+r+"Shape[1] * "+r+"Shape[2];\n int stride1 = "+r+"Shape[2];\n int index = row * stride0 + col * stride1 + depth + "+v+";\n vec2 uv = uvFromFlat("+r+"TexShape[0], "+r+"TexShape[1], index);\n return sampleTexture("+r+", uv);\n }\n ";return"\n float "+a+"(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+i+" + col * "+o+" + depth + "+v+";\n vec2 uv = uvFromFlat("+d+", "+f+", index);\n return sampleTexture("+r+", uv);\n }\n "}(e,t);case 4:return function(e,t){var n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=n[3],o=n[2]*i,s=n[1]*o,u=ng(n),l=u.newShape,c=u.keptDims;if(l.length<n.length){var p=["row","col","depth","depth2"];return"\n "+RJ(WJ(e,l),t)+"\n float "+a+"(int row, int col, int depth, int depth2) {\n return "+a+"("+VJ(p,c)+");\n }\n "}if(e.shapeInfo.isUniform)return"\n float "+a+"(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4("+s+", "+o+", "+i+", 1)));\n "+zJ(e)+"\n }\n ";var h=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,f=d[0],m=d[1],v="int stride2 = "+r+"Shape[3];",g="int stride1 = "+r+"Shape[2] * stride2;",y="int stride0 = "+r+"Shape[1] * stride1;";if(m===s&&null==h)return t?"\n float "+a+"(int row, int col, int depth, int depth2) {\n "+v+"\n "+g+"\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(stride1, stride2, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+r+"TexShape[1], "+r+"TexShape[0]);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+a+"(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3("+o+", "+i+", 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+m+".0, "+f+".0);\n return sampleTexture("+r+", uv);\n }\n ";if(m===i&&null==h)return t?"\n float "+a+"(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3("+r+"Shape[1] * "+r+"Shape[2], "+r+"Shape[2], 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+r+"TexShape[1], "+r+"TexShape[0]);\n return sampleTexture("+r+", uv);\n }\n ":"\n float "+a+"(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3("+n[1]*n[2]+", "+n[2]+", 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+m+".0, "+f+".0);\n return sampleTexture("+r+", uv);\n }\n ";var b=LJ(r);if(t)return"\n float "+a+"(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n "+v+"\n "+g+"\n "+y+"\n int index = row * stride0 + col * stride1 +\n depth * stride2 + depth2;\n vec2 uv = uvFromFlat("+r+"TexShape[0], "+r+"TexShape[1], index + "+b+");\n return sampleTexture("+r+", uv);\n }\n ";return"\n float "+a+"(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * "+s+" + col * "+o+" +\n depth * "+i+" + depth2;\n vec2 uv = uvFromFlat("+f+", "+m+", index + "+b+");\n return sampleTexture("+r+", uv);\n }\n "}(e,t);case 5:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[4],i=t[3]*a,o=t[2]*i,s=t[1]*o,u=ng(t),l=u.newShape,c=u.keptDims;if(l.length<t.length){var p=["row","col","depth","depth2","depth3"];return"\n "+RJ(WJ(e,l))+"\n float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n return "+r+"("+VJ(p,c)+");\n }\n "}if(e.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 "+zJ(e)+"\n }\n ";var h=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,f=d[0],m=d[1];if(m===s&&null==h)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, "+f+".0);\n return sampleTexture("+n+", uv);\n }\n ";if(m===a&&null==h)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("+t[1]*t[2]*t[3]+",\n "+t[2]*t[3]+", "+t[3]+", 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+m+".0, "+f+".0);\n return sampleTexture("+n+", uv);\n }\n ";var v=LJ(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("+f+", "+m+", index);\n return sampleTexture("+n+", uv);\n }\n "}(e);case 6:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=ng(t),i=a.newShape,o=a.keptDims;if(i.length<t.length){var s=["row","col","depth","depth2","depth3","depth4"];return"\n "+RJ(WJ(e,i))+"\n float "+r+"(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return "+r+"("+VJ(s,o)+");\n }\n "}var u=t[5],l=t[4]*u,c=t[3]*l,p=t[2]*c,h=t[1]*p;if(e.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("+h+", "+p+", "+c+", "+l+")) +\n dot(\n vec2(depth3, depth4),\n vec2("+u+", 1)));\n "+zJ(e)+"\n }\n ";var d=e.shapeInfo.flatOffset,f=e.shapeInfo.texShape,m=f[0],v=f[1];if(v===h&&null==d)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("+p+", "+c+", "+l+", "+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==d)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("+t[1]*t[2]*t[3]*t[4]+",\n "+t[2]*t[3]*t[4]+",\n "+t[3]*t[4]+",\n "+t[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=LJ(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 * "+h+" + col * "+p+" + depth * "+c+" +\n depth2 * "+l+" + depth3 * "+u+" + depth4 + "+g+";\n vec2 uv = uvFromFlat("+m+", "+v+", index);\n return sampleTexture("+n+", uv);\n }\n "}(e);default:throw new Error(n.length+"-D input sampling is not yet supported")}}function _J(e,t){var n,r,a;switch(e.shapeInfo.logicalShape.length){case 0:return n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=kJ(),"\n vec4 "+r+"() {\n return "+a.texture2D+"("+n+", halfCR);\n }\n ";case 1:return function(e,t){var n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,i=kJ();if(t)return"\n vec4 "+r+"(int index) {\n ivec2 packedTexShape = ivec2(ceil(float("+n+"TexShape[0]) / 2.0), ceil(float("+n+"TexShape[1]) / 2.0));\n vec2 uv = packedUVfrom1D(\n packedTexShape[0], packedTexShape[1], index);\n return "+i.texture2D+"("+n+", uv);\n }\n ";var o=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];return"\n vec4 "+r+"(int index) {\n vec2 uv = packedUVfrom1D(\n "+o[0]+", "+o[1]+", index);\n return "+i.texture2D+"("+n+", uv);\n }\n "}(e,t);case 2:return function(e,t){var n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=e.shapeInfo.texShape,o=i[0],s=i[1],u=kJ();if(null!=i&&Yv(n,i))return t?"\n vec4 "+a+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+r+"TexShape[1], "+r+"TexShape[0]);\n\n return "+u.texture2D+"("+r+", uv);\n }\n ":"\n vec4 "+a+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+s+".0, "+o+".0);\n\n return "+u.texture2D+"("+r+", uv);\n }\n ";if(t)return"\n vec4 "+a+"(int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float("+r+"TexShape[0]) / 2.0), ceil(float("+r+"TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float("+r+"Shape[1]) / 2.0));\n vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);\n return "+u.texture2D+"("+r+", uv);\n }\n ";var l=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],c=Math.ceil(n[1]/2);return"\n vec4 "+a+"(int row, int col) {\n vec2 uv = packedUVfrom2D("+c+", "+l[0]+", "+l[1]+", row, col);\n return "+u.texture2D+"("+r+", uv);\n }\n "}(e,t);case 3:return function(e,t){var n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=e.shapeInfo.texShape,o=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];if(1===n[0]){var s=[1,2],u=["b","row","col"];return"\n "+_J(WJ(e,n.slice(1)),t)+"\n vec4 "+a+"(int b, int row, int col) {\n return "+a+"("+VJ(u,s)+");\n }\n "}var l=kJ();if(t)return"\n vec4 "+a+"(int b, int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float("+r+"TexShape[0]) / 2.0), ceil(float("+r+"TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float("+r+"Shape[2]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float("+r+"Shape[1]) / 2.0));\n vec2 uv = packedUVfrom3D(\n packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);\n return "+l.texture2D+"("+r+", uv);\n }\n ";var c=o[0],p=o[1],h=Math.ceil(n[2]/2),d=h*Math.ceil(n[1]/2);return"\n vec4 "+a+"(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n "+c+", "+p+", "+d+", "+h+", b, row, col);\n return "+l.texture2D+"("+r+", uv);\n }\n "}(e,t);default:return function(e,t){var n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=kJ();if(t)return"\n vec4 "+r+"(int b2, int b, int row, int col) {\n int valuesPerRow = int(ceil(float("+n+"Shape[3]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float("+n+"Shape[2]) / 2.0));\n int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);\n texelsInBatch *= "+n+"Shape[1];\n index = b2 * texelsInBatch + index;\n ivec2 packedTexShape = ivec2(ceil(float("+n+"TexShape[0]) / 2.0), ceil(float("+n+"TexShape[1]) / 2.0));\n int texR = index / packedTexShape[1];\n int texC = index - texR * packedTexShape[1];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return "+a.texture2D+"("+n+", uv);\n }\n ";for(var i=e.shapeInfo.logicalShape,o=i.length,s=e.shapeInfo.texShape,u=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],l=u[0],c=u[1],p=Math.ceil(i[o-1]/2),h=p*Math.ceil(i[o-2]/2),d="int b, int row, int col",f="b * "+h+" + (row / 2) * "+p+" + (col / 2)",m=2;m<o-1;m++)d="int b"+m+", "+d,f="b"+m+" * "+(h*=i[o-m-1])+" + "+f;return"\n vec4 "+r+"("+d+") {\n int index = "+f+";\n int texR = index / "+c+";\n int texC = index - texR * "+c+";\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+c+", "+l+");\n return "+a.texture2D+"("+n+", uv);\n }\n "}(e,t)}}var FJ="\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",OJ="\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",DJ="\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",MJ="\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 LJ(e){return"offset"+e}function zJ(e){var t=e.name,n=Xv(e.shapeInfo.logicalShape);return n<2?"return "+t+";":"\n for (int i = 0; i < "+n+"; i++) {\n if (i == index) {\n return "+t+"[i];\n }\n }\n "}function PJ(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error("GPU for rank "+e+" is not yet supported")}function BJ(e,t,n){var r=ng(t),a=r.newShape,i=r.keptDims,o=t.length,s=e&&3===o&&1===t[0],u=s?t.slice(1):a,l=!e&&o>1&&!Yv(t,n)&&a.length<o||s;return{useSqueezeShape:l,uniformShape:l?u:t,keptDims:i}}function WJ(e,t){var n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function VJ(e,t){return t.map((function(t){return e[t]})).join(", ")}function UJ(e,t,n){var r,a,i,o,s=[],u=[],l=null;o=e.getUniformLocation(n,"NAN",!1),1===Fg().getNumber("WEBGL_VERSION")&&(l=e.getUniformLocation(n,"INFINITY",!1));for(var c,p=!1,h=Lv(t.variableNames);!(c=h()).done;){var d=c.value,f={name:d,uniform:e.getUniformLocation(n,d,p),offset:e.getUniformLocation(n,"offset"+d,p)};t.enableShapeUniforms&&(f.shape=e.getUniformLocation(n,d+"Shape",p),f.texShape=e.getUniformLocation(n,d+"TexShape",p)),s.push(f)}if(t.enableShapeUniforms&&(r=e.getUniformLocation(n,"outShape",p),i=e.getUniformLocation(n,"outShapeStrides",p),a=e.getUniformLocation(n,"outTexShape",p)),t.customUniforms)for(var m,v=Lv(t.customUniforms);!(m=v()).done;){var g=m.value;u.push(e.getUniformLocation(n,g.name,p))}return{variablesLocations:s,customUniformLocations:u,infLoc:l,nanLoc:o,outShapeLocation:r,outShapeStridesLocation:i,outTexShapeLocation:a}}function GJ(e,t){if(e.length!==t.length)throw Error("Binary was compiled with "+e.length+" inputs, but was executed with "+t.length+" inputs");e.forEach((function(e,n){var r=e.logicalShape,a=t[n],i=a.shape;if(!Yv(r,i))throw Error("Binary was compiled with different shapes than the current args. Shapes "+r+" and "+i+" must match");if(!e.isUniform||!a.isUniform){var o=e.texShape,s=a.isUniform?null:a.texData.texShape;if(!Yv(o,s))throw Error("Binary was compiled with different texture shapes than the current args. Shape "+o+" and "+s+" must match")}}))}function jJ(e){return Fg().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}var HJ=function(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=yY.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];var t=kJ();this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length),this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n "+(this.enableShapeUniforms?IJ(["r","c","d"],e):NJ(["r","c","d"],e))+"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[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 "+t.output+" = result;\n }\n "},qJ=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=yY.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];var t=kJ();this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length),this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n "+(this.enableShapeUniforms?IJ(["r","c","d"],e):NJ(["r","c","d"],e))+"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[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 "+t.output+" = result;\n }\n "},KJ=function(e){this.variableNames=["A"],this.outTexUsage=bY.DOWNLOAD;var t=kJ();this.outputShape=e,this.userCode="\n "+CJ+"\n\n void main() {\n float x = getAAtOutCoords();\n "+t.output+" = encode_float(x);\n }\n "},XJ=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=bY.DOWNLOAD;var t=kJ();this.outputShape=e,this.userCode="\n "+CJ+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n "+t.output+" = encode_float(x);\n }\n "},YJ={R:0,G:1,B:2,A:3},JJ=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n="RGBA"),this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];var r=kJ();this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length);var a="result";t&&(a="floor(result * 255. + 0.5)");for(var i="",o=0;o<n.length;o++){var s=n[o];i+="\n if(offset == "+o+") {\n result = values["+YJ[s]+"];\n }"}this.userCode="\n "+(this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":TJ(e))+"\n\n void main() {\n ivec3 coords = getOutputCoords();\n int flatIndex = getFlatIndex(coords);\n float result = 0.;\n int offset = imod(flatIndex, "+n.length+");\n\n flatIndex = idiv(flatIndex, "+n.length+", 1.);\n\n int r = flatIndex / texShape[1];\n if (r < texShape[0]) {\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = "+r.texture2D+"(A, uv);\n "+i+"\n }\n "+r.output+" = vec4("+a+", 0., 0., 0.);\n }\n "},ZJ=function(e,t){void 0===t&&(t=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];var n=kJ();this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length);var r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(var i=0;i<=1;i++)for(var o=0;o<=1;o++){var s=2*i+o;r+="\n localCoords = coords;\n if(localCoords[2] + "+o+" < "+(this.enableShapeUniforms?"outShape[2]":""+e[2])+") {\n localCoords[2] += "+o+";\n if (localCoords[1] + "+i+" < "+(this.enableShapeUniforms?"outShape[1]":""+e[1])+") {\n localCoords[1] += "+i+";\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = "+n.texture2D+"(A, uv);\n\n if (offset == 0) {\n result["+s+"] = values[0];\n } else if (offset == 1) {\n result["+s+"] = values[1];\n } else if (offset == 2) {\n result["+s+"] = values[2];\n } else {\n result["+s+"] = values[3];\n }\n }\n }\n "}this.userCode="\n "+(this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":TJ(e))+"\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 "+r+"\n\n "+n.output+" = "+a+";\n }\n "};function QJ(e){var t=kJ();return OY(e,t.version+"\n precision highp float;\n "+t.attribute+" vec3 clipSpacePos;\n "+t.attribute+" vec2 uv;\n "+t.varyingVs+" vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }")}function $J(e){return UY(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function eZ(e){return GY(e,new Uint16Array([0,1,2,2,1,3]))}function tZ(e,t,n,r,a,i){HY(t,n);var o=jY(e),s=e.TEXTURE_2D;return AY(e,(function(){return e.bindTexture(s,o)})),AY(e,(function(){return e.texParameteri(s,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)})),AY(e,(function(){return e.texParameteri(s,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)})),AY(e,(function(){return e.texParameteri(s,e.TEXTURE_MIN_FILTER,e.NEAREST)})),AY(e,(function(){return e.texParameteri(s,e.TEXTURE_MAG_FILTER,e.NEAREST)})),1===Fg().getNumber("WEBGL_VERSION")?AY(e,(function(){return e.texImage2D(s,0,r,t,n,0,a,i,null)})):AY(e,(function(){return e.texStorage2D(s,1,r,t,n)})),AY(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)})),{texture:o,texShape:[n,t]}}function nZ(e){return e.internalFormatFloat}function rZ(e,t,n,r){var a=SY(t,n);return tZ(e,a[0],a[1],nZ(r),r.textureFormatFloat,e.FLOAT)}function aZ(e){return e.internalFormatHalfFloat}function iZ(e,t,n,r){var a=SY(t,n);return tZ(e,a[0],a[1],aZ(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function oZ(e){return e.downloadTextureFormat}function sZ(e,t,n,r){var a=SY(t,n);return tZ(e,a[0],a[1],oZ(r),e.RGBA,e.UNSIGNED_BYTE)}function uZ(e){return e.internalFormatPackedFloat}function lZ(e,t,n,r){var a=CY(t,n);return tZ(e,a[0],a[1],uZ(r),e.RGBA,e.FLOAT)}function cZ(e){return e.internalFormatPackedHalfFloat}function pZ(e,t,n,r){var a=CY(t,n);return tZ(e,a[0],a[1],cZ(r),e.RGBA,r.textureTypeHalfFloat)}function hZ(e,t,n){return AY(e,(function(){return e.bindBuffer(e.ARRAY_BUFFER,n)})),KY(e,t,"clipSpacePos",n,3,20,0)&&KY(e,t,"uv",n,2,20,12)}function dZ(e,t,n,r,a,i){var o,s,u;AY(e,(function(){return e.bindTexture(e.TEXTURE_2D,t)})),a instanceof Uint8Array?(o=new Uint8Array(n*r*4),s=e.UNSIGNED_BYTE,u=e.RGBA):(o=new Float32Array(n*r*4),s=e.FLOAT,u=i.internalFormatPackedFloat),o.set(a),2===Fg().getNumber("WEBGL_VERSION")?AY(e,(function(){return e.texSubImage2D(e.TEXTURE_2D,0,0,0,n,r,e.RGBA,s,o)})):AY(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,u,n,r,0,e.RGBA,s,o)})),AY(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))}function fZ(e,t,n){AY(e,(function(){return e.bindTexture(e.TEXTURE_2D,t)})),n.data instanceof Uint8Array?2===Fg().getNumber("WEBGL_VERSION")?AY(e,(function(){return e.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,e.RGBA,e.UNSIGNED_BYTE,n.data)})):AY(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)})):2===Fg().getNumber("WEBGL_VERSION")?AY(e,(function(){return e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n)})):AY(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)})),AY(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))}function mZ(e,t,n,r){var a=e.createBuffer();AY(e,(function(){return e.bindBuffer(e.PIXEL_PACK_BUFFER,a)}));var i=16*t*n;return AY(e,(function(){return e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ)})),AY(e,(function(){return e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)})),AY(e,(function(){return e.bindBuffer(e.PIXEL_PACK_BUFFER,null)})),a}function vZ(e,t,n){var r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}function gZ(e,t,n,r){var a=SY(t,n),i=a[0],o=a[1],s=new Uint8Array(t*n*4);return AY(e,(function(){return e.readPixels(0,0,i,o,r.downloadTextureFormat,e.UNSIGNED_BYTE,s)})),new Float32Array(s.buffer)}function yZ(e,t,n,r,a,i,o,s){var u=e,l=new Float32Array(function(e,t){var n=CY(e,t);return n[0]*n[1]*4}(i,o));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}function bZ(e,t,n){var r=new Float32Array(t*n*4);return AY(e,(function(){return e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r)})),r}var xZ={__proto__:null,createVertexShader:QJ,createVertexBuffer:$J,createIndexBuffer:eZ,getInternalFormatForFloat32MatrixTexture:nZ,createFloat32MatrixTexture:rZ,getInternalFormatForFloat16MatrixTexture:aZ,createFloat16MatrixTexture:iZ,getInternalFormatForUnsignedBytesMatrixTexture:oZ,createUnsignedBytesMatrixTexture:sZ,getInternalFormatForPackedMatrixTexture:uZ,createPackedMatrixTexture:lZ,getInternalFormatForFloat16PackedMatrixTexture:cZ,createFloat16PackedMatrixTexture:pZ,bindVertexProgramAttributeStreams:hZ,uploadDenseMatrixToTexture:dZ,uploadPixelDataToTexture:fZ,createBufferFromOutputTexture:mZ,downloadFloat32MatrixFromBuffer:vZ,downloadByteEncodedFloatMatrixFromOutputTexture:gZ,downloadPackedMatrixFromBuffer:yZ,downloadMatrixFromPackedOutputTexture:bZ},wZ=function(){function e(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];var t=Fg().getNumber("WEBGL_VERSION");if(null!=e?(this.gl=e,NY(t,e)):this.gl=IY(t),e=this.gl,2===Fg().getNumber("WEBGL_VERSION")){var n=e;this.createVertexArray=function(){return AY(n,(function(){return n.createVertexArray()}))},this.bindVertexArray=function(e){return AY(n,(function(){return n.bindVertexArray(e)}))},this.deleteVertexArray=function(e){return AY(n,(function(){return n.deleteVertexArray(e)}))},this.getVertexArray=function(){return AY(n,(function(){return n.getParameter(n.VERTEX_ARRAY_BINDING)}))}}else if(null!=e){var r=e.getExtension("OES_vertex_array_object");if(null==r)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=function(){return AY(e,(function(){return r.createVertexArrayOES()}))},this.bindVertexArray=function(t){return AY(e,(function(){return r.bindVertexArrayOES(t)}))},this.deleteVertexArray=function(t){return AY(e,(function(){return r.deleteVertexArrayOES(t)}))},this.getVertexArray=function(){return AY(e,(function(){return e.getParameter(r.VERTEX_ARRAY_BINDING_OES)}))}}var a="WEBGL_color_buffer_float",i="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===Fg().getNumber("WEBGL_VERSION")){var o="OES_texture_half_float";if(this.textureFloatExtension=FY(this.gl,"OES_texture_float"),dJ(this.gl,o))this.textureHalfFloatExtension=FY(this.gl,o);else if(Fg().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(a),dJ(this.gl,i))this.colorBufferHalfFloatExtension=FY(this.gl,i);else if(Fg().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(a="EXT_color_buffer_float",dJ(this.gl,a))this.colorBufferFloatExtension=this.gl.getExtension(a);else{if(!dJ(this.gl,i))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(i)}this.vertexBuffer=$J(this.gl),this.indexBuffer=eZ(this.gl),this.framebuffer=qY(this.gl),this.textureConfig=EY(this.gl,this.textureHalfFloatExtension)}var t=e.prototype;return t.dispose=function(){var e=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 t=this.gl;AY(t,(function(){return t.finish()})),AY(t,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,null)})),AY(t,(function(){return t.deleteFramebuffer(e.framebuffer)})),AY(t,(function(){return t.bindBuffer(t.ARRAY_BUFFER,null)})),AY(t,(function(){return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)})),AY(t,(function(){return t.deleteBuffer(e.indexBuffer)})),this.disposed=!0}},t.createFloat32MatrixTexture=function(e,t){return this.throwIfDisposed(),rZ(this.gl,e,t,this.textureConfig)},t.createFloat16MatrixTexture=function(e,t){return this.throwIfDisposed(),iZ(this.gl,e,t,this.textureConfig)},t.createUnsignedBytesMatrixTexture=function(e,t){return this.throwIfDisposed(),sZ(this.gl,e,t,this.textureConfig)},t.uploadPixelDataToTexture=function(e,t){this.throwIfDisposed(),fZ(this.gl,e,t)},t.uploadDenseMatrixToTexture=function(e,t,n,r){this.throwIfDisposed(),dZ(this.gl,e,t,n,r,this.textureConfig)},t.createFloat16PackedMatrixTexture=function(e,t){return this.throwIfDisposed(),pZ(this.gl,e,t,this.textureConfig)},t.createPackedMatrixTexture=function(e,t){return this.throwIfDisposed(),lZ(this.gl,e,t,this.textureConfig)},t.deleteMatrixTexture=function(e){var t=this;this.throwIfDisposed(),this.outputTexture===e&&($Y(this.gl,this.framebuffer),this.outputTexture=null),AY(this.gl,(function(){return t.gl.deleteTexture(e)}))},t.downloadByteEncodedFloatMatrixFromOutputTexture=function(e,t,n){var r=this;return this.downloadMatrixDriver(e,(function(){return gZ(r.gl,t,n,r.textureConfig)}))},t.downloadPackedMatrixFromBuffer=function(e,t,n,r,a,i){return yZ(this.gl,e,0,0,0,a,i,this.textureConfig)},t.downloadFloat32MatrixFromBuffer=function(e,t){return vZ(this.gl,e,t)},t.createBufferFromTexture=function(e,t,n){this.bindTextureToFrameBuffer(e);var r=mZ(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r},t.createAndWaitForFence=function(){var e=this.createFence(this.gl);return this.pollFence(e)},t.createFence=function(e){var t,n,r=this;if(Fg().getBool("WEBGL_FENCE_API_ENABLED")){var a=e,i=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=function(){var e=a.clientWaitSync(i,0,0);return e===a.ALREADY_SIGNALED||e===a.CONDITION_SATISFIED},t=i}else Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=function(){return r.isQueryAvailable(t,Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):n=function(){return!0};return{query:t,isFencePassed:n}},t.downloadMatrixFromPackedTexture=function(e,t,n){var r=this;return this.downloadMatrixDriver(e,(function(){return bZ(r.gl,t,n)}))},t.createProgram=function(e){var t=this;this.throwIfDisposed();var n=this.gl;null==this.vertexShader&&(this.vertexShader=QJ(n));var r,a=BY(n);return AY(n,(function(){return n.attachShader(a,t.vertexShader)})),AY(n,(function(){return n.attachShader(a,e)})),WY(n,a),r=Object.assign(a,{vao:this.createVertexArray()}),this.bindVertexArray(r.vao),AY(n,(function(){return n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.indexBuffer)})),console.assert(hZ(n,r,this.vertexBuffer),"gpgpu_util.bindVertexProgramAttributeStreams not fully successful."),this.debug&&VY(n,r),this.setProgram(r),r},t.deleteProgram=function(e){var t=this;this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&(AY(this.gl,(function(){return t.gl.deleteProgram(e)})),this.deleteVertexArray(e.vao))},t.setProgram=function(e){var t=this;this.throwIfDisposed(),this.program=e,null!=this.program&&(this.bindVertexArray(this.program.vao),this.debug&&VY(this.gl,this.program)),AY(this.gl,(function(){return t.gl.useProgram(e)}))},t.getUniformLocation=function(e,t,n){return void 0===n&&(n=!0),this.throwIfDisposed(),n?YY(this.gl,e,t):JY(this.gl,e,t)},t.getAttributeLocation=function(e,t){var n=this;return this.throwIfDisposed(),AY(this.gl,(function(){return n.gl.getAttribLocation(e,t)}))},t.getUniformLocationNoThrow=function(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)},t.setInputMatrixTexture=function(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),ZY(this.gl,e,t,n)},t.setOutputMatrixTexture=function(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)},t.setOutputPackedMatrixTexture=function(e,t,n){this.throwIfDisposed();var r=CY(t,n),a=r[0],i=r[1];this.setOutputMatrixTextureDriver(e,a,i)},t.setOutputMatrixWriteRegion=function(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)},t.setOutputPackedMatrixWriteRegion=function(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")},t.debugValidate=function(){null!=this.program&&VY(this.gl,this.program),eJ(this.gl)},t.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var e=this.gl;if(this.debug){var t=this.getVertexArray();console.assert(t===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}AY(e,(function(){return e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}))},t.blockUntilAllProgramsCompleted=function(){var e=this;this.throwIfDisposed(),AY(this.gl,(function(){return e.gl.finish()}))},t.getQueryTimerExtension=function(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=FY(this.gl,2===Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension},t.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension()},t.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension()},t.beginQuery=function(){if(2===Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}var r=this.getQueryTimerExtensionWebGL1(),a=r.createQueryEXT();return r.beginQueryEXT(r.TIME_ELAPSED_EXT,a),a},t.endQuery=function(){if(2!==Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}else{var t=this.gl,n=this.getQueryTimerExtensionWebGL2();t.endQuery(n.TIME_ELAPSED_EXT)}},t.waitForQueryAndGetTime=function(){var e=Iv(kv().mark((function e(t){var n=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,$v((function(){return n.disposed||n.isQueryAvailable(t,Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}));case 2:return e.abrupt("return",this.getQueryTime(t,Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getQueryTime=function(e,t){if(0===t)return null;if(2===t){var n=this.gl;return n.getQueryParameter(e,n.QUERY_RESULT)/1e6}var r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(e,r.QUERY_RESULT_EXT)/1e6},t.isQueryAvailable=function(e,t){if(0===t)return!0;if(2===t){var n=this.gl,r=this.getQueryTimerExtensionWebGL2(),a=n.getQueryParameter(e,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(e,i.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(i.GPU_DISJOINT_EXT)),o&&!this.disjoint},t.pollFence=function(e){var t=this;return new Promise((function(n){t.addItemToPoll((function(){return e.isFencePassed()}),(function(){return n()}))}))},t.pollItems=function(){for(var e=function(e){for(var t=0;t<e.length;++t){if(!e[t]())break}return t-1}(this.itemsToPoll.map((function(e){return e.isDoneFn}))),t=0;t<=e;++t){(0,this.itemsToPoll[t].resolveFn)()}this.itemsToPoll=this.itemsToPoll.slice(e+1)},t.addItemToPoll=function(e,t){var n=this;if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),!(this.itemsToPoll.length>1)){var r=void 0;"setTimeoutCustom"in Fg().platform&&(r=Fg().platform.setTimeoutCustom.bind(Fg().platform)),$v((function(){return n.pollItems(),0===n.itemsToPoll.length}),(function(){return 0}),null,r)}},t.bindTextureToFrameBuffer=function(e){this.throwIfDisposed(),QY(this.gl,e,this.framebuffer),this.debug&&eJ(this.gl)},t.unbindTextureToFrameBuffer=function(){null!=this.outputTexture?(QY(this.gl,this.outputTexture,this.framebuffer),this.debug&&eJ(this.gl)):$Y(this.gl,this.framebuffer)},t.downloadMatrixDriver=function(e,t){this.bindTextureToFrameBuffer(e);var n=t();return this.unbindTextureToFrameBuffer(),n},t.setOutputMatrixTextureDriver=function(e,t,n){this.throwIfDisposed();var r=this.gl;QY(r,e,this.framebuffer),this.debug&&eJ(r),this.outputTexture=e,AY(r,(function(){return r.viewport(0,0,t,n)})),AY(r,(function(){return r.scissor(0,0,t,n)}))},t.setOutputMatrixWriteRegionDriver=function(e,t,n,r){var a=this;this.throwIfDisposed(),AY(this.gl,(function(){return a.gl.scissor(e,t,n,r)}))},t.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")},t.throwIfNoProgram=function(){if(null==this.program)throw new Error("No GPU program is currently set.")},Tv(e,[{key:"debug",get:function(){return Fg().getBool("DEBUG")}}]),e}();var kZ=pG,NZ=mG,IZ=vG,SZ=oG,TZ=xG,CZ=NG,EZ=IG,AZ=CG,RZ=RG,_Z=OG,FZ=BG,OZ=WG,DZ=VG,MZ=jG,LZ=KG,zZ=JG,PZ=$G,BZ=ej,WZ=rj,VZ=aj,UZ=sj,GZ=cj,jZ=fj,HZ=vj,qZ=kj,KZ=Cj,XZ=Aj,YZ=Dj,JZ=Mj,ZZ=Lj,QZ=Bj,$Z=Wj,eQ=JU,tQ=Gj,nQ=qj,rQ=Kj,aQ=Xj,iQ=Yj,oQ=tH,sQ=aH,uQ=oH,lQ=uH,cQ=lH,pQ=cH,hQ=fH,dQ=gH,fQ=bj,mQ=yH;function vQ(e,t){return["x","y","z","w","u","v"].slice(0,t).map((function(t){return e+"."+t}))}function gQ(e,t){return 1===t?[e]:vQ(e,t)}var yQ=function(){function e(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=jJ(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{var t=gQ("rc",this.rank),n=PJ(this.rank),r=this.getOutOfBoundsCondition(t),a=this.getSetup(t),i=this.getOutput(t);this.userCode="\n void main() {\n "+n+" rc = getOutputCoords();\n\n if("+r+") {\n setOutput(vec4(0));\n } else {\n "+a+"\n\n setOutput(vec4("+i+"));\n }\n }\n "}}var t=e.prototype;return t.getSourceCoordsArr=function(e){for(var t=[],n=0;n<=1;n++)for(var r=0;r<=1;r++){for(var a=(0===n?"r":"rp1")+", "+(0===r?"c":"cp1"),i=2;i<this.rank;i++)a=e[e.length-1-i]+","+a;t.push(a)}return t},t.getOutOfBoundsCondition=function(e){if(1===this.rank)return"rc > "+(this.enableShapeUniforms?"outShape":this.outputShape[0]);for(var t="",n=this.rank-2;n<this.rank;n++)t+=e[n]+" >= "+(this.enableShapeUniforms?"outShape["+n+"]":this.outputShape[n]),n<this.rank-1&&(t+="||");return t},t.getSetup=function(e){if(1===this.rank)return"";var t=e.slice(-2),n=this.enableShapeUniforms?"outShape["+this.rank+" - 1]":this.outputShape[this.rank-1],r=this.enableShapeUniforms?"outShape["+this.rank+" - 2]":this.outputShape[this.rank-2];return"\n int r = "+t[0]+";\n int c = "+t[1]+";\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= "+n+";\n bool rEdge = rp1 >= "+r+";\n "},t.getOutput=function(e){var t=this.getSourceCoordsArr(e);return 1===this.rank?"getA(rc), (rc + 1 >= "+(this.enableShapeUniforms?"outShape":this.outputShape[0])+" ? 0. : getA(rc + 1)), 0, 0":"getA("+t[0]+"),\n cEdge ? 0. : getA("+t[1]+"),\n rEdge ? 0. : getA("+t[2]+"),\n rEdge || cEdge ? 0. : getA("+t[3]+")"},e}(),bQ=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length);for(var n,r="",a=0;a<4;a++){var i="thisRC = rc;";a%2==1&&(i+="thisRC.z += 1;"),a>1&&(i+="thisRC.y += 1;"),r+="\n "+i+"\n "+(a>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["+a+"] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n "+(a>0?"}":"")+"\n "}this.userCode="\n "+(n=t,"\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n "+(this.enableShapeUniforms?SJ(["r","c","d"],"inputShape"):NJ(["r","c","d"],n))+"\n return ivec3(r, c, d);\n }\n \n ")+(this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":TJ(e))+"\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = "+(this.enableShapeUniforms?"outShape[1]":e[1])+";\n int cols = "+(this.enableShapeUniforms?"outShape[2]":e[2])+";\n\n "+r+"\n\n setOutput(result);\n }\n "};var xQ=function(){function e(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}var t=e.prototype;return t.acquireTexture=function(e,t,n){var r=kQ(t,n),a=NQ(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);var i,o=wQ(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=o,this.log();var s=this.freeTextures[a].pop();return this.usedTextures[a].push(s),s}return r===xY.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===xY.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===xY.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===xY.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===xY.PACKED_4X1_UNSIGNED_BYTE&&(i=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(i),this.numUsedTextures++,this._numBytesAllocated+=o,this.log(),i},t.releaseTexture=function(e,t,n,r){if(null!=this.freeTextures){var a=kQ(n,r),i=NQ(t,a,r);i in this.freeTextures||(this.freeTextures[i]=[]);var o=wQ(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),s=Fg().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==s&&this._numBytesAllocated>s?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=o):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=o),this.numUsedTextures--;var u=this.usedTextures[i],l=u&&u.indexOf(e);if(null==l||l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u[l]=u[u.length-1],u.pop(),this.log()}},t.log=function(){if(this.logEnabled){var e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+e+")");var t=this._numBytesFree/this._numBytesAllocated;console.log("Bytes allocated: "+this._numBytesAllocated),console.log("Bytes unused: "+this._numBytesFree+" ("+Math.round(100*t)+"%)")}},t.getNumUsedTextures=function(){return this.numUsedTextures},t.getNumFreeTextures=function(){return this.numFreeTextures},t.dispose=function(){var e=this;if(null!=this.freeTextures){for(var t in this.freeTextures)this.freeTextures[t].forEach((function(t){e.gpgpu.deleteMatrixTexture(t.texture)}));for(var n in this.usedTextures)this.usedTextures[n].forEach((function(t){e.gpgpu.deleteMatrixTexture(t.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}},Tv(e,[{key:"numBytesAllocated",get:function(){return this._numBytesAllocated}},{key:"numBytesFree",get:function(){return this._numBytesFree}}]),e}();function wQ(e,t,n,r,a){var i,o=function(e,t){switch(e){case xY.PACKED_2X2_FLOAT32:return uZ(t);case xY.PACKED_2X2_FLOAT16:return cZ(t);case xY.UNPACKED_FLOAT32:return nZ(t);case xY.UNPACKED_FLOAT16:return aZ(t);case xY.PACKED_4X1_UNSIGNED_BYTE:return oZ(t);default:throw new Error("Unknown physical texture type "+e)}}(t,r);if(a){var s=CY(e[0],e[1]);i=s[0]*s[1]}else{var u=SY(e[0],e[1]);i=u[0]*u[1]}var l=function(e,t){var n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;if(t===n.RGBA8)return 4;throw new Error("Unknown internal format "+t)}(n,o);return i*l}function kQ(e,t){if(e===bY.UPLOAD)return xY.PACKED_2X2_FLOAT32;if(e===bY.RENDER||null==e)return function(e){return Fg().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?xY.PACKED_2X2_FLOAT32:xY.UNPACKED_FLOAT32:e?xY.PACKED_2X2_FLOAT16:xY.UNPACKED_FLOAT16}(t);if(e===bY.DOWNLOAD||e===bY.PIXELS)return xY.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+e)}function NQ(e,t,n){return e[0]+"_"+e[1]+"_"+t+"_"+n}var IQ=function(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length),this.userCode="\n float unaryOperation(float x) {\n "+t+"\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n "},SQ="if (isnan(x)) return x;",TQ="return abs(x);";var CQ="return x;",EQ=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length),this.userCode="\n vec4 unaryOperation(vec4 x) {\n "+t+"\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n "},AQ=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length);var t=e.length,n=gQ("rc",t),r=PJ(t),a=function(e,t){if(1===e)return"rc";for(var n="",r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}(t,n),i=n.slice(-2),o=t<=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 "},RQ=OE,_Q={};var FQ=Fg().getNumber("CPU_HANDOFF_SIZE_THRESHOLD");var OQ=function(e){Cv(n,e);var t=n.prototype;function n(t){var n,r,a;if((n=e.call(this)||this).pendingRead=new WeakMap,n.pendingDisposal=new WeakSet,n.dataRefCount=new WeakMap,n.numBytesInGPU=0,n.uploadWaitMs=0,n.downloadWaitMs=0,n.lastGlFlushTime=0,n.warnedAboutMemory=!1,n.pendingDeletes=0,n.disposed=!1,!Fg().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null!=t){if(t instanceof wZ)r=t;else{var i=IY(Fg().getNumber("WEBGL_VERSION"),t);r=new wZ(i)}n.binaryCache={},n.gpgpuCreatedLocally=!1}else{var o=IY(Fg().getNumber("WEBGL_VERSION"));r=new wZ(o),n.binaryCache=((a=Fg().getNumber("WEBGL_VERSION"))in _Q||(_Q[a]={}),_Q[a]),n.gpgpuCreatedLocally=!0}return n.gpgpu=r,n.canvas=n.gpgpu.gl.canvas,n.textureManager=new xQ(n.gpgpu),n.numMBBeforeWarning=null==Fg().global.screen?1024:Fg().global.screen.height*Fg().global.screen.width*window.devicePixelRatio*600/1024/1024,n.texData=new zv(Ov(n),QN()),n}return t.nextDataId=function(){return n.nextDataId++},t.numDataIds=function(){return this.texData.numDataIds()-this.pendingDeletes},t.writeTexture=function(e,t,n,r,a,i){var o=this.makeTensorInfo(t,n),s=this.texData.get(o.dataId);s.isPacked=!1,s.texture={texture:e,texShape:[r,a]},s.texShape=[r,a];var u=oJ(t),l=new JJ(u,!1,i),c=this.runWebGLProgram(l,[o],n,[[r,a]]);return c.shape=t,s.texture=null,this.disposeIntermediateTensorInfo(o),c.dataId},t.write=function(e,t,n){if((Fg().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||Fg().getBool("DEBUG"))&&this.checkNumericalProblems(e),"complex64"===n&&null!=e)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var r={id:this.nextDataId()};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:bY.UPLOAD,refCount:1}),r},t.refCount=function(e){return this.texData.has(e)?this.texData.get(e).refCount:0},t.incRef=function(e){this.texData.get(e).refCount++},t.decRef=function(e){this.texData.has(e)&&this.texData.get(e).refCount--},t.move=function(e,t,n,r,a){if(Fg().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:bY.UPLOAD,refCount:a})},t.disposeIntermediateTensorInfo=function(e){this.disposeData(e.dataId)},t.readSync=function(e){var t=this.texData.get(e),n=t.values,r=t.dtype,a=t.complexTensorInfos,i=t.slice,o=t.shape,s=t.isPacked;if(null!=i){var u;u=s?new EQ(o,CQ):new IQ(o,CQ);var l=this.runWebGLProgram(u,[{dataId:e,shape:o,dtype:r}],r),c=this.readSync(l.dataId);return this.disposeIntermediateTensorInfo(l),c}if(null!=n)return this.convertAndCacheOnCPU(e);if("string"===r)return n;var p,h,d=null!=this.activeTimers;(d&&(p=Vw()),"complex64"===r)?h=G_(this.readSync(a.real.dataId),this.readSync(a.imag.dataId)):h=this.getValuesFromTexture(e);return d&&(this.downloadWaitMs+=Vw()-p),this.convertAndCacheOnCPU(e,h)},t.read=function(){var e=Iv(kv().mark((function e(t){var n,r,a,i,o,s,u,l,c,p,h,d,f,m,v,g,y,b,x,w,k,N,I;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.pendingRead.has(t)){e.next=3;break}return n=this.pendingRead.get(t),e.abrupt("return",new Promise((function(e){return n.push(e)})));case 3:if(r=this.texData.get(t),a=r.values,i=r.shape,o=r.slice,s=r.dtype,u=r.complexTensorInfos,l=r.isPacked,null==o){e.next=11;break}return c=l?new EQ(i,CQ):new IQ(i,CQ),p=this.runWebGLProgram(c,[{dataId:t,shape:i,dtype:s}],s),h=this.read(p.dataId),this.disposeIntermediateTensorInfo(p),e.abrupt("return",h);case 11:if(null==a){e.next=13;break}return e.abrupt("return",this.convertAndCacheOnCPU(t));case 13:if(!Fg().getBool("DEBUG")){e.next=16;break}if(Fg().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")||2!==Fg().getNumber("WEBGL_VERSION")){e.next=16;break}throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");case 16:if(d=null,"complex64"!==s&&Fg().get("WEBGL_BUFFER_SUPPORTED")&&(f=this.decode(t),v=this.texData.get(f.dataId),d=(m=this.gpgpu).createBufferFromTexture.apply(m,[v.texture.texture].concat(TY(i)))),this.pendingRead.set(t,[]),"complex64"===s){e.next=22;break}return e.next=22,this.gpgpu.createAndWaitForFence();case 22:if("complex64"!==s){e.next=31;break}return e.next=25,Promise.all([this.read(u.real.dataId),this.read(u.imag.dataId)]);case 25:y=e.sent,b=y[0],x=y[1],g=G_(b,x),e.next=32;break;case 31:null==d?g=this.getValuesFromTexture(t):(w=Xv(i),g=this.gpgpu.downloadFloat32MatrixFromBuffer(d,w));case 32:return null!=f&&this.disposeIntermediateTensorInfo(f),null!=d&&AY(k=this.gpgpu.gl,(function(){return k.deleteBuffer(d)})),N=this.convertAndCacheOnCPU(t,g),I=this.pendingRead.get(t),this.pendingRead.delete(t),I.forEach((function(e){return e(N)})),this.pendingDisposal.has(t)&&(this.pendingDisposal.delete(t),this.disposeData(t)&&QN().removeDataId(t,this),this.pendingDeletes--),e.abrupt("return",N);case 40:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.readToGPU=function(e,t){void 0===t&&(t={});var n=this.texData.get(e),r=n.values,a=n.shape,i=n.slice,o=n.dtype,s=n.isPacked,u=n.texture;if("complex64"===o)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=i){var l;l=s?new EQ(a,CQ):new IQ(a,CQ);var c=this.runWebGLProgram(l,[{dataId:e,shape:a,dtype:o}],o),p=this.readToGPU(c,t);return this.disposeIntermediateTensorInfo(c),p}if(null==u)throw null!=r?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");var h=this.decode(e,t.customTexShape),d=QN().makeTensorFromTensorInfo(h),f=this.texData.get(h.dataId);return Object.assign({tensorRef:d},f.texture)},t.bufferSync=function(e){var t=this.readSync(e.dataId);if("string"===e.dtype)try{var n=t.map((function(e){return jw(e)}));return KN(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return KN(e.shape,e.dtype,t)},t.checkNumericalProblems=function(e){if(null!=e)for(var t=0;t<e.length;t++){var n=e[t];if(!RY(n)){if(Fg().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.")}}},t.getValuesFromTexture=function(e){var t=this.texData.get(e),n=t.shape,r=t.dtype,a=t.isPacked,i=Xv(n);if(Fg().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var o,s=this.decode(e),u=this.texData.get(s.dataId),l=(o=this.gpgpu).downloadMatrixFromPackedTexture.apply(o,[u.texture.texture].concat(TY(n))).subarray(0,i);return this.disposeIntermediateTensorInfo(s),l}var c=Fg().getBool("WEBGL_PACK")&&!0===a,p=c?oJ(n):n,h=c?new XJ(p):new KJ(p),d=this.runWebGLProgram(h,[{shape:p,dtype:r,dataId:e}],"float32"),f=this.texData.get(d.dataId),m=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(f.texture.texture,f.texShape[0],f.texShape[1]).subarray(0,i);return this.disposeIntermediateTensorInfo(d),m},t.timerAvailable=function(){return Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0},t.time=function(e){var t=this,n=this.activeTimers,r=[],a=!1;null==this.programTimersStack?(this.programTimersStack=r,a=!0):this.activeTimers.push(r),this.activeTimers=r,e();var i=qw(this.activeTimers.map((function(e){return e.query}))).filter((function(e){return null!=e})),o=qw(this.activeTimers.map((function(e){return e.name}))).filter((function(e){return null!=e}));this.activeTimers=n,a&&(this.programTimersStack=null);var s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return Iv(kv().mark((function e(){var n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)){e.next=8;break}return e.next=3,Promise.all(i);case 3:n=e.sent,s.kernelMs=jv(n),s.getExtraProfileInfo=function(){return n.map((function(e,t){return{name:o[t],ms:e}})).map((function(e){return e.name+": "+e.ms})).join(", ")},e.next=9;break;case 8:s.kernelMs={error:"WebGL query timers are not supported in this environment."};case 9:return t.uploadWaitMs=0,t.downloadWaitMs=0,e.abrupt("return",s);case 12:case"end":return e.stop()}}),e)})))()},t.memory=function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}},t.startTimer=function(){return Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Vw(),endMs:null}},t.endTimer=function(e){return Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Vw(),e)},t.getQueryTime=function(){var e=Iv(kv().mark((function e(t){var n;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Fg().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)){e.next=2;break}return e.abrupt("return",this.gpgpu.waitForQueryAndGetTime(t));case 2:return n=t,e.abrupt("return",n.endMs-n.startMs);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.disposeData=function(e,t){if(void 0===t&&(t=!1),this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);var n=this.texData.get(e).complexTensorInfos;return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0},t.releaseGPUData=function(e){var t=this.texData.get(e),n=t.texture,r=t.dtype,a=t.texShape,i=t.usage,o=t.isPacked,s=t.slice,u=s&&s.origDataId||e,l=this.dataRefCount.get(u);l>1?this.dataRefCount.set(u,l-1):(this.dataRefCount.delete(u),null!=n&&(this.numBytesInGPU-=this.computeBytes(a,r),this.textureManager.releaseTexture(n,a,i,o)));var c=this.texData.get(e);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null},t.getTexture=function(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture},t.getDataInfo=function(e){return this.texData.get(e)},t.shouldExecuteOnCPU=function(e,t){var n=this;return void 0===t&&(t=FQ),Fg().getBool("WEBGL_CPU_FORWARD")&&e.every((function(e){return null==n.texData.get(e.dataId).texture&&Xv(e.shape)<t}))},t.getGPGPUContext=function(){return this.gpgpu},t.where=function(e){qx("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");var t=e.dataSync();return RQ(e.shape,t)},t.packedUnaryOp=function(e,t,n){var r=new EQ(e.shape,t),a=this.compileAndRun(r,[e],n);return QN().makeTensorFromTensorInfo(a)},t.abs=function(e){if(this.shouldExecuteOnCPU([e])&&"complex64"!==e.dtype){var t=eQ(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,t)}if(Fg().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,TQ,e.dtype);var n=new IQ(e.shape,TQ),r=this.compileAndRun(n,[e]);return QN().makeTensorFromTensorInfo(r)},t.makeTensorInfo=function(e,t,n){var r;if("string"===t&&null!=n&&n.length>0&&cg(n[0])){var a=n.map((function(e){return Gw(e)}));r=this.write(a,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}},t.makeOutput=function(e,t,n){return QN().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,n),this)},t.unpackTensor=function(e){var t=new AQ(e.shape);return this.runWebGLProgram(t,[e],e.dtype)},t.packTensor=function(e){var t=new yQ(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)},t.packedReshape=function(e,t){var n=[aJ(e.shape)].concat(iJ(e.shape)),r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[aJ(t)].concat(iJ(t)),i=new bQ(a,n),o=[n],s=this.runWebGLProgram(i,[r],e.dtype,o,!0);return{dataId:s.dataId,shape:t,dtype:s.dtype}},t.decode=function(e,t){var n=this.texData.get(e),r=n.isPacked,a=n.shape,i=n.dtype;null!=t&&Hv(Xv(a)<=t[0]*t[1]*4,(function(){return"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."}));var o,s=oJ(a);o=r?new qJ(s):new HJ(s);var u=[null!=t?t:TY(s)];return{dtype:i,shape:a,dataId:this.runWebGLProgram(o,[{shape:s,dtype:i,dataId:e}],i,u,!0,t).dataId}},t.runWebGLProgram=function(e,t,n,r,a,i){var o=this;void 0===a&&(a=!1);var s=this.makeTensorInfo(e.outputShape,n),u=this.texData.get(s.dataId);if(e.packedOutput&&(u.isPacked=!0),e.outPackingScheme===yY.DENSE){var l=null!=i?i:TY(e.outputShape);u.texShape=l.map((function(e){return 2*e}))}if(null!=e.outTexUsage&&(u.usage=e.outTexUsage),0===Xv(s.shape))return u.values=rg(s.dtype,0),s;var c=[],p=t.map((function(t){if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var n=o.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&Xv(t.shape)<=Fg().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}if(o.uploadToGPU(t.dataId),!!n.isPacked!=!!e.packedInputs)t=n.isPacked?o.unpackTensor(t):o.packTensor(t),c.push(t),n=o.texData.get(t.dataId);else if(n.isPacked&&!lJ(n.shape,t.shape)){var r=t,a=t.shape;t.shape=n.shape,t=o.packedReshape(t,a),c.push(t),n=o.texData.get(t.dataId),r.shape=a}return{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(s.dataId);var h,d={shape:s.shape,texData:u,isUniform:!1},f=function(e,t,n){var r="";t.concat(n).forEach((function(t){var a=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){var i=t.texData.texShape,o=BJ(e.packedInputs,t.shape,i),s=o.useSqueezeShape,u=o.uniformShape,l=o.keptDims,c="",p="",h="";if(1===u.length&&e.packedInputs){var d=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];c=(d[0]>1)+"_"+(d[1]>1)}else if(2!==u.length||e.packedInputs){if(u.length>2&&!e.packedInputs){var f=vg(u);h=(f[0]===i[1])+"_"+(f[f.length-1]===i[1])}}else p=(u[0]>1)+"_"+(u[1]>1);var m=t.shape.length,v=2===u.length&&Yv(t.shape,i),g=1===Xv(t.shape),y=IS(t.shape,n.shape),b=!e.packedInputs&&m===n.shape.length&&Yv(i,n.texData.texShape),x=e.packedInputs||u.length>2?"":(i[0]>1)+"_"+(i[1]>1);r+=m+"_"+b+"_"+(s?l:"")+"_"+u.length+"_"+g+"_"+y+"_"+v+"_"+c+"_"+p+"_"+h+"_"+x+"_"+a}else{var w=t.isUniform?"uniform":t.texData.texShape;r+=t.shape+"_"+w+"_"+a}}));var a=e.userCode,i=e.constructor.name;return i+"_"+r+"_"+a+Fg().getNumber("WEBGL_VERSION")}(e,p,d),m=this.getAndSaveBinary(f,(function(){return function(e,t,n,r){var a=n.map((function(e,n){var r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),i=a.map((function(e){return e.shapeInfo})),o={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},s=AJ(a,o,t),u=DY(e.gl,s),l=e.createProgram(u);return Fg().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:u,source:s,webGLProgram:l,inShapeInfos:i,outShapeInfo:o,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:t,fragmentShader:u,source:s,webGLProgram:l,inShapeInfos:i,outShapeInfo:o},UJ(e,t,l))}(o.gpgpu,e,p,d)})),v=null!=this.activeTimers;v&&(h=this.startTimer()),Fg().get("ENGINE_COMPILE_ONLY")||function(e,t,n,r,a){t.program.enableShapeUniforms||(GJ(t.inShapeInfos,n),GJ([t.outShapeInfo],[r]));var i=r.texData.texture,o=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(i.texture,o[0],o[1]):e.setOutputMatrixTexture(i.texture,o[0],o[1]),e.setProgram(t.webGLProgram),1===Fg().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN);for(var s=0;s<n.length;++s){var u=n[s],l=t.variablesLocations[s],c=l.uniform,p=l.offset,h=l.shape,d=l.texShape;if(h){var f=BJ(t.program.packedInputs,u.shape,u.texData.texShape).uniformShape;switch(f.length){case 1:e.gl.uniform1iv(h,new Int32Array(f));break;case 2:e.gl.uniform2iv(h,new Int32Array(f));break;case 3:e.gl.uniform3iv(h,new Int32Array(f));break;case 4:e.gl.uniform4iv(h,new Int32Array(f))}}if(d&&e.gl.uniform2i(d,u.texData.texShape[0],u.texData.texShape[1]),null!=c)if(u.isUniform)if(Xv(u.shape)<2)e.gl.uniform1f(c,u.uniformValues[0]);else{var m=u.uniformValues;m instanceof Float32Array||(m=new Float32Array(m)),e.gl.uniform1fv(c,m)}else null!=u.texData.slice&&null!=p&&e.gl.uniform1i(p,u.texData.slice.flatOffset),e.setInputMatrixTexture(u.texData.texture.texture,c,s)}var v=t.outShapeLocation;if(v)switch(r.shape.length){case 1:e.gl.uniform1iv(v,new Int32Array(r.shape));break;case 2:e.gl.uniform2iv(v,new Int32Array(r.shape));break;case 3:e.gl.uniform3iv(v,new Int32Array(r.shape));break;case 4:e.gl.uniform4iv(v,new Int32Array(r.shape))}if(t.outShapeStridesLocation){var g=vg(r.shape);switch(r.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(g));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(g));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(g))}}if(t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),t.program.customUniforms&&a)for(var y=0;y<t.program.customUniforms.length;++y){var b=t.program.customUniforms[y],x=t.customUniformLocations[y],w=a[y];if("float"===b.type)e.gl.uniform1fv(x,w);else if("vec2"===b.type)e.gl.uniform2fv(x,w);else if("vec3"===b.type)e.gl.uniform3fv(x,w);else if("vec4"===b.type)e.gl.uniform4fv(x,w);else if("int"===b.type)e.gl.uniform1iv(x,w);else if("ivec2"===b.type)e.gl.uniform2iv(x,w);else if("ivec3"===b.type)e.gl.uniform3iv(x,w);else{if("ivec4"!==b.type)throw Error("uniform type "+b.type+" is not supported yet.");e.gl.uniform4iv(x,w)}}e.executeProgram()}(this.gpgpu,m,p,d,r),c.forEach((function(e){return o.disposeIntermediateTensorInfo(e)})),v&&(h=this.endTimer(h),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(h)}));var g=Fg().get("WEBGL_FLUSH_THRESHOLD");if(g>0){var y=Vw();y-this.lastGlFlushTime>g&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=y)}if(!Fg().getBool("WEBGL_LAZILY_UNPACK")&&u.isPacked&&!1===a){var b=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),b}return s},t.compileAndRun=function(e,t,n,r,a){return void 0===a&&(a=!1),n=n||t[0].dtype,this.runWebGLProgram(e,t,n,r,a)},t.getAndSaveBinary=function(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]},t.getTextureManager=function(){return this.textureManager},t.dispose=function(){var e=this;if(!this.disposed){if(!Fg().getBool("IS_TEST"))Object.keys(this.binaryCache).forEach((function(t){e.gpgpu.deleteProgram(e.binaryCache[t].webGLProgram),delete e.binaryCache[t]}));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}},t.floatPrecision=function(){var e=this;return null==this.floatPrecisionValue&&(this.floatPrecisionValue=eI((function(){if(!Fg().get("WEBGL_RENDER_FLOAT32_ENABLED")){var t=Fg().getBool("DEBUG");Fg().set("DEBUG",!1);var n=e.abs(KS(1e-8)).dataSync()[0];if(Fg().set("DEBUG",t),n>0)return 32}return 16}))),this.floatPrecisionValue},t.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},t.uploadToGPU=function(e){var t=this.texData.get(e),n=t.shape,r=t.dtype,a=t.values,i=t.texture,o=t.usage,s=t.isPacked;if(null==i){var u,l=null!=this.activeTimers;l&&(u=Vw());var c=t.texShape;if(null==c&&(c=sJ(n,s),t.texShape=c),null!=a){var p,h=oJ(n),d=c[1],f=c[0],m=a instanceof Uint8Array||a instanceof Uint8ClampedArray;if(s||!m){var v=CY(c[0],c[1]);d=v[0],f=v[1]}p=s?new ZJ(h,m):new JJ(h,m);var g=m?[f,d]:c,y=this.makeTensorInfo(g,r),b=this.texData.get(y.dataId);b.usage=m?bY.PIXELS:bY.UPLOAD,b.texShape=g,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(y.dataId),d,f,a);var x=[[f,d]],w=this.runWebGLProgram(p,[y],r,x,!0),k=this.texData.get(w.dataId);t.texShape=k.texShape,t.isPacked=k.isPacked,t.usage=k.usage,Fg().get("ENGINE_COMPILE_ONLY")?this.disposeData(w.dataId):(t.texture=k.texture,t.values=null,this.texData.delete(w.dataId)),this.disposeIntermediateTensorInfo(y),l&&(this.uploadWaitMs+=Vw()-u)}else{var N=this.acquireTexture(c,o,r,s);t.texture=N}}},t.convertAndCacheOnCPU=function(e,t){var n=this.texData.get(e),r=n.dtype;return null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){for(var n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length),r=0;r<n.length;++r)n[r]=Math.round(e[r]);return n}throw new Error("Unknown dtype "+t)}(t,r)),n.values},t.acquireTexture=function(e,t,n,r){if(this.numBytesInGPU+=this.computeBytes(e,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(e,t,r)},t.computeBytes=function(e,t){return e[0]*e[1]*ug(t)},t.checkCompileCompletion=function(){for(var e=0,t=Object.entries(this.binaryCache);e<t.length;e++){var n=t[e][1];this.checkCompletion_(n)}},t.checkCompileCompletionAsync=function(){var e=Iv(kv().mark((function e(){var t,n,r,a,i,o,s,u,l=this;return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=[],!this.gpgpu.parallelCompilationExtension){e.next=6;break}for(n=0,r=Object.entries(this.binaryCache);n<r.length;n++)a=r[n],i=a[1],t.push(this.checkCompletionAsync_(i));return e.abrupt("return",Promise.all(t));case 6:for(o=function(){var e=u[s][1],n=new Promise((function(t){try{l.checkCompletion_(e),t(!0)}catch(e){throw e}}));t.push(n)},s=0,u=Object.entries(this.binaryCache);s<u.length;s++)o();return e.abrupt("return",Promise.all(t));case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.checkCompletionAsync_=function(){var e=Iv(kv().mark((function e(t){return kv().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.gpgpu.gl.getProgramParameter(t.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)){e.next=4;break}return e.abrupt("return",this.checkCompletion_(t));case 4:return e.next=6,w_();case 6:return e.abrupt("return",this.checkCompletionAsync_(t));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.checkCompletion_=function(e){if(!1===this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw PY(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0},t.getUniformLocations=function(){for(var e=0,t=Object.values(this.binaryCache);e<t.length;e++){var n=t[e],r=UJ(this.gpgpu,n.program,n.webGLProgram),a=r.variablesLocations,i=r.customUniformLocations,o=r.infLoc,s=r.nanLoc,u=r.outShapeLocation,l=r.outShapeStridesLocation,c=r.outTexShapeLocation;n.variablesLocations=a,n.customUniformLocations=i,n.infLoc=o,n.nanLoc=s,n.outShapeLocation=u,n.outShapeStridesLocation=l,n.outTexShapeLocation=c}},t.createTensorFromGPUData=function(e,t,n){e.channels=e.channels||"RGBA";var r=e.texture,a=e.height,i=e.width,o=e.channels,s=QN().backend;if(!s.gpgpu.gl.isTexture(r))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");var u=s.writeTexture(r,t,n,a,i,o);return QN().makeTensorFromDataId(u,t,n,s)},n}(Pv);OQ.nextDataId=0;var DQ="4.3.0";function MQ(){Fg().set("WEBGL_FORCE_F16_TEXTURES",!0)}_k()&&aI("webgl",(function(){return new OQ}),2);var LQ={forceHalfFloat:MQ},zQ=function(e,t,n){this.variableNames=["A","B"],this.outputShape=TS(t,n),this.enableShapeUniforms=jJ(this.outputShape.length),this.userCode="\n float binaryOperation(float a, float b) {\n "+e+"\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n "},PQ=function(e,t,n,r){void 0===r&&(r=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=TS(t,n);var a=this.outputShape.length;this.enableShapeUniforms=jJ(a);var i="";if(r)if(0===a||1===Xv(this.outputShape))i="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(i="\n "+PJ(a)+" coords = getOutputCoords();\n ",1===a)this.enableShapeUniforms?i+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":i+="\n result.y = (coords + 1) >= "+this.outputShape[0]+" ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ";else{var o=gQ("coords",a);this.enableShapeUniforms?i+="\n bool nextRowOutOfBounds =\n ("+o[a-2]+" + 1) >= outShape["+a+" - 2];\n bool nextColOutOfBounds =\n ("+o[a-1]+" + 1) >= outShape["+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 ":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 "+e+"\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 "};function BQ(e){var t=e.inputs,n=e.backend,r=t.x;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}var WQ={kernelName:Yy,backendName:"webgl",kernelFunc:BQ};function VQ(e){var t=e.inputs,n=e.backend,r=t.real,a=t.imag,i=n.makeTensorInfo(r.shape,"complex64"),o=n.texData.get(i.dataId),s=BQ({inputs:{x:r},backend:n}),u=BQ({inputs:{x:a},backend:n});return o.complexTensorInfos={real:s,imag:u},i}var UQ={kernelName:sy,backendName:"webgl",kernelFunc:VQ},GQ="return (a < 0.) ? b * a : a;",jQ="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";var HQ={kernelName:tb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.alpha,o=n.makeTensorInfo([],"float32",Bw(i,"float32")),s=Fg().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new PQ(jQ,a.shape,o.shape):new zQ(GQ,a.shape,o.shape),u=n.runWebGLProgram(s,[a,o],"float32");return n.disposeIntermediateTensorInfo(o),u}},qQ="return (a < 0.) ? b * a : a;",KQ="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";var XQ={kernelName:zb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=t.alpha,i=Fg().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new PQ(KQ,r.shape,a.shape):new zQ(qQ,r.shape,a.shape);return n.runWebGLProgram(i,[r,a],"float32")}};function YQ(e){var t=e.opSnippet,n=e.packedOpSnippet,r=e.cpuKernelImpl,a=e.dtype;return function(e){var i,o=e.inputs,s=e.backend,u=o.x,l=s,c=a||u.dtype;if(l.shouldExecuteOnCPU([u])&&null!=r){var p=l.texData.get(u.dataId),h=r(p.values,c);return l.makeTensorInfo(u.shape,c,h)}return i=Fg().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=n?new EQ(u.shape,n):new IQ(u.shape,t),l.runWebGLProgram(i,[u],c)}}function JQ(e){var t=e.opSnippet,n=e.packedOpSnippet,r=e.checkOutOfBounds,a=void 0!==r&&r,i=e.supportsComplex,o=void 0!==i&&i,s=e.cpuKernelImpl,u=e.dtype;return function(e){var r=e.inputs,i=e.backend,l=r.a,c=r.b,p=i;if(o&&"complex64"===l.dtype){var h=p.texData.get(l.dataId),d=p.texData.get(c.dataId),f=[[h.complexTensorInfos.real,d.complexTensorInfos.real],[h.complexTensorInfos.imag,d.complexTensorInfos.imag]].map((function(e){var n=e[0],r=e[1],a={dataId:n.dataId,dtype:n.dtype,shape:l.shape},i={dataId:r.dataId,dtype:r.dtype,shape:c.shape},o=new zQ(t,l.shape,c.shape);return p.runWebGLProgram(o,[a,i],dk(n.dtype,r.dtype))})),m=f[0],v=f[1],g=VQ({inputs:{real:m,imag:v},backend:p});return p.disposeIntermediateTensorInfo(m),p.disposeIntermediateTensorInfo(v),g}var y,b=u||dk(l.dtype,c.dtype);if(("string"===l.dtype||"string"===c.dtype||p.shouldExecuteOnCPU([l,c]))&&null!=s){var x=p.texData.get(l.dataId).values,w=p.texData.get(c.dataId).values,k="string"===l.dtype?wF(x):x,N="string"===l.dtype?wF(w):w,I=s(l.shape,c.shape,k,N,b),S=I[0],T=I[1],C=p.makeTensorInfo(T,b);return p.texData.get(C.dataId).values=S,C}return y=Fg().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=n?new PQ(n,l.shape,c.shape,a):new zQ(t,l.shape,c.shape),p.runWebGLProgram(y,[l,c],b)}}function ZQ(e,t){if(void 0===t&&(t=!1),"linear"===e)return"return x;";if("relu"===e)return t?"\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":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n";if("elu"===e)return t?"\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":"return (x >= 0.0) ? x : (exp(x) - 1.0);";if("relu6"===e)return t?"\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":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n";if("prelu"===e)return t?KQ:qQ;if("leakyrelu"===e)return t?jQ:GQ;if("sigmoid"===e)return"return 1.0 / (1.0 + exp(-1.0 * x));";throw new Error("Activation "+e+" has not been implemented for the WebGL backend.")}var QQ=function(e,t,n,r,a,i,o,s,u){void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=!1),void 0===o&&(o=null),void 0===s&&(s=!1),void 0===u&&(u=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=jJ(this.outputShape.length);var l=r?e[1]:e[2],c=Math.ceil(l/2),p=r?"i * 2, rc.y":"rc.y, i * 2",h=a?"rc.z, i * 2":"i * 2, rc.z",d=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",v="";o&&(m=s?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+o+"\n }":u?"vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n "+o+"\n }":"vec4 activation(vec4 x) {\n "+o+"\n }",v="result = activation(result);");var g=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");var y="rc.x",b="rc.x";e[0]<t[0]?y="imod(rc.x, "+e[0]+")":t[0]<e[0]&&(b="imod(rc.x, "+t[0]+")"),this.userCode="\n "+m+"\n // Don't use uniform for sharedDimensionPacked for performance.\n const float sharedDimension = "+c+".0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n int batchA = "+y+";\n int batchB = "+b+";\n for (int i = 0; i < "+c+"; i++) {\n vec4 a = getMatrixA(batchA, "+p+");\n vec4 b = getMatrixB(batchB, "+h+");\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += ("+d[0]+" * "+f[0]+");\n result += ("+d[1]+" * "+f[1]+");\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n "+g+"\n\n "+v+"\n\n setOutput(result);\n }\n "},$Q="return areal * breal - aimag * bimag;",e$="return areal * bimag + aimag * breal;",t$=function(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=TS(t,n),this.userCode="\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n "+e+"\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 "},n$="return a * b;";function r$(e){var t,n=e.inputs,r=e.backend,a=n.a,i=n.b,o=dk(a.dtype,i.dtype);if("complex64"===a.dtype){var s=r.texData.get(a.dataId),u=r.texData.get(i.dataId),l=new t$($Q,a.shape,i.shape),c=new t$(e$,a.shape,i.shape),p=[{dataId:s.complexTensorInfos.real.dataId,dtype:s.complexTensorInfos.real.dtype,shape:a.shape},{dataId:s.complexTensorInfos.imag.dataId,dtype:s.complexTensorInfos.imag.dtype,shape:a.shape},{dataId:u.complexTensorInfos.real.dataId,dtype:u.complexTensorInfos.real.dtype,shape:i.shape},{dataId:u.complexTensorInfos.imag.dataId,dtype:u.complexTensorInfos.imag.dtype,shape:i.shape}],h=r.runWebGLProgram(l,p,"float32"),d=r.runWebGLProgram(c,p,"float32"),f=VQ({inputs:{real:h,imag:d},backend:r});return r.disposeIntermediateTensorInfo(h),r.disposeIntermediateTensorInfo(d),f}if(r.shouldExecuteOnCPU([a,i])){var m=r.texData.get(a.dataId),v=r.texData.get(i.dataId),g=GZ(a.shape,i.shape,m.values,v.values,o),y=g[0],b=g[1],x=r.makeTensorInfo(b,o);return r.texData.get(x.dataId).values=y,x}return t=Fg().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new PQ(n$,a.shape,i.shape):new zQ(n$,a.shape,i.shape),r.runWebGLProgram(t,[a,i],o)}var a$={kernelName:Tb,backendName:"webgl",kernelFunc:r$};function i$(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.shape,o=n,s=Xv(a.shape),u=eg(i,s),l=Xv(u);Hv(s===l,(function(){return"The new shape ("+u+") has "+l+" elements and the old shape ("+a.shape+") has "+s+" elements. The new shape and old shape must have the same number of elements."}));var c=o.texData.get(a.dataId);return!c.isPacked||lJ(a.shape,u)||null!==c.texture&&lJ(c.shape,u)?(o.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype}):function(e,t,n){var r=[aJ(e.shape)].concat(iJ(e.shape)),a={dtype:e.dtype,shape:r,dataId:e.dataId},i=[aJ(t)].concat(iJ(t)),o=new bQ(i,r),s=[r],u=n.runWebGLProgram(o,[a],e.dtype,s,!0);return{dataId:u.dataId,shape:t,dtype:u.dtype}}(a,u,o)}var o$={kernelName:qb,backendName:"webgl",kernelFunc:i$},s$=function(e,t){this.variableNames=["x"];var n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.outSize;this.outputShape=[r,i];var o=4*Math.floor(n/4),s=n%4,u="sumValue += dot(values, ones);";if(null!=t){var l=1/t;u="sumValue += dot(values * "+(Jv(l)?l.toPrecision(2):l)+", ones);"}var c="";a%n>0&&(c="\n if (inIdx < 0 || inIdx >= "+a+") {\n return 0.0;\n }\n "),this.userCode="\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n "+c+"\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 float sumValue = 0.0;\n\n for (int i = 0; i < "+o+"; 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 "+u+"\n }\n\n int inIdx = inOffset + "+o+";\n if ("+(1===s)+") {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n "+u+"\n } else if ("+(2===s)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n "+u+"\n } else if ("+(3===s)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n "+u+"\n }\n setOutput(sumValue);\n }\n "},u$=function(e,t){this.variableNames=["x"];var n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.outSize;this.outputShape=[r,i];var o="0.0",s="";"prod"===t?o="1.0":"min"===t?(o="1.0 / 1e-20",s="min"):"max"===t&&(o="-1.0 / 1e-20",s="max");var u=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===t?u="sumValue":"prod"===t?u="prodValue":"all"===t?u="allValue":"any"===t&&(u="anyValue");var l=4*Math.floor(n/4),c=n%4,p="\n if ("+("sum"===t)+") {\n sumValue += dot(values, ones);\n } else if ("+("prod"===t)+") {\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 if ("+("min"===t)+" || "+("max"===t)+") {\n minMaxValue = "+s+"(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n ",h="vec4";"all"===t?(o="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",h="bvec4"):"any"===t&&(o="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",h="bvec4");var d="";a%n>0&&(d="\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 "+d+"\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 < "+l+"; i += 4) {\n int inIdx = inOffset + i;\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n "+p+"\n }\n\n int inIdx = inOffset + "+l+";\n if ("+(1===c)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+p+"\n } else if ("+(2===c)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n "+p+"\n } else if ("+(3===c)+") {\n "+h+" values = "+h+"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n "+p+"\n }\n setOutput("+u+");\n }\n "};function l$(e,t,n,r){for(var a=function(e){for(var t=[];0===t.length||1!==t[t.length-1].outSize;){var n=t.length?t[t.length-1].outSize:e[1],r=E_(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape),i=e,o=0;o<a.length;o++){var s,u=a[o],l=u.inSize,c=u.windowSize,p=u.outSize,h=void 0;h="mean"===n?0===o?new s$({windowSize:c,inSize:l,batchSize:e.shape[0],outSize:p},l):new s$({windowSize:c,inSize:l,batchSize:e.shape[0],outSize:p}):new u$({windowSize:c,inSize:l,batchSize:e.shape[0],outSize:p},n),s=i,i=r.runWebGLProgram(h,[i],t),s.dataId!==e.dataId&&r.disposeIntermediateTensorInfo(s)}return i}var c$=function(e,t){this.variableNames=["A"];for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[t[r]];this.outputShape=n,this.rank=n.length;var a=PJ(this.rank),i=function(e){var t=e.length;if(t>6)throw Error("Transpose for rank "+t+" is not yet supported");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t),a=0;a<e.length;a++)r[e[a]]=n[a];return r.join()}(t);this.userCode="\n void main() {\n "+a+" resRC = getOutputCoords();\n setOutput(getA("+i+"));\n }\n "};var p$=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[t[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=PJ(this.rank),i=vQ("rc",this.rank),o=new Array(this.rank),s=0;s<t.length;s++)o[t[s]]=i[s];var u="vec2("+o.slice(-2).join()+")",l="++"+i[this.rank-1]+" < "+n[this.rank-1],c="getChannel(getA("+o.join()+"), "+u+")";this.userCode="\n void main() {\n "+a+" rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = "+c+";\n if("+l+") {\n result[1] = "+c+";\n }\n --"+i[this.rank-1]+";\n if(++"+i[this.rank-2]+" < "+n[this.rank-2]+") {\n result[2] = "+c+";\n if("+l+") {\n result[3] = "+c+";\n }\n }\n setOutput(result);\n }\n "};function h$(e,t,n){var r=Fg().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new p$(e.shape,t):new c$(e.shape,t);return n.runWebGLProgram(r,[e],e.dtype)}function d$(e){var t=e.inputs,n=e.backend,r=e.attrs;return function(e,t,n,r){var a=t,i=e.shape.length,o=tg(a,e.shape),s=o,u=VS(s,i),l=null!=u,c=e;l&&(c=h$(e,u,r),s=GS(s.length,i)),WS("sum",s,i);var p=PS(c.shape,s),h=p[0],d=p[1],f=h;n&&(f=BS(h,o));var m=Xv(d),v=i$({inputs:{x:c},attrs:{shape:[Xv(e.shape)/m,m]},backend:r}),g=l$(v,fk(e.dtype),"sum",r),y=i$({inputs:{x:g},attrs:{shape:f},backend:r});return r.disposeIntermediateTensorInfo(v),r.disposeIntermediateTensorInfo(g),l&&r.disposeIntermediateTensorInfo(c),y}(t.x,r.axis,r.keepDims,n)}var f$={kernelName:dx,backendName:"webgl",kernelFunc:d$};function m$(e){for(var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.perm,s=r,u=i.shape.length,l=new Array(u),c=0;c<l.length;c++)l[c]=i.shape[o[c]];if(s.shouldExecuteOnCPU([i])){var p=s.texData.get(i.dataId).values,h=fQ(p,i.shape,i.dtype,o,l);t=s.makeTensorInfo(l,i.dtype),s.texData.get(t.dataId).values=h}else t=h$(i,o,s);return t}var v$={kernelName:Mx,backendName:"webgl",kernelFunc:m$};function g$(e){var t=e.a,n=e.b,r=e.transposeA,a=e.transposeB,i=e.backend,o=e.bias,s=void 0===o?null:o,u=e.preluActivationWeights,l=void 0===u?null:u,c=e.leakyreluAlpha,p=void 0===c?0:c,h=e.activation,d=void 0===h?null:h,f=t.shape.length,m=n.shape.length,v=r?t.shape[f-2]:t.shape[f-1],g=a?n.shape[m-1]:n.shape[m-2],y=r?t.shape[f-1]:t.shape[f-2],b=a?n.shape[m-2]:n.shape[m-1],x=t.shape.slice(0,-2),w=n.shape.slice(0,-2),k=Xv(x),N=Xv(w),I=TS(t.shape.slice(0,-2),n.shape.slice(0,-2)).concat([y,b]);Hv(v===g,(function(){return"Error in matMul: inner shapes ("+v+") and ("+g+") of Tensors with shapes "+t.shape+" and "+n.shape+" and transposeA="+r+" and transposeB="+a+" must match."}));var S,T=r?[k,v,y]:[k,y,v],C=a?[N,b,g]:[N,g,b],E=i$({inputs:{x:t},backend:i,attrs:{shape:T}}),A=i$({inputs:{x:n},backend:i,attrs:{shape:C}}),R=[E,A],_=Math.max(k,N),F=r?E.shape[1]:E.shape[2],O=null!=s,D=null!=l,M="leakyrelu"===d,L=null!=d?ZQ(d,!0):null;if((1===y||1===b)&&F>1e3&&!1===(O||D||M||null!=L)){var z=E,P=A;r&&(z=m$({inputs:{x:E},backend:i,attrs:{perm:[0,2,1]}}),R.push(z)),a&&(P=m$({inputs:{x:A},backend:i,attrs:{perm:[0,2,1]}}),R.push(P));var B=1===b,W=z;1!==b&&(W=i$({inputs:{x:z},backend:i,attrs:{shape:[_,F,1]}}),R.push(W));var V=1===b?2:1,U=P;B&&(U=i$({inputs:{x:P},backend:i,attrs:{shape:[_,1,F]}}),R.push(U));var G=r$({inputs:{a:W,b:U},backend:i});S=d$({inputs:{x:G},backend:i,attrs:{axis:V,keepDims:!0}}),R.push(G)}else{var j=dk(t.dtype,n.dtype),H=new QQ(T,C,[_,y,b],r,a,O,L,D,M),q=[E,A];if(null!=s&&q.push(s),D&&q.push(l),M){var K=i.makeTensorInfo([],"float32",Bw(p,"float32"));q.push(K),R.push(K)}S=i.runWebGLProgram(H,q,j)}var X=i$({inputs:{x:S},backend:i,attrs:{shape:I}});R.push(S);for(var Y=0,J=R;Y<J.length;Y++){var Z=J[Y];i.disposeIntermediateTensorInfo(Z)}return X}var y$={kernelName:Gx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.a,i=t.b,o=t.bias,s=t.preluActivationWeights,u=r.transposeA,l=r.transposeB,c=r.activation;return g$({a:a,b:i,transposeA:u,transposeB:l,backend:n,bias:o,preluActivationWeights:s,leakyreluAlpha:r.leakyreluAlpha,activation:c})}},b$="return abs(x);";var x$={kernelName:Mg,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=n.x;if(r.shouldExecuteOnCPU([a])&&"complex64"!==a.dtype){var i=r.texData.get(a.dataId),o=eQ(i.values);return r.makeTensorInfo(a.shape,a.dtype,o)}return t=Fg().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new EQ(a.shape,b$):new IQ(a.shape,b$),r.runWebGLProgram(t,[a],a.dtype)}},w$=YQ({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n"}),k$={kernelName:Lg,backendName:"webgl",kernelFunc:w$},N$=YQ({opSnippet:"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),I$={kernelName:zg,backendName:"webgl",kernelFunc:N$},S$="return a + b;",T$=JQ({opSnippet:S$,packedOpSnippet:S$,supportsComplex:!0,cpuKernelImpl:kZ}),C$={kernelName:Pg,backendName:"webgl",kernelFunc:T$},E$=function(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((function(e,t){return"T"+t}));var n=[];this.variableNames.forEach((function(e){n.push("float v"+e+" = get"+e+"AtOutCoords();")}));var r=this.variableNames.map((function(e){return"v"+e})).join(" + ");this.userCode="\n void main() {\n "+n.join("\n ")+"\n\n float result = "+r+";\n setOutput(result);\n }\n "},A$=function(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((function(e,t){return"T"+t}));var n=[];this.variableNames.forEach((function(e){n.push("vec4 v"+e+" = get"+e+"AtOutCoords();")}));var r=this.variableNames.map((function(e){return"v"+e})).join(" + ");this.userCode="\n void main() {\n "+n.join("\n ")+"\n\n vec4 result = "+r+";\n setOutput(result);\n }\n "};var R$={kernelName:Bg,backendName:"webgl",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=n;if(1===a.length)return BQ({inputs:{x:a[0]},backend:r});if(a.length>Fg().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var i=Math.floor(a.length/2),o=e({inputs:a.slice(0,i),backend:r}),s=e({inputs:a.slice(i),backend:r});return e({inputs:[o,s],backend:r})}var u=a.map((function(e){return e.dtype})).reduce((function(e,t){return dk(e,t)})),l=a.map((function(e){return e.shape})),c=Fg().getBool("WEBGL_PACK")?new A$(a[0].shape,l):new E$(a[0].shape,l);return r.runWebGLProgram(c,a,u)}};var _$={kernelName:Wg,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims,s=a.shape.length,u=tg(i,a.shape),l=u,c=VS(l,s),p=a;null!=c&&(p=m$({inputs:{x:a},backend:n,attrs:{perm:c}}),l=GS(l.length,s)),WS("all",l,s);var h,d=PS(p.shape,l),f=d[0],m=i$({inputs:{x:p},backend:n,attrs:{shape:[-1,Xv(d[1])]}}),v=l$(m,m.dtype,"all",n);return h=i$(o?{inputs:{x:v},backend:n,attrs:{shape:BS(f,u)}}:{inputs:{x:v},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),null!=c&&n.disposeIntermediateTensorInfo(p),h}};var F$={kernelName:Vg,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims,s=a.shape.length,u=tg(i,a.shape),l=u,c=VS(l,s),p=a;null!=c&&(p=m$({inputs:{x:a},backend:n,attrs:{perm:c}}),l=GS(l.length,s)),WS("any",l,s);var h,d=PS(p.shape,l),f=d[0],m=i$({inputs:{x:p},backend:n,attrs:{shape:[-1,Xv(d[1])]}}),v=l$(m,m.dtype,"any",n);return h=i$(o?{inputs:{x:v},backend:n,attrs:{shape:BS(f,u)}}:{inputs:{x:v},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),null!=c&&n.disposeIntermediateTensorInfo(p),h}},O$=function(e,t,n){this.variableNames=["A"];var r=e.windowSize,a=e.batchSize,i=e.outSize;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,i];var o="max"===t?">":"<",s=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 = "+s+";\n float candidate = getA(batch, inIdx);\n if (candidate "+o+" bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n "},D$=function(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,Hv(e.length>2,(function(){return"Packed arg"+(n.charAt(0).toUpperCase()+n.slice(1))+" supports only inputs with rank above 2."}));var a=e[e.length-1],i=Math.ceil(a/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");var o,s,u=this.outputShape,l=u.length,c=PJ(l),p=gQ("coords",l);if(1===i){var h=PJ(s=l+1);o="\n "+h+" sourceLocR = "+h+"("+p.join()+", 0);\n ++"+p[l-1]+";\n "+h+" sourceLocG = "+h+"("+p.join()+", 0);\n ++"+p[l-2]+";\n "+h+" sourceLocA = "+h+"("+p.join()+", 0);\n --"+p[l-1]+";\n "+h+" sourceLocB = "+h+"("+p.join()+", 0);\n --"+p[l-2]+";"}else s=l,o="\n "+c+" sourceLocR = coords;\n ++"+p[l-1]+";\n "+c+" sourceLocG = coords;\n ++"+p[l-2]+";\n "+c+" sourceLocA = coords;\n --"+p[l-1]+";\n "+c+" sourceLocB = coords;\n --"+p[l-2]+";";var d=["x","y","z","w","u","v"].slice(0,s),f="."+d[s-1],m=d.map((function(e){return"int "+e})),v=gQ("sourceLocR",s-1).concat("inIdx.r"),g=gQ("sourceLocG",s-1).concat("inIdx.g"),y=gQ("sourceLocB",s-1).concat("inIdx.b"),b=gQ("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.)",N=r?"":"\n float getBestIndicesAChannel("+m.join()+") {\n return getChannel(getBestIndicesA("+d.join()+"),\n vec2("+d.slice(-2).join()+"));\n }";this.userCode="\n float getAChannel("+m.join()+") {\n return getChannel(getA("+d.join()+"),\n vec2("+d.slice(-2).join()+"));\n }\n "+N+"\n void main() {\n "+c+" coords = getOutputCoords();\n bool hasNextCol = "+p[l-1]+" < "+(u[l-1]-1)+";\n bool hasNextRow = "+p[l-2]+" < "+(u[l-2]-1)+";\n "+o+"\n ivec4 srcIdx = ivec4(sourceLocR"+f+", sourceLocG"+f+",\n sourceLocB"+f+", sourceLocA"+f+") * "+t+";\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = "+k+";\n\n for (int i = 0; i < "+t+"; 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 "};function M$(e,t,n,r){void 0===r&&(r=null);var a=t.shape[0],i=t.shape[1];null!=r&&(a=r.shape[0],i=r.shape[1]);var o=E_(i),s={windowSize:o,inSize:i,batchSize:a,outSize:Math.ceil(i/o)},u=new O$(s,n,null==r),l=[t];null!=r&&l.push(r);var c=e.runWebGLProgram(u,l,"int32");if(1===c.shape[1])return c;var p=M$(e,t,n,c);return e.disposeIntermediateTensorInfo(c),p}function L$(e,t,n,r){void 0===r&&(r=null);var a=null!=r?r.shape:t.shape,i=E_(a[a.length-1]),o=new D$(a,i,n,null==r),s=null==r?[t]:[t,r],u=e.runWebGLProgram(o,s,"int32");if(u.shape.length===t.shape.length){var l=L$(e,t,n,u);return e.disposeIntermediateTensorInfo(u),l}return u}function z$(e,t,n,r){var a=[n];if(WS("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Fg().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){var i=[],o=e.texData.get(t.dataId),s=t;null!==o&&o.isPacked&&(s=e.unpackTensor(t),i.push(s));var u=PS(s.shape,a),l=u[0],c=Xv(u[1]),p=i$({inputs:{x:s},backend:e,attrs:{shape:[-1,c]}});i.push(p);var h=M$(e,p,r);i.push(h);var d=i$({inputs:{x:h},backend:e,attrs:{shape:l}});return i.forEach((function(t){return e.disposeIntermediateTensorInfo(t)})),d}return L$(e,t,r)}var P$={kernelName:Ug,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=tg(r.axis,a.shape),o=VS(i,a.shape.length),s=a,u=[];null!=o&&(s=m$({inputs:{x:a},backend:n,attrs:{perm:o}}),u.push(s),i=GS(i.length,s.shape.length)),WS("argMax",[i[0]],s.shape.length);var l=z$(n,s,i[0],"max");return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),l}};var B$={kernelName:Gg,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=tg(r.axis,a.shape),o=VS(i,a.shape.length),s=a,u=[];null!=o&&(s=m$({inputs:{x:a},backend:n,attrs:{perm:o}}),u.push(s),i=GS(i.length,s.shape.length)),WS("argMin",[i[0]],s.shape.length);var l=z$(n,s,i[0],"min");return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),l}},W$=YQ({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),V$={kernelName:jg,backendName:"webgl",kernelFunc:W$},U$=YQ({opSnippet:"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));"}),G$={kernelName:Hg,backendName:"webgl",kernelFunc:U$},j$=YQ({opSnippet:"if (isnan(x)) return x;\n return atan(x);\n"}),H$={kernelName:qg,backendName:"webgl",kernelFunc:j$},q$=JQ({opSnippet:"\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return atan(a, b);\n",packedOpSnippet:"\n vec4 result = atan(a, b);\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n \n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n\n return result;\n"}),K$={kernelName:Xg,backendName:"webgl",kernelFunc:q$},X$=YQ({opSnippet:"if (isnan(x)) return x;\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"}),Y$={kernelName:Kg,backendName:"webgl",kernelFunc:X$},J$=function(e,t,n,r,a){if(void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");var i=e.filterWidth,o=e.strideHeight,s=e.strideWidth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterHeight,p=e.effectiveFilterWidth,h=e.padInfo.top,d=e.padInfo.left;this.outputShape=e.outShape;var f="avg"===t,m="((batch * "+e.inHeight+" + xR) * "+e.inWidth+" + xC) * "+e.inChannels+" + d",v="(xR * "+e.inWidth+" + xC) * "+e.inChannels+" + d",g="0.0";if(f||(g="-1.0 / 1e-20"),n){this.userCode="\n const ivec2 strides = ivec2("+o+", "+s+");\n const ivec2 pads = ivec2("+h+", "+d+");\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 < "+c+";\n wR += "+u+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+p+";\n wC += "+l+") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+e.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 * "+p+" + wC")+";\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n "}else{var y=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===t&&(y="avgValue / max(count, 1.0)");var b=4*Math.floor(i/4),x=i%4,w="\n if ("+f+") {\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("+h+", "+d+");\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 >= "+e.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 < "+c+";\n wR += "+u+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+b+"; wC += 4) {\n int xC = xCCorner + wC * "+l+";\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + "+l+", d),\n getValue(batch, xR, xC + 2 * "+l+", d),\n getValue(batch, xR, xC + 3 * "+l+", 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 + "+l+", 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 + "+l+", d),\n getValue(batch, xR, xC + 2 * "+l+", d),\n initializationValue\n );\n\n "+w+"\n }\n }\n setOutput("+y+");\n }\n "}},Z$=function(e,t,n,r,a){if(void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");var i=e.filterWidth,o=e.strideDepth,s=e.strideHeight,u=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,p=e.dilationWidth,h=e.effectiveFilterDepth,d=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,v=e.padInfo.top,g=e.padInfo.left;this.outputShape=e.outShape;var y="avg"===t,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 < "+h+";\n wD += "+l+") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= "+e.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+d+";\n wR += "+c+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+f+";\n wC += "+p+") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+e.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 * "+e.inDepth+" + xD) * "+e.inHeight+" + xR) * "+e.inWidth+" + xC) * "+e.inChannels+" + ch":"((xD * "+e.inHeight+" + xR) * "+e.inWidth+" + xC) * "+e.inChannels+" + ch":"wD * "+d+" * "+f+" +\n wR * "+f+" + wC")+";\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n "}else{var x=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===t&&(x="avgValue / max(count, 1.0)");var w=4*Math.floor(i/4),k=i%4,N="\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 >= "+e.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 < "+h+";\n wD += "+l+") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= "+e.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+d+";\n wR += "+c+") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+w+"; wC += 4) {\n int xC = xCCorner + wC * "+p+";\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+p+", ch),\n getValue(batch, xD, xR, xC + 2 * "+p+", ch),\n getValue(batch, xD, xR, xC + 3 * "+p+", ch)\n );\n\n "+N+"\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 "+N+"\n } else if ("+(2===k)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+p+", ch),\n initializationValue,\n initializationValue\n );\n\n "+N+"\n } else if ("+(3===k)+") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + "+p+", ch),\n getValue(batch, xD, xR, xC + 2 * "+p+", ch),\n initializationValue\n );\n\n "+N+"\n }\n }\n }\n setOutput("+x+");\n }\n "}};var Q$={kernelName:Yg,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;bJ(a,"avgPool");var i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode;Hv(DI(o,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '1'"}));var l=II(a.shape,i,o,1,s,u);if(1===l.filterWidth&&1===l.filterHeight&&Yv(l.inShape,l.outShape))return BQ({inputs:{x:a},backend:n});var c=new J$(l,"avg",!1);return n.runWebGLProgram(c,[a],"float32")}};var $$={kernelName:Zg,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode,l=r.dataFormat,c=SI(a.shape,i,o,[1,1,1],s,u,l),p=new Z$(c,"avg",!1);return n.runWebGLProgram(p,[a],"float32")}},e0=function(e){this.variableNames=["dy"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=e.dilationHeight,o=e.dilationWidth,s=e.effectiveFilterHeight,u=e.effectiveFilterWidth,l=s-1-e.padInfo.top,c=u-1-e.padInfo.left,p=1/(t*n);this.userCode="\n const ivec2 pads = ivec2("+l+", "+c+");\n const float avgMultiplier = float("+p+");\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 >= "+e.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 >= "+e.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 "},t0=function(e){this.variableNames=["dy"],this.outputShape=e.inShape;var t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,o=e.strideWidth,s=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,p=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=c-1-e.padInfo.front,f=p-1-e.padInfo.top,m=h-1-e.padInfo.left,v=1/(t*n*r);this.userCode="\n const ivec3 pads = ivec3("+d+", "+f+", "+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 < "+c+";\n wD += "+s+") {\n float dyD = float(dyDCorner + wD) / "+a+".0;\n\n if (dyD < 0.0 || dyD >= "+e.outDepth+".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < "+p+";\n wR += "+u+") {\n float dyR = float(dyRCorner + wR) / "+i+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+h+";\n wC += "+l+") {\n float dyC = float(dyCCorner + wC) / "+o+".0;\n\n if (dyC < 0.0 || dyC >= "+e.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 "};var n0={kernelName:Qg,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=r.filterSize,s=r.strides,u=r.pad,l=r.dimRoundingMode,c=SI(i.shape,o,s,[1,1,1],u,l),p=new t0(c);return n.runWebGLProgram(p,[a],i.dtype)}};var r0={kernelName:Jg,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=i;bJ([a,i],"avgPoolGrad");var s=r.filterSize,u=r.strides,l=r.pad,c=II(o.shape,s,u,1,l),p=new e0(c);return n.runWebGLProgram(p,[a],o.dtype)}};var a0={kernelName:$g,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs;return g$({a:t.a,b:t.b,transposeA:r.transposeA,transposeB:r.transposeB,backend:n})}},i0=function(e,t,n,r,a,i){this.outputShape=[],this.variableNames=["x","mean","variance"],TS(e,t),TS(e,n);var o="0.0";null!=r&&(TS(e,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");var s="1.0";null!=a&&(TS(e,a),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,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 "},o0=function(e,t,n,r,a,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],TS(e,t),TS(e,n);var o="vec4(0.0)";null!=r&&(TS(e,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");var s="vec4(1.0)";null!=a&&(TS(e,a),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,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 "},s0={kernelName:jy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.mean,o=t.variance,s=t.offset,u=t.scale;Hv(i.shape.length===o.shape.length,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),Hv(null==s||i.shape.length===s.shape.length,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),Hv(null==u||i.shape.length===u.shape.length,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}));var l=r.varianceEpsilon;null==l&&(l=.001);var c=[a,i,o],p=null;null!=s&&(p=s.shape,c.push(s));var h=null;null!=u&&(h=u.shape,c.push(u));var d=Fg().getBool("WEBGL_PACK_NORMALIZATION")?new o0(a.shape,i.shape,o.shape,p,h,l):new i0(a.shape,i.shape,o.shape,p,h,l);return n.runWebGLProgram(d,c,c[0].dtype)}},u0=function(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;var t=PJ(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];var n,r=function(e){if(1===e)return"sourceLoc";if(e<=6)return l0.slice(0,e).map((function(e){return"sourceLoc."+e})).join(",");throw Error("Slicing for rank "+e+" is not yet supported")}(this.rank);n="\n "+t+" sourceLoc;\n "+t+" coords = getOutputCoords();\n "+e.map((function(e,t){return"sourceLoc."+l0[t]+" = start["+t+"] + coords."+l0[t]+";"})).join("\n")+"\n ",this.userCode="\n void main() {\n "+n+"\n setOutput(getSource("+r+"));\n }\n "},l0=["x","y","z","w","u","v"];var c0=function(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];var t=PJ(this.rank),n=gQ("coords",this.rank),r=gQ("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]+" < "+e[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]+" < "+e[this.rank-2]+") {\n ++"+r[this.rank-2]+";\n result.z = "+i+";\n if (++"+n[this.rank-1]+" < "+e[this.rank-1]+") {\n ++"+r[this.rank-1]+";\n result.w = "+i+";\n }\n }\n ",u=this.rank<=4?"sourceLoc = coords +\n "+t+"("+e.map((function(e,t){return"start["+t+"]"})).join()+");":e.map((function(e,t){return r[t]+" = "+n[t]+" + start["+t+"];"})).join("\n");this.userCode="\n void main() {\n "+t+" coords = getOutputCoords();\n "+t+" sourceLoc;\n "+u+"\n vec4 result = vec4(0.);\n "+o+"\n "+s+"\n setOutput(result);\n }\n "};function p0(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=h_(a,r.begin,r.size),o=i[0],s=i[1];if(e_(a,o,s),0===Xv(s))return n.makeTensorInfo(s,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){var u=n.texData.get(a.dataId),l=tQ(u.values,o,s,a.shape,a.dtype);return n.makeTensorInfo(s,a.dtype,l)}var c=n.texData.get(a.dataId).isPacked,p=c_(a.shape,o,s);if(c||!p){var h=Fg().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new c0(s):new u0(s),d=[o];return n.runWebGLProgram(h,[a],a.dtype,d)}return n.uploadToGPU(a.dataId),function(e,t,n,r){var a=r.texData.get(e.dataId),i=r.makeTensorInfo(n,e.dtype),o=r.texData.get(i.dataId);Object.assign(o,a),o.refCount=1,o.shape=n,o.dtype=e.dtype;var s=p_(t,vg(e.shape));a.slice&&(s+=a.slice.flatOffset),o.slice={flatOffset:s,origDataId:a.slice&&a.slice.origDataId||e.dataId};var u=r.dataRefCount.get(o.slice.origDataId)||1;return r.dataRefCount.set(o.slice.origDataId,u+1),i}(a,o,s,n)}var h0={kernelName:ox,backendName:"webgl",kernelFunc:p0},d0={kernelName:ey,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockShape,o=r.crops;Hv(a.shape.length<=4,(function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"}));var s=i.reduce((function(e,t){return e*t})),u=R_(a.shape,i,s),l=__(u.length,i.length),c=F_(a.shape,i,s),p=O_(o,i.length),h=D_(c,o,i.length),d=[],f=i$({inputs:{x:a},backend:n,attrs:{shape:u}}),m=m$({inputs:{x:f},backend:n,attrs:{perm:l}}),v=i$({inputs:{x:m},backend:n,attrs:{shape:c}}),g=p0({inputs:{x:v},backend:n,attrs:{begin:p,size:h}});return d.push(f),d.push(m),d.push(v),d.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),g}};var f0={kernelName:ty,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.weights,o=r.size,s=n.readSync(a.dataId),u=n.readSync(i.dataId),l=NZ(s,u,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,l)}};var m0={kernelName:ry,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.s0,a=t.s1,i=n.readSync(r.dataId),o=n.readSync(a.dataId),s=TS(Array.from(i),Array.from(o));return n.makeTensorInfo([s.length],"int32",Int32Array.from(s))}},v0=JQ({opSnippet:"return float(a != b);",cpuKernelImpl:HZ,dtype:"bool"}),g0={kernelName:Eb,backendName:"webgl",kernelFunc:v0};function y0(e){var t=e.inputs,n=e.backend,r=t.input;return BQ({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}var b0={kernelName:Gb,backendName:"webgl",kernelFunc:y0};var x0={kernelName:ay,backendName:"webgl",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=t.attrs,i=n.x,o=a.dtype;if("complex64"===o){if("complex64"===i.dtype)return BQ({inputs:{x:i},backend:r});var s=VT(i.shape),u=e({inputs:{x:i},backend:r,attrs:{dtype:"float32"}}),l=VQ({inputs:{real:u,imag:s},backend:r});return s.dispose(),r.disposeIntermediateTensorInfo(u),l}if("complex64"===i.dtype){var c=y0({inputs:{input:i},backend:r}),p=e({inputs:{x:c},backend:r,attrs:{dtype:o}});return r.disposeIntermediateTensorInfo(c),p}if(!sg(i.dtype,o)){var h=BQ({inputs:{x:i},backend:r});return{dataId:h.dataId,shape:h.shape,dtype:o}}if(r.shouldExecuteOnCPU([i])){var d=r.texData.get(i.dataId).values,f=SZ(d,i.shape,i.dtype,o),m=f[0],v=f[1],g=f[2];return r.makeTensorInfo(m,v,g)}if("int32"===o)return function(e,t){var n=new IQ(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(i,r);if("bool"===o){var y=r.makeTensorInfo([],"bool",rg("bool",1)),b=v0({inputs:{a:i,b:y},backend:r});return r.disposeIntermediateTensorInfo(y),b}throw new Error("Error in Cast: failed to cast "+i.dtype+" to "+o)}},w0="return ceil(x);",k0=YQ({opSnippet:w0,packedOpSnippet:w0,cpuKernelImpl:TZ}),N0={kernelName:iy,backendName:"webgl",kernelFunc:k0},I0=function(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\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 "},S0=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\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 "};var T0={kernelName:oy,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.clipValueMin,s=a.clipValueMax;t=Fg().getBool("WEBGL_PACK_CLIP")?new S0(i.shape):new I0(i.shape);var u=[[o],[s]];return r.runWebGLProgram(t,[i],i.dtype,u)}},C0=function(e){this.variableNames=["real","imag"],this.outputShape=e,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 "};function E0(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}var A0={kernelName:uy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=n.texData.get(r.dataId),i=new C0(r.shape),o=[E0(r,a.complexTensorInfos.real),E0(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(i,o,o[0].dtype)}},R0=function(e){this.outputShape=[],this.outputShape=N_(e,1),this.variableNames=e.map((function(e,t){return"T"+t}));var t=new Array(e.length-1);t[0]=e[0][1];for(var n=1;n<t.length;n++)t[n]=t[n-1]+e[n][1];for(var r=["if (yC < "+t[0]+") setOutput(getT0(yR, yC));"],a=1;a<t.length;a++){var i=t[a-1];r.push("else if (yC < "+t[a]+") setOutput(getT"+a+"(yR, yC-"+i+"));")}var o=t.length,s=t[t.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 "},_0=function(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=N_(e,t);var n=this.outputShape,r=n.length,a=PJ(r),i=gQ("coords",r),o=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map((function(e,t){return"T"+t}));var s=new Array(e.length-1);s[0]=e[0][t];for(var u=1;u<s.length;u++)s[u]=s[u-1]+e[u][t];for(var l=o[t],c=o.slice(-2),p=o.join(),h="if ("+l+" < "+s[0]+") {\n return getChannel(\n getT0("+p+"), vec2("+c.join()+"));\n }",d=1;d<s.length;d++){var f=s[d-1];h+="\n if ("+l+" < "+s[d]+" && "+l+" >= "+s[d-1]+") {\n return getChannel(\n getT"+d+"("+F0(o,l,f)+"),\n vec2("+F0(c,l,f)+"));\n }"}var m=s.length,v=s[s.length-1];h+="\n return getChannel(\n getT"+m+"("+F0(o,l,v)+"),\n vec2("+F0(c,l,v)+"));",this.userCode="\n float getValue("+o.map((function(e){return"int "+e}))+") {\n "+h+"\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 F0(e,t,n){var r=e.indexOf(t);return e.map((function(e,t){return t===r?e+" - "+n:e})).join()}function O0(e){var t=e.inputs,n=e.backend,r=t.input;return BQ({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}var D0={kernelName:Zy,backendName:"webgl",kernelFunc:O0};function M0(e,t,n){var r=e[0].dtype;if("complex64"===r){var a=e.map((function(e){return y0({inputs:{input:e},backend:n})})),i=e.map((function(e){return O0({inputs:{input:e},backend:n})})),o=M0(a,t,n),s=M0(i,t,n),u=VQ({inputs:{real:o,imag:s},backend:n});return a.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),i.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}var l=n.shouldExecuteOnCPU(e);if("string"===r&&(l=!0),l){var c=e.map((function(e){var r=Xv(e.shape.slice(t));return i$({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})})),p=c.map((function(e){return{vals:n.readSync(e.dataId),shape:e.shape}})),h=N_(c.map((function(e){return e.shape})),1),d=1===c[0].shape[0],f=CZ(p,h,r,d),m=N_(e.map((function(e){return e.shape})),t),v=n.makeTensorInfo(m,r,f);return c.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),v}var g=e.filter((function(e){return Xv(e.shape)>0})),y=Fg().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&g[0].shape.length>1;if(1===g.length){var b=y?new IQ(e[0].shape,CQ):new EQ(e[0].shape,CQ);return n.runWebGLProgram(b,e,r)}var x=Fg().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(g.length>x){for(var w=[],k=0;k<g.length;k+=x){var N=g.slice(k,k+x);w.push(M0(N,t,n))}for(var I=M0(w,t,n),S=0,T=w;S<T.length;S++){var C=T[S];n.disposeIntermediateTensorInfo(C)}return I}if(y){var E=new _0(g.map((function(e){return e.shape})),t);return n.runWebGLProgram(E,g,r)}var A=function(e,t,n){var r=N_(e.map((function(e){return e.shape})),t);return{tensors2D:e.map((function(e){return i$({inputs:{x:e},attrs:{shape:[-1,Xv(e.shape.slice(t))]},backend:n})})),outShape:r}}(g,t,n),R=A.tensors2D,_=A.outShape,F=new R0(R.map((function(e){return e.shape}))),O=n.runWebGLProgram(F,R,r);R.forEach((function(e){return n.disposeIntermediateTensorInfo(e)}));var D=i$({inputs:{x:O},attrs:{shape:_},backend:n});return n.disposeIntermediateTensorInfo(O),D}function L0(e){var t=e.inputs,n=e.backend,r=tg(e.attrs.axis,t[0].shape)[0];k_(t.map((function(e){return e.shape})),r);var a=N_(t.map((function(e){return e.shape})),r);if(0===Xv(a))return n.makeTensorInfo(a,t[0].dtype,[]);var i=t.filter((function(e){return Xv(e.shape)>0}));return 1===i.length?BQ({inputs:{x:i[0]},backend:n}):M0(i,r,n)}var z0={kernelName:ly,backendName:"webgl",kernelFunc:L0},P0=function(e,t,n,r,a){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x","W"],this.outputShape=e.outShape;var i=e.padInfo.top,o=e.padInfo.left,s=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,p=e.filterHeight,h=e.filterWidth,d=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,v=m?1:2,g=m?2:3,y=m?3:1,b="",x="";n&&(b=r?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":a?"float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n "+n+"\n }":"\n float activation(float x) {\n "+n+"\n }\n ",x="result = activation(result);");var w=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n "+b+"\n\n const ivec2 strides = ivec2("+s+", "+u+");\n const ivec2 pads = ivec2("+i+", "+o+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords["+y+"];\n\n ivec2 xRCCorner =\n ivec2(coords["+v+"], coords["+g+"]) * 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 < "+p+"; wR++) {\n int xR = xRCorner + wR * "+l+";\n\n if (xR < 0 || xR >= "+e.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 >= "+e.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+d+"; 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 ("+m+") {\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===f)+") {\n\n if ("+m+") {\n dotProd +=\n getX(batch, xR, xC, "+d+") *\n getW(wR, wC, "+d+", d2);\n } else {\n dotProd +=\n getX(batch, "+d+", xR, xC) *\n getW(wR, wC, "+d+", d2);\n }\n\n } else if ("+(2===f)+") {\n vec2 wValues = vec2(\n getW(wR, wC, "+d+", d2),\n getW(wR, wC, "+d+" + 1, d2)\n );\n\n if ("+m+") {\n vec2 xValues = vec2(\n getX(batch, xR, xC, "+d+"),\n getX(batch, xR, xC, "+d+" + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, "+d+", xR, xC),\n getX(batch, "+d+" + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if ("+(3===f)+") {\n vec3 wValues = vec3(\n getW(wR, wC, "+d+", d2),\n getW(wR, wC, "+d+" + 1, d2),\n getW(wR, wC, "+d+" + 2, d2)\n );\n\n if ("+m+") {\n vec3 xValues = vec3(\n getX(batch, xR, xC, "+d+"),\n getX(batch, xR, xC, "+d+" + 1),\n getX(batch, xR, xC, "+d+" + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, "+d+", xR, xC),\n getX(batch, "+d+" + 1, xR, xC),\n getX(batch, "+d+" + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n "+w+"\n "+x+"\n setOutput(result);\n }\n "},B0=function(e){this.variableNames=["x","W"],this.outputShape=e.outShape;var t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,i=e.strideHeight,o=e.strideWidth,s=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.filterDepth,p=e.filterHeight,h=e.filterWidth,d=4*Math.floor(e.inChannels/4),f=e.inChannels%4;this.userCode="\n const ivec3 strides = ivec3("+a+", "+i+", "+o+");\n const ivec3 pads = ivec3("+t+", "+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 < "+c+"; wF++) {\n int xF = xFCorner + wF * "+s+";\n\n if (xF < 0 || xF >= "+e.inDepth+") {\n continue;\n }\n\n for (int wR = 0; wR < "+p+"; wR++) {\n int xR = xRCorner + wR * "+u+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+h+"; wC++) {\n int xC = xCCorner + wC * "+l+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+d+"; 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===f)+") {\n dotProd +=\n getX(batch, xF, xR, xC, "+d+") *\n getW(wF, wR, wC, "+d+", d2);\n } else if ("+(2===f)+") {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, "+d+"),\n getX(batch, xF, xR, xC, "+d+" + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, "+d+", d2),\n getW(wF, wR, wC, "+d+" + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if ("+(3===f)+") {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, "+d+"),\n getX(batch, xF, xR, xC, "+d+" + 1),\n getX(batch, xF, xR, xC, "+d+" + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, "+d+", d2),\n getW(wF, wR, wC, "+d+" + 1, d2),\n getW(wF, wR, wC, "+d+" + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n "},W0=function(e,t,n,r,a){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=jJ(this.outputShape.length);for(var i=e.padInfo.left,o=e.strideWidth,s=e.dilationWidth,u=e.filterHeight,l=e.filterWidth,c=l,p="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;",h=0;h<l;h++)p+="\n vec4 xTexelC"+2*h+";\n int xTexelC"+2*h+"Ready;\n vec4 xTexelC"+(2*h+1)+";\n int xTexelC"+(2*h+1)+"Ready;\n vec4 xC"+h+";";p+="\n for (int r = 0; r < "+u+"; r++) {\n for (int d1 = 0; d1 < "+e.inChannels+"; d1 += 2) {\n ";for(var d=0;d<l;d++)p+="\n xTexelC"+2*d+" = vec4(0.0);\n xTexelC"+2*d+"Ready = 0;\n xTexelC"+(2*d+1)+" = vec4(0.0);\n xTexelC"+(2*d+1)+"Ready = 0;\n xC"+d+" = vec4(0.0);";p+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(var f=0;f<(c+1)/2;f++){var m=2*f;if(p+="\n xC = xCCorner + "+m*s+";\n ",1===o){if(m<l&&(i%2==1?(p+="\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+m+"Ready == 0) {\n xTexelC"+m+" = 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 >= inDims[1]) {\n xTexelC"+m+".zw = vec2(0.0);\n }\n xTexelC"+m+"Ready = 1;\n }\n ",p+=1===s&&m>0?"\n xC"+m+" = vec4(xTexelC"+(m-2)+".zw, xTexelC"+m+".xy);\n ":"\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n 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 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC"+m+" = vec4(previous.zw, xTexelC"+m+".xy);\n } else {\n xC"+m+" = vec4(0.0, 0.0, xTexelC"+m+".xy);\n }\n "):p+="\n if (xC >= 0 && xC < inDims[1] && xTexelC"+m+"Ready == 0) {\n xTexelC"+m+" = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC"+m+".zw = vec2(0.0);\n }\n xTexelC"+m+"Ready = 1;\n }\n\n xC"+m+" = xTexelC"+m+";\n ",m+1<l)){var v=i%2==0?Uv(s):s;s%2==0&&i%2==1||s%2!=0&&i%2!=1?(p+="\n xCOffset = xC + imod(pads[1], 2) + "+v+";\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+(m+1)+"Ready == 0) {\n xTexelC"+(m+1)+" = 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 >= inDims[1]) {\n xTexelC"+(m+1)+".zw = vec2(0.0);\n }\n xTexelC"+(m+1)+"Ready = 1;\n }\n ",p+=s>1?"\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC"+(m+1)+" = vec4(previous.zw, xTexelC"+(m+1)+".xy);\n } else {\n xC"+(m+1)+" = vec4(0.0, 0.0, xTexelC"+(m+1)+".xy);\n }\n ":"\n xC"+(m+1)+" = vec4(xTexelC"+m+".zw, xTexelC"+(m+1)+".xy);\n "):p+=1===v?"\n xC"+(m+1)+" = xTexelC"+m+";\n ":"\n xCOffset = xC + "+v+";\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+(m+1)+"Ready == 0) {\n xTexelC"+(m+1)+" = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC"+(m+1)+".zw = vec2(0.0);\n }\n xTexelC"+(m+1)+"Ready = 1;\n }\n\n xC"+(m+1)+" = xTexelC"+(m+1)+";\n "}}else m<l&&(i%2==1?(p+="\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+m+"Ready == 0) {\n xTexelC"+m+" = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC"+m+".zw = vec2(0.0);\n }\n xTexelC"+m+"Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC"+(m+1)+"Ready == 0) {\n xTexelC"+(m+1)+" = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC"+(m+1)+".zw = vec2(0.0);\n }\n xTexelC"+(m+1)+"Ready = 1;\n }\n\n xC"+m+" = vec4(xTexelC"+m+".zw, xTexelC"+(m+1)+".zw);\n ",m+1<l&&(p+="\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC"+(m+1)+" = vec4(xTexelC"+(m+1)+".xy, final.xy);\n ")):(p+="\n if(xC >= 0 && xC < inDims[1] && xTexelC"+m+"Ready == 0) {\n xTexelC"+m+" = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC"+m+".zw = vec2(0.0);\n }\n xTexelC"+m+"Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+(m+1)+"Ready == 0) {\n xTexelC"+(m+1)+" = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC"+(m+1)+".zw = vec2(0.);\n }\n xTexelC"+(m+1)+"Ready = 1;\n }\n\n xC"+m+" = vec4(\n xTexelC"+m+".xy, xTexelC"+(m+1)+".xy);\n ",m+1<l&&(p+="\n xC"+(m+1)+" = vec4(xTexelC"+m+".zw, xTexelC"+(m+1)+".zw);\n ")));m<l&&(p+="\n wTexel = getW(r, "+m+", d1, d2);\n dotProd += xC"+m+".xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < "+e.inChannels+") {\n dotProd += xC"+m+".yyww * vec4(wTexel.zw, wTexel.zw);\n }\n ",m+1<l&&(p+="\n wTexel = getW(r, "+(m+1)+", d1, d2);\n dotProd += xC"+(m+1)+".xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < "+e.inChannels+") {\n dotProd += xC"+(m+1)+".yyww * vec4(wTexel.zw, wTexel.zw);\n }\n "))}p+="\n }\n ",p+="\n }\n ",p+="\n }\n ";var g="",y="";n&&(g=r?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":a?"vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n "+n+"\n }":"vec4 activation(vec4 x) {\n "+n+"\n }",y="result = activation(result);");var b=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n "+g+"\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 xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n "+p+"\n\n vec4 result = dotProd - vec4(0.000000000000001);\n "+b+"\n "+y+"\n setOutput(result);\n }\n "},V0=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=jJ(this.outputShape.length);for(var n=t.dataFormat,r=kJ(),a="channelsLast"===n,i=a?1:2,o=a?2:3,s=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":"if(blockIndex < "+e[2]+" && pos < "+e[1]+") {",u="",l=0;l<=1;l++)for(var c=0;c<=1;c++)u+="\n blockIndex = rc.z + "+c+";\n pos = rc.y + "+l+";\n\n "+s+"\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape["+i+"] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape["+o+"] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if ("+a+") {\n innerDims = vec2(d1, ch);\n result["+(2*l+c)+"] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result["+(2*l+c)+"] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n ";this.userCode="\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n "+u+"\n\n "+r.output+" = result;\n }\n "};function U0(e,t){var n=e.length;return n>=3?[].concat(e.slice(0,-3),t?[e[n-3]*e[n-2],e[n-1]]:[e[n-3],e[n-2]*e[n-1]]):!t&&1===n&&e[0]>1?[e[0],1]:null}function G0(e){var t,n=e.x,r=e.filter,a=e.convInfo,i=e.backend,o=e.bias,s=void 0===o?null:o,u=e.preluActivationWeights,l=void 0===u?null:u,c=e.leakyreluAlpha,p=void 0===c?0:c,h=e.activation,d=void 0===h?null:h,f=n.shape,m=i.texData.get(n.dataId),v=a.inChannels,g=f[0]*f[1]*f[2],y=a.outChannels,b="channelsLast"===a.dataFormat,x=[];if(null!=l){var w=U0(l.shape,b);null!=w&&(l=i$({inputs:{x:l},backend:i,attrs:{shape:w}}),x.push(l))}if(null!=s){var k=U0(s.shape,b);null!=k&&(s=i$({inputs:{x:s},backend:i,attrs:{shape:k}}),x.push(s))}if(!((1===g||1===y)&&v>1e3)&&m.isPacked&&b&&null!=m.texture&&f[2]%2!=0&&Yv(m.shape.slice(-3),f.slice(-3))){var N=f[0]*f[1]*(f[2]+1),I={dataId:n.dataId,shape:[1,N,a.inChannels],dtype:n.dtype},S=m.shape;m.shape=m.shape.slice(),m.shape[m.shape.length-2]++,Hv(lJ(m.shape,I.shape),(function(){return"packed reshape "+m.shape+" to "+I.shape+" isn't free"}));var T=i$({inputs:{x:r},backend:i,attrs:{shape:[1,a.inChannels,a.outChannels]}});x.push(T);var C=g$({a:I,b:T,backend:i,transposeA:!1,transposeB:false,bias:s,activation:d,preluActivationWeights:l,leakyreluAlpha:p}),E=i.texData.get(C.dataId);Hv(E.isPacked,(function(){return"batchMatMul result is expected to be packed"})),m.shape=S,E.shape=a.outShape,(t=BQ({inputs:{x:C},backend:i})).shape=a.outShape,x.push(C)}else{var A=a.outHeight*a.outWidth,R=i$({inputs:{x:n},backend:i,attrs:{shape:b?[a.batchSize,A,a.inChannels]:[a.batchSize,a.inChannels,A]}}),_=i$({inputs:{x:r},backend:i,attrs:{shape:[1,a.inChannels,a.outChannels]}}),F=g$({a:b?R:_,b:b?_:R,transposeA:!b,transposeB:false,backend:i,bias:s,activation:d,preluActivationWeights:l,leakyreluAlpha:p});t=i$({inputs:{x:F},backend:i,attrs:{shape:a.outShape}}),x.push(R),x.push(_),x.push(F)}for(var O=0,D=x;O<D.length;O++){var M=D[O];i.disposeIntermediateTensorInfo(M)}return t}function j0(e){var t=e.x,n=e.filter,r=e.convInfo,a=e.backend,i=e.bias,o=void 0===i?null:i,s=e.preluActivationWeights,u=void 0===s?null:s,l=e.leakyreluAlpha,c=void 0===l?0:l,p=e.activation,h=void 0===p?null:p,d=r.filterWidth,f=r.filterHeight,m=r.inChannels,v=r.outWidth,g=r.outHeight,y="channelsLast"===r.dataFormat,b=d*f*m,x=g*v,w=[r.batchSize,b,x],k=[];if(null!=u){var N=U0(u.shape,y);null!=N&&(u=i$({inputs:{x:u},backend:a,attrs:{shape:N}}),k.push(u))}if(null!=o){var I=U0(o.shape,y);null!=I&&(o=i$({inputs:{x:o},backend:a,attrs:{shape:I}}),k.push(o))}var S=i$({inputs:{x:n},backend:a,attrs:{shape:[1,b,Xv(n.shape)/b]}});k.push(S);var T=new V0(w,r),C=[t.shape,[r.padInfo.top,r.padInfo.left],[r.strideHeight,r.strideWidth],[r.dilationHeight,r.dilationWidth],[r.inChannels],[r.filterWidth*r.inChannels],[r.outWidth]],E=a.runWebGLProgram(T,[t],"float32",C),A=i$({inputs:{x:E},backend:a,attrs:{shape:w}});k.push(E),k.push(A);var R=null!=o,_=null!=u,F="leakyrelu"===h,O=h?ZQ(h,!0):null,D=new QQ(y?A.shape:S.shape,y?S.shape:A.shape,y?[r.batchSize,x,r.outChannels]:[r.batchSize,r.outChannels,x],!0,!1,R,O,_,F),M=y?[A,S]:[S,A];if(o&&M.push(o),_&&M.push(u),F){var L=a.makeTensorInfo([],"float32",Bw(c,"float32"));M.push(L),k.push(L)}var z=a.runWebGLProgram(D,M,"float32"),P=i$({inputs:{x:z},backend:a,attrs:{shape:r.outShape}});k.push(z);for(var B=0,W=k;B<W.length;B++){var V=W[B];a.disposeIntermediateTensorInfo(V)}return P}var H0={kernelName:cy,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=n.filter,s=a.strides,u=a.pad,l=a.dataFormat,c=a.dilations,p=a.dimRoundingMode,h=LI(l),d=TI(i.shape,o.shape,s,c,u,p,!1,h);if(1!==d.filterHeight||1!==d.filterWidth||1!==d.dilationHeight||1!==d.dilationWidth||1!==d.strideHeight||1!==d.strideWidth||"SAME"!==d.padInfo.type&&"VALID"!==d.padInfo.type)if(d.strideWidth<=2&&"channelsLast"===h&&Fg().getBool("WEBGL_EXP_CONV")){var f=new W0(d),m=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];t=r.runWebGLProgram(f,[i,o],"float32",m)}else if(Fg().getBool("WEBGL_CONV_IM2COL"))t=j0({x:i,filter:o,convInfo:d,backend:r});else{var v=new P0(d);t=r.runWebGLProgram(v,[i,o],"float32")}else t=G0({x:i,filter:o,convInfo:d,backend:r});var g=i$({inputs:{x:t},backend:r,attrs:{shape:d.outShape}});return r.disposeIntermediateTensorInfo(t),g}},q0=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i="channelsLast"===e.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 < "+e.batchSize+"; b++) {\n for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n int xR = wR + yR * "+t+" - "+r+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+a+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n "+(i?"float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);":"float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);")+"\n }\n }\n }\n setOutput(dotProd);\n }\n "},K0=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i="channelsLast"===e.dataFormat,o=t-1-e.padInfo.top,s=n-1-e.padInfo.left,u=i?1:2,l=i?2:3,c=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["+c+"];\n\n ivec2 dyCorner = ivec2(coords["+u+"], coords["+l+"]) - 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 < "+t+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+t+" - 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 >= "+e.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 < "+e.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 "},X0=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,i=e.padInfo.top,o=e.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 < "+e.batchSize+"; b++) {\n for (int yF = 0; yF < "+e.outDepth+"; yF++) {\n int xF = wF + yF * "+t+" - "+a+";\n\n if (xF < 0 || xF >= "+e.inDepth+") {\n continue;\n }\n\n for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n int xR = wR + yR * "+n+" - "+i+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n int xC = wC + yC * "+r+" - "+o+";\n\n if (xC < 0 || xC >= "+e.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 "},Y0=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,o=e.strideWidth,s=t-1-e.padInfo.front,u=n-1-e.padInfo.top,l=r-1-e.padInfo.left;this.userCode="\n const ivec3 pads = ivec3("+s+", "+u+", "+l+");\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 < "+t+"; wF++) {\n float dyF = float(dyFCorner + wF) / "+a+".0;\n\n if (dyF < 0.0 || dyF >= "+e.outDepth+".0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = "+t+" - 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 >= "+e.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 >= "+e.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 < "+e.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 "};var J0={kernelName:py,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.pad,u=r.dataFormat,l=r.dimRoundingMode,c=r.filterShape,p=LI(u),h=TI(a.shape,c,o,1,s,l,!1,p),d=new q0(h);return n.runWebGLProgram(d,[a,i],"float32")}},Z0=function(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=jJ(this.outputShape.length);var t=e.filterHeight,n=e.filterWidth,r=t-1-e.padInfo.top,a=n-1-e.padInfo.left;this.userCode="\n const ivec2 pads = ivec2("+r+", "+a+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n\n ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n vec4 result = vec4(0.);\n for (int wR = 0; wR < "+t+"; wR++) {\n float dyR = float(dyRCorner + wR) / strides[0];\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n int wRPerm = "+t+" - 1 - wR;\n\n for (int wC = 0; wC < "+n+"; wC++) {\n int wCPerm = "+n+" - 1 - wC;\n\n float dyC = float(dyCCorner + wC) / strides[1];\n bool idyCVal = (dyC >= 0.0) && (dyC < "+e.outWidth+".0)\n && (fract(dyC) == 0.0);\n int idyC = int(dyC);\n\n float dyC2 = float(dyCCorner + wC + 1) / strides[1];\n bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < "+e.outWidth+".0)\n && (fract(dyC2) == 0.0);\n int idyC2 = int(dyC2);\n\n if (idyCVal && idyCVal2) {\n for (int d2 = 0; d2 < "+e.outChannels+"; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec4 dySample2 = (idyC / 2 == idyC2 / 2) ?\n dySample : getDy(batch, idyR, idyC2, d2);\n\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n\n dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample2.xy : dySample2.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal) {\n for (int d2 = 0; d2 < "+e.outChannels+"; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal2) {\n for (int d2 = 0; d2 < "+e.outChannels+"; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC2, d2);\n vec2 dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n }\n }\n }\n setOutput(result);\n }\n "};var Q0={kernelName:hy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.inputShape,s=r.strides,u=r.pad,l=r.dataFormat,c=r.dimRoundingMode,p=LI(l),h=TI(o,i.shape,s,1,u,c,!1,p);if(Fg().getBool("WEBGL_PACK")&&"channelsLast"===p){var d=[[h.strideHeight,h.strideWidth]],f=new Z0(h);return n.runWebGLProgram(f,[a,i],"float32",d)}var m=new K0(h);return n.runWebGLProgram(m,[a,i],"float32")}};var $0={kernelName:dy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations,l=CI(a.shape,i.shape,o,u,s),c=new B0(l);return n.runWebGLProgram(c,[a,i],"float32")}};var e1={kernelName:fy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.pad,u=r.filterShape,l=CI(a.shape,u,o,1,s),c=new X0(l);return n.runWebGLProgram(c,[a,i],"float32")}};var t1,n1={kernelName:my,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.pad,s=r.strides,u=CI(r.inputShape,i.shape,s,1,o),l=new Y0(u);return n.runWebGLProgram(l,[a,i],"float32")}},r1=YQ({opSnippet:"if (isnan(x)) return x;\n return cos(x);\n",packedOpSnippet:"\n vec4 result = cos(x);\n bvec4 isNaN = isnan(x);\n \n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n\n return result;\n"}),a1={kernelName:vy,backendName:"webgl",kernelFunc:r1},i1=YQ({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),o1={kernelName:gy,backendName:"webgl",kernelFunc:i1},s1=function(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3],l=t[0],c=n[0],p=n[1];this.outputShape=[l,c,p,u];var h="bilinear"===r?1:0,d=o-1+".0",f=s-1+".0",m=c>1?[""+(o-1)/(c-1),"(y2-y1) * height_ratio","y1*"+d+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+d],v=m[0],g=m[1],y=m[2],b=p>1?[""+(s-1)/(p-1),"(x2-x1) * width_ratio","x1*"+f+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+f],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 > "+d+" ) {\n setOutput(float("+a+"));\n return;\n }\n float in_x = "+k+";\n if( in_x < 0.0 || in_x > "+f+" ) {\n setOutput(float("+a+"));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if("+h+" == 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 "},u1={kernelName:xy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.image,i=t.boxes,o=t.boxInd,s=r.cropSize,u=r.method,l=r.extrapolationValue,c=new s1(a.shape,i.shape,s,u,l);return n.runWebGLProgram(c,[a,i,o],"float32")}};!function(e){e.Prod="*",e.Sum="+"}(t1||(t1={}));var l1=function(e,t,n,r){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];var a=this.outputShape.length,i=this.op===t1.Prod?"1.0":"0.0",o=n?i:"getX("+c1(a,"coords",this.op)+")",s=this.outputShape[this.outputShape.length-1],u="",l="";n?(u=r?"end != "+(s-1):"end != 0",l=r?"end + 1":"end - 1"):(u=r?"end + pow2 < "+s:"end >= pow2",l=r?"end + pow2":"end - pow2"),this.userCode="\n void main() {\n "+PJ(a)+" coords = getOutputCoords();\n int end = "+p1(a,"coords",this.op)+";\n float val = "+o+";\n int pow2 = int(pow(2.0, index));\n if ("+u+") {\n int idx = "+l+";\n "+p1(a,"coords",this.op)+" = idx;\n val "+this.op+"= getX("+c1(a,"coords",this.op)+");\n }\n setOutput(val);\n }\n "};function c1(e,t,n){if(1===e)return""+t;if(2===e)return t+".x, "+t+".y";if(3===e)return t+".x, "+t+".y, "+t+".z";if(4===e)return t+".x, "+t+".y, "+t+".z, "+t+".w";throw new Error("Cumulative "+n+" for rank "+e+" is not yet supported")}function p1(e,t,n){if(1===e)return""+t;if(2===e)return t+".y";if(3===e)return t+".z";if(4===e)return t+".w";throw new Error("Cumulative "+n+" for rank "+e+" is not yet supported")}function h1(e,t,n,r,a,i){var o=t.shape.length,s=VS([r],o),u=t;null!=s&&(u=m$({inputs:{x:t},backend:n,attrs:{perm:s}}));var l=GS(1,o)[0];if(l!==o-1)throw new Error("WebGL cumprod shader expects an inner-most axis="+(t.shape.length-1)+" but got axis="+r);for(var c=u.shape[l],p=BQ({inputs:{x:u},backend:n}),h=0;h<=Math.ceil(Math.log2(c))-1;h++){var d=new l1(e,u.shape,!1,i),f=[[h]],m=p;p=n.runWebGLProgram(d,[p],p.dtype,f),n.disposeIntermediateTensorInfo(m)}if(a){var v=new l1(e,u.shape,a,i),g=p;p=n.runWebGLProgram(v,[p],p.dtype),n.disposeIntermediateTensorInfo(g)}if(null!=s){var y=m$({inputs:{x:p},backend:n,attrs:{perm:US(s)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(u),y}return p}var d1={kernelName:yy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.exclusive,s=r.reverse;return h1(t1.Prod,a,n,i,o,s)}};var f1={kernelName:by,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.exclusive,s=r.reverse;return h1(t1.Sum,a,n,i,o,s)}};var m1={kernelName:wy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.weights,o=r.size,s=r.binaryOutput;if(1===a.shape.length){var u=n.readSync(a.dataId),l=n.readSync(i.dataId),c=NZ(u,l,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,c)}if(2===a.shape.length){var p=n.bufferSync(a),h=n.bufferSync(i),d=IZ(p,h,o,s);return n.makeTensorInfo(d.shape,i.dtype,d.values)}throw new Error("Error in denseBincount: input must be at most rank 2, but got rank"+a.shape.length+".")}},v1=function(){function e(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,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 / "+t+";\n int offset_h = imod(h, "+t+");\n int in_w = w / "+t+";\n int offset_w = imod(w, "+t+");\n int offset_d = (offset_h * "+t+" + offset_w) *\n "+this.getOutputDepthSize()+";\n int in_d = d + offset_d;\n\n float result = "+this.getInputSamplingString()+";\n setOutput(result);\n }\n "}var t=e.prototype;return t.getHeightCoordString=function(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"},t.getWidthCoordString=function(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"},t.getDepthCoordString=function(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"},t.getOutputDepthSize=function(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]},t.getInputSamplingString=function(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"},e}();var g1={kernelName:ky,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockSize,o=r.dataFormat,s=a.shape[0],u=("NHWC"===o?a.shape[1]:a.shape[2])*i,l=("NHWC"===o?a.shape[2]:a.shape[3])*i,c=("NHWC"===o?a.shape[3]:a.shape[1])/(i*i),p=new v1("NHWC"===o?[s,u,l,c]:[s,c,u,l],i,o);return n.runWebGLProgram(p,[a],a.dtype)}},y1=function(e,t,n,r,a){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=jJ(this.outputShape.length);var i=e.filterHeight,o=e.filterWidth,s=e.outChannels/e.inChannels,u="",l="";n&&(u=r?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":a?"float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n "+n+"\n }":"\n float activation(float x) {\n "+n+"\n }\n ",l="result = activation(result);");var c=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n "+u+"\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 / "+s+";\n int q = d2 - d1 * "+s+";\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 < "+i+"; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < "+o+"; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\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 "+c+"\n "+l+"\n setOutput(result);\n }\n "},b1=function(e,t,n,r,a){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=jJ(this.outputShape.length);for(var i=e.outChannels/e.inChannels,o=e.padInfo.left,s=e.strideWidth,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,p=c,h="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;",d=0;d<c;d++)h+="\n vec4 xTexelC"+2*d+";\n int xTexelC"+2*d+"Ready;\n vec4 xTexelC"+(2*d+1)+";\n int xTexelC"+(2*d+1)+"Ready;\n vec4 xC"+d+";";h+="\n for (int r = 0; r < "+l+"; r++) {\n ";for(var f=0;f<c;f++)h+="\n xTexelC"+2*f+" = vec4(0.0);\n xTexelC"+2*f+"Ready = 0;\n xTexelC"+(2*f+1)+" = vec4(0.0);\n xTexelC"+(2*f+1)+"Ready = 0;\n xC"+f+" = vec4(0.0);";h+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(var m=0;m<(p+1)/2;m++){var v=2*m;if(h+="\n xC = xCCorner + "+v*u+";\n ",1===s){if(v<c&&(o%2==1?(h+="\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+v+"Ready == 0) {\n xTexelC"+v+" = 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 >= inDims[1]) {\n xTexelC"+v+".zw = vec2(0.0);\n }\n xTexelC"+v+"Ready = 1;\n }\n ",h+=1===u&&v>0?"\n xC"+v+" = vec4(xTexelC"+(v-2)+".zw, xTexelC"+v+".xy);\n ":"\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n 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 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC"+v+" = vec4(previous.zw, xTexelC"+v+".xy);\n } else {\n xC"+v+" = vec4(0.0, 0.0, xTexelC"+v+".xy);\n }\n "):h+="\n if (xC >= 0 && xC < inDims[1] && xTexelC"+v+"Ready == 0) {\n xTexelC"+v+" = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC"+v+".zw = vec2(0.0);\n }\n xTexelC"+v+"Ready = 1;\n }\n\n xC"+v+" = xTexelC"+v+";\n ",v+1<c)){var g=o%2==0?Uv(u):u;u%2==0&&o%2==1||u%2!=0&&o%2!=1?(h+="\n xCOffset = xC + imod(pads[1], 2) + "+g+";\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+(v+1)+"Ready == 0) {\n xTexelC"+(v+1)+" = 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 >= inDims[1]) {\n xTexelC"+(v+1)+".zw = vec2(0.0);\n }\n xTexelC"+(v+1)+"Ready = 1;\n }\n ",h+=u>1?"\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC"+(v+1)+" = vec4(previous.zw, xTexelC"+(v+1)+".xy);\n } else {\n xC"+(v+1)+" = vec4(0.0, 0.0, xTexelC"+(v+1)+".xy);\n }\n ":"\n xC"+(v+1)+" = vec4(xTexelC"+v+".zw, xTexelC"+(v+1)+".xy);\n "):h+=1===g?"\n xC"+(v+1)+" = xTexelC"+v+";\n ":"\n xCOffset = xC + "+g+";\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+(v+1)+"Ready == 0) {\n xTexelC"+(v+1)+" = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC"+(v+1)+".zw = vec2(0.0);\n }\n xTexelC"+(v+1)+"Ready = 1;\n }\n\n xC"+(v+1)+" = xTexelC"+(v+1)+";\n "}}else v<c&&(o%2==1?(h+="\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+v+"Ready == 0) {\n xTexelC"+v+" = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC"+v+".zw = vec2(0.0);\n }\n xTexelC"+v+"Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC"+(v+1)+"Ready == 0) {\n xTexelC"+(v+1)+" = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC"+(v+1)+".zw = vec2(0.0);\n }\n xTexelC"+(v+1)+"Ready = 1;\n }\n\n xC"+v+" = vec4(xTexelC"+v+".zw, xTexelC"+(v+1)+".zw);\n ",v+1<c&&(h+="\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC"+(v+1)+" = vec4(xTexelC"+(v+1)+".xy, final.xy);\n ")):(h+="\n if(xC >= 0 && xC < inDims[1] && xTexelC"+v+"Ready == 0) {\n xTexelC"+v+" = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC"+v+".zw = vec2(0.0);\n }\n xTexelC"+v+"Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC"+(v+1)+"Ready == 0) {\n xTexelC"+(v+1)+" = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC"+(v+1)+".zw = vec2(0.);\n }\n xTexelC"+(v+1)+"Ready = 1;\n }\n\n xC"+v+" = vec4(\n xTexelC"+v+".xy, xTexelC"+(v+1)+".xy);\n ",v+1<c&&(h+="\n xC"+(v+1)+" = vec4(xTexelC"+v+".zw, xTexelC"+(v+1)+".zw);\n ")));v<c&&(h+="\n wTexel = getW(r, "+v+", d1, q);\n dotProd += xC"+v+" * vec4(wTexel.xz, wTexel.xz);\n ",v+1<c&&(h+="\n wTexel = getW(r, "+(v+1)+", d1, q);\n dotProd += xC"+(v+1)+" * vec4(wTexel.xz, wTexel.xz);\n "))}h+="\n }\n ",h+="\n }\n ";var y="",b="";n&&(y=r?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n "+n+"\n }":a?"vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n "+n+"\n }":"vec4 activation(vec4 x) {\n "+n+"\n }",b="result = activation(result);");var x=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n "+y+"\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 / "+i+";\n int q = d2 - d1 * "+i+";\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n "+h+"\n\n vec4 result = dotProd - vec4(0.000000000000001);\n "+x+"\n "+b+"\n setOutput(result);\n }\n "};var x1={kernelName:Ny,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations,l=r.dimRoundingMode,c=u;null==c&&(c=[1,1]),Hv(DI(o,c),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+c+"'"}));var p,h=TI(a.shape,i.shape,o,c,s,l,!0);p=Fg().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels==1?new b1(h):new y1(h);var d=[[h.padInfo.top,h.padInfo.left],[h.strideHeight,h.strideWidth],[h.dilationHeight,h.dilationWidth],[h.inHeight,h.inWidth]];return n.runWebGLProgram(p,[a,i],"float32",d)}},w1=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i=e.outChannels/e.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 < "+e.batchSize+"; b++) {\n for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n int xR = wR + yR * "+t+" - "+r+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+a+";\n\n if (xC < 0 || xC >= "+e.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 "},k1=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=t-1-e.padInfo.top,o=n-1-e.padInfo.left,s=e.outChannels/e.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 < "+t+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+t+" - 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 >= "+e.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 "};var N1={kernelName:Iy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.dilations,u=r.pad,l=r.dimRoundingMode,c=r.filterShape,p=TI(a.shape,c,o,s,u,l,!0),h=new w1(p);return n.runWebGLProgram(h,[a,i],"float32")}};var I1={kernelName:Sy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.strides,s=r.dilations,u=r.pad,l=r.dimRoundingMode,c=TI(r.inputShape,i.shape,o,s,u,l,!0),p=new k1(c);return n.runWebGLProgram(p,[a,i],"float32")}},S1=function(e){this.variableNames=["X"],this.outputShape=[e,e],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 "};var T1={kernelName:Ty,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=[].concat(r.shape,r.shape),i=Xv(r.shape),o=i$({inputs:{x:r},backend:n,attrs:{shape:[i]}}),s=new S1(i),u=n.runWebGLProgram(s,[o],o.dtype),l=i$({inputs:{x:u},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(u),l}},C1=function(e){this.variableNames=["x","W"],this.outputShape=e.outShape;var t=e.inHeight,n=e.inWidth,r=e.padInfo,a=e.strideHeight,i=e.strideWidth,o=e.filterHeight,s=e.filterWidth,u=e.dilationHeight,l=e.dilationWidth,c=r.top,p=r.left;this.userCode="\n const ivec2 strides = ivec2("+a+", "+i+");\n const ivec2 pads = ivec2("+c+", "+p+");\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < "+o+"; h++) {\n int hIn = hBeg + h * "+u+";\n\n if (hIn >= 0 && hIn < "+t+") {\n for (int w = 0; w < "+s+"; w++) {\n int wIn = wBeg + w * "+l+";\n\n if (wIn >= 0 && wIn < "+n+") {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n "};var E1={kernelName:Cy,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=n.filter,s=a.strides,u=a.pad,l=a.dilations,c=NI(i.shape,o.shape,s,u,"NHWC",l),p=new C1(c),h=i$({inputs:{x:t=r.runWebGLProgram(p,[i,o],"float32")},backend:r,attrs:{shape:c.outShape}});return r.disposeIntermediateTensorInfo(t),h}};var A1={kernelName:_y,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t,a=$_(e.attrs.equation,r.length),i=a.allDims,o=a.summedDims,s=a.idDims;tF(i.length,s,r);for(var u=nF(o,s),l=u.path,c=u.steps,p=c.length,h=null,d=i.length,f=[],m=0;m<p;++m){for(var v,g=Lv(c[m]);!(v=g()).done;){var y=v.value,b=eF(d,s[y]),x=b.permutationIndices,w=b.expandDims,k=void 0;rF(x)?k=r[y]:(k=m$({inputs:{x:r[y]},backend:n,attrs:{perm:x}}),f.push(k));for(var N=k.shape.slice(),I=0;I<w.length;++I)N.splice(w[I],0,1);Yv(k.shape,N)||(k=i$({inputs:{x:k},backend:n,attrs:{shape:N}}),f.push(k)),null===h?h=k:(h=r$({inputs:{a:k,b:h},backend:n}),f.push(h))}m<p-1&&(l[m]>=0&&(h=d$({inputs:{x:h},backend:n,attrs:{axis:l[m]-(i.length-d),keepDims:!1}}),f.push(h)),d--)}for(var S=0,T=f;S<T.length;S++){var C=T[S];C!==h&&n.disposeIntermediateTensorInfo(C)}return h}},R1=YQ({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:"\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"}),_1={kernelName:Fy,backendName:"webgl",kernelFunc:R1},F1={kernelName:Oy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.dy,a=t.y,i=Fg().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new PQ("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",r.shape,a.shape):new zQ("return (b >= 0.0) ? a : a * (b + 1.0);",r.shape,a.shape);return n.runWebGLProgram(i,[r,a],r.dtype)}},O1=JQ({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:EZ}),D1={kernelName:My,backendName:"webgl",kernelFunc:O1},M1=YQ({opSnippet:'\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'}),L1={kernelName:Dy,backendName:"webgl",kernelFunc:M1},z1=YQ({opSnippet:"if (isnan(x)) return x;\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\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",cpuKernelImpl:AZ,dtype:"float32"}),P1={kernelName:Ly,backendName:"webgl",kernelFunc:z1};function B1(e){var t=e.inputs,n=e.attrs,r=e.backend,a=n.dim,i=t.input,o=i.shape.length,s=i.shape.slice(),u=a;return a<0&&(Hv(-(o+1)<=a,(function(){return"Axis must be in the interval ["+-(o+1)+", "+o+"]"})),u=o+a+1),s.splice(u,0,1),i$({inputs:{x:i},backend:r,attrs:{shape:s}})}var W1={kernelName:zy,backendName:"webgl",kernelFunc:B1},V1="return exp(x) - 1.0;",U1=YQ({opSnippet:V1,packedOpSnippet:V1,cpuKernelImpl:RZ}),G1={kernelName:Py,backendName:"webgl",kernelFunc:U1},j1=function(e,t,n){this.variableNames=["real","imag"];var r=t[1];this.outputShape=t;var a,i=n?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,o=n?r+".0":"1.0";if("real"===e)a="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error('FFT component must be either "real" or "imag", got '+e+".");a="return real * expI + imag * expR;"}this.userCode="\n const float exponentMultiplier = "+i+";\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n "+a+"\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) / "+o+";\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n "};function H1(e,t,n){var r=n.texData.get(e.dataId),a=Xv(e.shape),i=e.shape[e.shape.length-1],o=i$({inputs:{x:e},backend:n,attrs:{shape:[a/i,i]}}),s=o.shape,u=new j1("real",s,t),l=new j1("imag",s,t),c=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:s},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:s}],p=n.runWebGLProgram(u,c,"float32"),h=n.runWebGLProgram(l,c,"float32"),d=VQ({inputs:{real:p,imag:h},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h);var f=i$({inputs:{x:d},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(d),f}var q1={kernelName:By,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend;return H1(t.input,!1,n)}},K1=function(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "};function X1(e){var t=e.backend,n=e.attrs,r=n.shape,a=n.value,i=n.dtype;if("string"===(i=i||dg(a))){var o=ag(i,Xv(r));return o.fill(a),t.makeTensorInfo(r,i,o)}var s=new K1(r,a),u=[[a]];return t.runWebGLProgram(s,[],i,u)}var Y1,J1={kernelName:Wy,backendName:"webgl",kernelFunc:X1},Z1=function(e){this.variableNames=["Image"],this.outputShape=[];var t=e[2];this.outputShape=e,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = "+t+" - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < "+t+") {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n "},Q1={kernelName:Vy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.image,a=n,i=new Z1(r.shape);return a.runWebGLProgram(i,[r],r.dtype)}},$1="return floor(x);",e2=YQ({opSnippet:$1,packedOpSnippet:$1,cpuKernelImpl:_Z}),t2={kernelName:Uy,backendName:"webgl",kernelFunc:e2},n2=JQ({opSnippet:"\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",packedOpSnippet:"\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",dtype:"int32"}),r2={kernelName:Gy,backendName:"webgl",kernelFunc:n2},a2=function(e){this.variableNames=["A"];var t=kJ(),n=e[0],r=e[1];this.outputShape=e,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 = "+t.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 "},i2=function(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var t=kJ(),n=e[0],r=e[1];this.outputShape=e,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 = "+t.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 "+t.output+" = result;\n }\n "},o2={kernelName:Vx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.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],l=u[0],c=u[1],p=[c,l],h=[c,l,i];if(s||o){var d=Fg().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");null!=Y1&&d===s2||(s2=d,Y1=document.createElement("canvas").getContext("2d",{willReadFrequently:s2})),Y1.canvas.width=l,Y1.canvas.height=c,Y1.drawImage(a,0,0,l,c),a=Y1.canvas}var f=n.makeTensorInfo(p,"int32");n.texData.get(f.dataId).usage=bY.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(f.dataId),a);var m=Fg().getBool("WEBGL_PACK")?new i2(h):new a2(h),v=n.runWebGLProgram(m,[f],"int32");return n.disposeData(f.dataId),v}},s2=Fg().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");var u2={kernelName:jx,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=n.filter,s=n.bias,u=n.preluActivationWeights,l=a.strides,c=a.pad,p=a.dataFormat,h=a.dilations,d=a.dimRoundingMode,f=a.activation,m=a.leakyreluAlpha,v=LI(p),g=TI(i.shape,o.shape,l,h,c,d,!1,v),y=[],b=null!=s,x=null!=u,w="leakyrelu"===f,k=function(){var e=[i,o],t=function(e,t){if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){var n=i$({inputs:{x:e},backend:r,attrs:{shape:[e.shape[0],1,1]}});return y.push(n),n}return e};if(b&&e.push(t(s,p)),x&&e.push(t(u,p)),w){var n=r.makeTensorInfo([],"float32",Bw(m,"float32"));e.push(n),y.push(n)}return e};if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(g.strideWidth<=2&&"channelsLast"===v&&Fg().getBool("WEBGL_EXP_CONV")){var N=f?ZQ(f,!0):null,I=new W0(g,b,N,x,w),S=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],T=k();t=r.runWebGLProgram(I,T,"float32",S)}else if(Fg().getBool("WEBGL_CONV_IM2COL"))t=j0({x:i,filter:o,convInfo:g,backend:r,bias:s,activation:f,preluActivationWeights:u,leakyreluAlpha:m});else{var C=f?ZQ(f,!1):null,E=new P0(g,b,C,x,w),A=k();t=r.runWebGLProgram(E,A,"float32")}else t=G0({x:i,filter:o,convInfo:g,backend:r,bias:s,activation:f,preluActivationWeights:u,leakyreluAlpha:m});var R=i$({inputs:{x:t},backend:r,attrs:{shape:g.outShape}});return y.push(t),y.forEach((function(e){return r.disposeIntermediateTensorInfo(e)})),R}};var l2={kernelName:Hx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.bias,s=t.preluActivationWeights,u=r.strides,l=r.pad,c=r.dilations,p=r.dimRoundingMode,h=r.activation,d=r.leakyreluAlpha,f=[],m=c;null==m&&(m=[1,1]),Hv(DI(u,m),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+u+" and dilations '"+m+"'"}));var v,g=TI(a.shape,i.shape,u,m,l,p,!0),y=Fg().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,b=h?ZQ(h,y):null,x=[a,i],w=null!=o,k=null!=s,N="leakyrelu"===h;if(w&&x.push(o),k&&x.push(s),N){var I=n.makeTensorInfo([],"float32",Bw(d,"float32"));x.push(I),f.push(I)}v=y?new b1(g,w,b,k,N):new y1(g,w,b,k,N);var S=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],T=n.runWebGLProgram(v,x,"float32",S);return f.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),T}},c2=function(e,t,n,r){this.sliceDim=e,this.strides=t,this.paramsShape=r,this.variableNames=["x","indices"],this.outputShape=n;for(var a=PJ(n.length),i="\n int index;",o=0;o<this.sliceDim;o++)i+="\n index = round(getIndices(coords[0], "+o+"));\n out_of_bounds = out_of_bounds || index < 0;\n out_of_bounds = out_of_bounds || index >= "+this.paramsShape[o]+";\n flattenIndex += index * "+this.strides[o]+";";this.userCode="\n void main() {\n "+a+" coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n\n "+i+"\n\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n "};var p2={kernelName:qy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.params,a=t.indices,i=a.shape,o=i[i.length-1],s=Xv(r.shape),u=QR(r,a),l=u[0],c=u[1],p=u[2],h=u[3],d=i$({inputs:{x:a},backend:n,attrs:{shape:[c,o]}}),f=i$({inputs:{x:r},backend:n,attrs:{shape:[Xv(r.shape)/p,p]}});if(n.shouldExecuteOnCPU([r,a])||"string"===r.dtype){var m=n.readSync(a.dataId),v=n.bufferSync(r),g=FZ(m,v,r.dtype,c,o,p,h,r.shape,s);return n.makeTensorInfo(l,r.dtype,g.values)}var y=new c2(o,h,[c,p],r.shape),b=n.runWebGLProgram(y,[f,d],f.dtype),x=i$({inputs:{x:b},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(b),x}},h2=function(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;var n=PJ(this.rank),r=function(e,t){for(var n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[],a=0;a<e.length;a++)2===a?r.push("index"):r.push(""+n[a]);return r.join()}(e);this.userCode="\n void main() {\n "+n+" resRC = getOutputCoords();\n int index = int(getIndices(resRC.x, resRC.z));\n float inBounds = (index >= 0) && (index < "+e[2]+") ? 1.0 : 0.0;\n setOutput(inBounds * getA("+r+"));\n }\n "};function d2(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.indices,o=r.axis,s=r.batchDims,u=tg(o,a.shape)[0];Fg().get("DEBUG")&&function(){for(var e=n.readSync(i.dataId),t=a.shape[u],r=function(n){var r=e[n];Hv(r<=t-1&&r>=0,(function(){return"GatherV2: the index value "+r+" is not in [0, "+(t-1)+"]"}))},o=0;o<e.length;++o)r(o)}();var l=xF(a,i,u,s),c=Xv(i.shape),p=[],h=i$({inputs:{x:a},backend:n,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),d=i$({inputs:{x:i},backend:n,attrs:{shape:[l.batchSize,c/l.batchSize]}});p.push(h),p.push(d);var f=[l.batchSize,l.outerSize,c/l.batchSize,l.sliceSize];if(n.shouldExecuteOnCPU([a,i])||"string"===a.dtype){var m=n.bufferSync(d),v=n.bufferSync(h),g=OZ(v,m,f);return p.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(l.outputShape,g.dtype,g.values)}var y=new h2(h.shape,f),b=n.runWebGLProgram(y,[h,d],h.dtype);p.push(b);var x=i$({inputs:{x:b},backend:n,attrs:{shape:l.outputShape}});return p.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),x}var f2={kernelName:Hy,backendName:"webgl",kernelFunc:d2},m2=JQ({opSnippet:"return float(a > b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:DZ,dtype:"bool"}),v2={kernelName:Ky,backendName:"webgl",kernelFunc:m2},g2=JQ({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:MZ}),y2={kernelName:Xy,backendName:"webgl",kernelFunc:g2};var b2={kernelName:Jy,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend;return H1(t.input,!0,n)}},x2=YQ({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),w2={kernelName:Qy,backendName:"webgl",kernelFunc:x2},k2=YQ({opSnippet:"return float(isinf(x));",dtype:"bool"}),N2={kernelName:$y,backendName:"webgl",kernelFunc:k2},I2=YQ({opSnippet:"return float(isnan(x));",dtype:"bool"}),S2={kernelName:eb,backendName:"webgl",kernelFunc:I2},T2=JQ({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:LZ,dtype:"bool"}),C2={kernelName:nb,backendName:"webgl",kernelFunc:T2},E2=JQ({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:zZ,dtype:"bool"}),A2={kernelName:rb,backendName:"webgl",kernelFunc:E2};var R2={kernelName:ab,backendName:"webgl",kernelFunc:function(e){var t=e.backend,n=e.attrs,r=n.start,a=n.stop,i=n.num,o=PZ(r,a,i);return t.makeTensorInfo([o.length],"float32",o)}},_2=YQ({opSnippet:"if (isnan(x)) return x;\n return x < 0.0 ? 0./0. : log(x);\n",packedOpSnippet:"\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n",cpuKernelImpl:BZ}),F2={kernelName:ib,backendName:"webgl",kernelFunc:_2},O2=YQ({opSnippet:"if (isnan(x)) return x;\n return log(1.0 + x);\n"}),D2={kernelName:ob,backendName:"webgl",kernelFunc:O2},M2=JQ({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n",dtype:"bool"}),L2={kernelName:sb,backendName:"webgl",kernelFunc:M2},z2=YQ({opSnippet:"return float(!(x >= 1.0));"}),P2={kernelName:ub,backendName:"webgl",kernelFunc:z2},B2=JQ({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n",dtype:"bool"}),W2={kernelName:lb,backendName:"webgl",kernelFunc:B2},V2=function(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[];var i,o=t,s=e[3]-1;this.outputShape=e;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 "},U2=function(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var i,o=t,s=e[3]-1;this.outputShape=e;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 "},G2={kernelName:pb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.depthRadius,o=r.bias,s=r.alpha,u=r.beta,l=Fg().getBool("WEBGL_PACK_NORMALIZATION")?new U2(a.shape,i,o,s,u):new V2(a.shape,i,o,s,u);return n.runWebGLProgram(l,[a],a.dtype)}},j2=function(e,t,n,r,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,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 - "+t+")));\n int depthEnd = int(min(float("+this.depth+"),\n float(d + "+t+" + 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 "},H2={kernelName:hb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.y,o=t.dy,s=r.depthRadius,u=r.bias,l=r.alpha,c=r.beta,p=new j2(a.shape,s,u,l,c);return n.runWebGLProgram(p,[a,i,o],a.dtype)}};function q2(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.reductionIndices,o=r.keepDims,s=a.shape.length,u=tg(i,a.shape),l=u,c=VS(l,s),p=null!=c,h=n.shouldExecuteOnCPU([a]),d=a;if(p){if(h){for(var f=n.texData.get(d.dataId).values,m=new Array(s),v=0;v<m.length;v++)m[v]=a.shape[c[v]];var g=fQ(f,a.shape,a.dtype,c,m);d=n.makeTensorInfo(m,a.dtype),n.texData.get(d.dataId).values=g}else d=h$(a,c,n);l=GS(l.length,s)}WS("max",l,s);var y,b=PS(d.shape,l),x=b[0],w=b[1],k=x;if(o&&(k=BS(x,u)),h){f=n.texData.get(d.dataId).values;var N=WZ(f,Xv(w),k,a.dtype);y=n.makeTensorInfo(k,a.dtype),n.texData.get(y.dataId).values=N}else y=function(e,t,n,r){var a=Xv(t),i=i$({inputs:{x:e},attrs:{shape:[Xv(e.shape)/a,a]},backend:r}),o=l$(i,e.dtype,"max",r),s=i$({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),s}(d,w,k,n);return p&&n.disposeIntermediateTensorInfo(d),y}var K2={kernelName:db,backendName:"webgl",kernelFunc:q2},X2=JQ({opSnippet:"\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return max(a, b);\n",packedOpSnippet:"\n vec4 result = vec4(max(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n \n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:VZ}),Y2={kernelName:fb,backendName:"webgl",kernelFunc:X2};var J2={kernelName:mb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;bJ(a,"maxPool");var i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode;Hv(DI(o,1),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '1'"}));var l=II(a.shape,i,o,1,s,u);if(1===l.filterWidth&&1===l.filterHeight&&Yv(l.inShape,l.outShape))return BQ({inputs:{x:a},backend:n});var c=new J$(l,"max",!1);return n.runWebGLProgram(c,[a],a.dtype)}};var Z2={kernelName:gb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.filterSize,o=r.strides,s=r.pad,u=r.dataFormat,l=r.dimRoundingMode,c=SI(a.shape,i,o,[1,1,1],s,l,u),p=new Z$(c,"max",!1);return n.runWebGLProgram(p,[a],a.dtype)}},Q2=function(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;var t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,i=e.effectiveFilterWidth,o=a-1-e.padInfo.top,s=i-1-e.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) / "+t+".0;\n\n if (dyR < 0.0 || dyR >= "+e.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 >= "+e.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 "},$2=function(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;var t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,i=e.dilationHeight,o=e.dilationWidth,s=e.effectiveFilterDepth,u=e.effectiveFilterHeight,l=e.effectiveFilterWidth,c=s-1-e.padInfo.front,p=u-1-e.padInfo.top,h=l-1-e.padInfo.left,d=s*u*l-1;this.userCode="\n const ivec3 pads = ivec3("+c+", "+p+", "+h+");\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) / "+t+".0;\n\n if (dyD < 0.0 || dyD >= "+e.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 >= "+e.outHeight+".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+l+";\n wC += "+o+") {\n float dyC = float(dyCCorner + wC) / "+r+".0;\n\n if (dyC < 0.0 || dyC >= "+e.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 = "+d+" -\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+" * "+l+" +\n wR * "+l+" + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n "};var e3={kernelName:yb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=r.filterSize,s=r.strides,u=r.pad,l=r.dimRoundingMode,c=SI(i.shape,o,s,[1,1,1],u,l),p=new Z$(c,"max",!0),h=n.runWebGLProgram(p,[i],i.dtype),d=new $2(c),f=n.runWebGLProgram(d,[a,h],i.dtype);return n.disposeIntermediateTensorInfo(h),f}};var t3={kernelName:vb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=i;bJ([i,t.output],"maxPoolGrad");var s=r.filterSize,u=r.strides,l=r.pad,c=r.dimRoundingMode,p=II(o.shape,s,u,1,l,c),h=new J$(p,"max",!0),d=n.runWebGLProgram(h,[o],o.dtype),f=new Q2(p),m=n.runWebGLProgram(f,[a,d],o.dtype);return n.disposeIntermediateTensorInfo(d),m}};var n3={kernelName:bb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=n.filterSize,o=n.strides,s=n.pad,u=n.includeBatchInIndex,l=r;Hv(4===a.shape.length,(function(){return"Error in maxPool: input must be rank 4 but got rank "+a.shape.length+"."}));var c=[1,1];Hv(DI(o,c),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+c+"'"}));var p=II(a.shape,i,o,c,s),h=function(e,t,n,r){var a=new J$(n,"max",!1),i=r.runWebGLProgram(a,[e],"float32");return a=new J$(n,"max",!0,!0,t),[i,r.runWebGLProgram(a,[e],"float32")]}(a,u,p,l);return[h[0],h[1]]}};var r3={kernelName:xb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=n.keepDims,o=n.axis,s=r,u=a.shape.length,l=tg(o,a.shape),c=l,p=VS(c,u),h=null!=p,d=s.shouldExecuteOnCPU([a]),f=[],m=a;if(h){if(d){for(var v=s.texData.get(m.dataId).values,g=new Array(u),y=0;y<g.length;y++)g[y]=a.shape[p[y]];var b=fQ(v,a.shape,a.dtype,p,g);m=s.makeTensorInfo(g,a.dtype),s.texData.get(m.dataId).values=b}else m=h$(a,p,s);f.push(m),c=GS(c.length,u)}WS("sum",c,u);var x=PS(m.shape,c),w=x[0],k=x[1],N=w;i&&(N=BS(w,l));for(var I=function(e,t,n,r){var a=Xv(t),i=i$({inputs:{x:e},attrs:{shape:[Xv(e.shape)/a,a]},backend:r}),o=l$(i,"float32","mean",r),s=i$({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),s}(m,k,N,s),S=0,T=f;S<T.length;S++){y=T[S];s.disposeIntermediateTensorInfo(y)}return I}};var a3={kernelName:wb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims,s=a.shape.length,u=tg(i,a.shape),l=u,c=VS(l,s),p=a;null!=c&&(p=m$({inputs:{x:a},backend:n,attrs:{perm:c}}),l=GS(l.length,a.shape.length)),WS("min",l,s);var h,d=PS(p.shape,l),f=d[0],m=i$({inputs:{x:p},backend:n,attrs:{shape:[-1,Xv(d[1])]}}),v=l$(m,m.dtype,"min",n);return h=i$(o?{inputs:{x:v},backend:n,attrs:{shape:BS(f,u)}}:{inputs:{x:v},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),null!=c&&n.disposeIntermediateTensorInfo(p),h}},i3=JQ({opSnippet:"\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return min(a, b);\n",packedOpSnippet:"\n vec4 result = vec4(min(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n \n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:UZ}),o3={kernelName:kb,backendName:"webgl",kernelFunc:i3},s3=function(e,t,n){this.variableNames=["x"],this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));var r=e.length,a=PJ(r),i=t.map((function(e){return e[0]})).join(","),o=t.map((function(t,n){return t[0]+e[n]})).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u="reflect"===n?0:1;this.userCode=1!==r?"\n "+a+" start = "+a+"("+i+");\n "+a+" end = "+a+"("+o+");\n\n void main() {\n "+a+" outC = getOutputCoords();\n for (int i = 0; i < "+r+"; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - "+u+";\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + "+u+";\n }\n }\n "+a+" coords = outC - start;\n setOutput(getX("+s+"));\n }\n ":"\n int start = "+i+";\n int end = "+o+";\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - "+u+";\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + "+u+";\n }\n setOutput(getX(outC - start));\n }\n "},u3=function(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));var r=e.length,a=PJ(r),i=t.map((function(e){return e[0]})).join(","),o=t.map((function(t,n){return t[0]+e[n]})).join(","),s=gQ("rc",r),u=gQ("source",r),l=s[r-1]+" < "+this.outputShape[r-1],c=1===r?"source":"vec2("+u.slice(-2).join()+")",p="reflect"===n?0:1,h="";if(1===r){var d="\n "+a+" source = rc;\n if (source < start) {\n source = start * 2 - source - "+p+";\n } else if (source >= end) {\n source = (end - 1) * 2 - source + "+p+";\n }\n source -= start;\n ";h="\n "+a+" rc = outputLoc;\n "+d+"\n result[0] = getChannel(getX("+u.join()+"), "+c+");\n "+s[r-1]+" += 1;\n if("+l+") {\n "+d+"\n result[1] = getChannel(getX("+u.join()+"), "+c+");\n }\n "}else{var f="\n "+a+" source = rc;\n "+a+" lt = "+a+"(lessThan(source, start));\n "+a+" gte = "+a+"(greaterThanEqual(source, end));\n "+a+" orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - "+p+") +\n gte * ((end - 1) * 2 - source + "+p+");\n source -= start;\n ";h="\n "+a+" rc = outputLoc;\n "+f+"\n result[0] = getChannel(getX("+u.join()+"), "+c+");\n "+s[r-1]+" += 1;\n if("+l+") {\n "+f+"\n result[1] = getChannel(getX("+u.join()+"), "+c+");\n }\n rc = outputLoc;\n "+s[r-2]+" += 1;\n if("+s[r-2]+" < "+this.outputShape[r-2]+") {\n "+f+"\n result[2] = getChannel(getX("+u.join()+"), "+c+");\n "+s[r-1]+" += 1;\n if("+l+") {\n "+f+"\n result[3] = getChannel(getX("+u.join()+"), "+c+");\n }\n }\n "}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 "+h+"\n setOutput(result);\n }\n "},l3={kernelName:Nb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.paddings,o=r.mode,s=Fg().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new u3(a.shape,i,o):new s3(a.shape,i,o);return n.runWebGLProgram(s,[a],a.dtype)}},c3=JQ({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\n vec4 result = mod(a, b);\n bvec4 isNaN = equal(b, vec4(0.0));\n \n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n\n return result;\n"}),p3={kernelName:Ib,backendName:"webgl",kernelFunc:c3},h3=function(e,t,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,n],this.userCode="\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 < "+(t-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("+(t-1)+"));\n }\n "},d3=JQ({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\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",checkOutOfBounds:!0}),f3={kernelName:Ry,backendName:"webgl",kernelFunc:d3},m3="return a - b;",v3=JQ({opSnippet:m3,packedOpSnippet:m3,supportsComplex:!0,cpuKernelImpl:pQ}),g3={kernelName:Ax,backendName:"webgl",kernelFunc:v3};function y3(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,i=tg([r.dim],a.shape),o=q2({inputs:{x:a},backend:n,attrs:{reductionIndices:i,keepDims:!1}}),s=BS(o.shape,i),u=i$({inputs:{x:o},backend:n,attrs:{shape:s}}),l=v3({inputs:{a:a,b:u},backend:n}),c=z1({inputs:{x:l},backend:n}),p=d$({inputs:{x:c},backend:n,attrs:{axis:i,keepDims:!1}}),h=i$({inputs:{x:p},backend:n,attrs:{shape:s}}),d=d3({inputs:{a:c,b:h},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),d}var b3={kernelName:vx,backendName:"webgl",kernelFunc:y3};var x3={kernelName:Sb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,i=r.numSamples,o=r.seed,s=r.normalized,u=s?a:y3({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),l=u.shape[0],c=u.shape[1],p=new h3(l,c,i),h=[[o]],d=n.runWebGLProgram(p,[u],"int32",h);return s||n.disposeIntermediateTensorInfo(u),d}};var w3={kernelName:Cb,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=n.x;if(r.shouldExecuteOnCPU([a])){var i=r.texData.get(a.dataId),o=jZ(i.values,a.shape,a.dtype),s=o[0],u=o[1];return r.makeTensorInfo(u,a.dtype,s)}return t=Fg().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new EQ(a.shape,"\n vec4 result = -x;\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"):new IQ(a.shape,"if (isnan(x)) return x;\n return -x;\n"),r.runWebGLProgram(t,[a],a.dtype)}},k3=gA;var N3={kernelName:Ab,backendName:"webgl",kernelFunc:function(e){qx("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=n.readSync(a.dataId),c=n.readSync(i.dataId),p=k3(l,c,o,s,u).selectedIndices;return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},I3=yA;var S3={kernelName:Rb,backendName:"webgl",kernelFunc:function(e){qx("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=r.padToMaxOutputSize,c=n.readSync(a.dataId),p=n.readSync(i.dataId),h=I3(c,p,o,s,u,l),d=h.selectedIndices,f=h.validOutputs;return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([f]))]}},T3=bA;var C3={kernelName:_b,backendName:"webgl",kernelFunc:function(e){qx("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=r.softNmsSigma,c=n.readSync(a.dataId),p=n.readSync(i.dataId),h=T3(c,p,o,s,u,l),d=h.selectedIndices,f=h.selectedScores;return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([f.length],"float32",new Float32Array(f))]}},E3=function(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],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 "},A3={kernelName:Ob,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,i=r.dtype,o=r.depth,s=r.onValue,u=r.offValue,l=Xv(a.shape),c=new E3(l,o,s,u),p=i$({inputs:{x:a},backend:n,attrs:{shape:[l]}}),h=n.runWebGLProgram(c,[p],i);n.disposeIntermediateTensorInfo(p);var d=i$({inputs:{x:h},backend:n,attrs:{shape:[].concat(a.shape,[o])}});return n.disposeIntermediateTensorInfo(h),d}};function R3(e){var t=e.inputs,n=e.backend,r=t.x;if("complex64"===r.dtype){var a=y0({inputs:{input:r},backend:n}),i=R3({inputs:{x:a},backend:n}),o=O0({inputs:{input:r},backend:n}),s=R3({inputs:{x:o},backend:n}),u=VQ({inputs:{real:i,imag:s},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}return X1({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}var _3={kernelName:Bx,backendName:"webgl",kernelFunc:R3};var F3={kernelName:Fb,backendName:"webgl",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=n.x;if("string"===a.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===a.dtype){var i=y0({inputs:{input:a},backend:r}),o=e({inputs:{x:i},backend:r}),s=O0({inputs:{input:a},backend:r}),u=R3({inputs:{x:s},backend:r}),l=VQ({inputs:{real:o,imag:u},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(u),l}return X1({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:r})}};var O3={kernelName:Db,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs.axis;if(1===t.length)return B1({inputs:{input:t[0]},backend:n,attrs:{dim:r}});var a=t[0].shape,i=t[0].dtype;t.forEach((function(e){qv(a,e.shape,"All tensors passed to stack must have matching shapes"),Hv(i===e.dtype,(function(){return"All tensors passed to stack must have matching dtypes"}))}));var o=[],s=L0({inputs:t.map((function(e){var t=B1({inputs:{input:e},backend:n,attrs:{dim:r}});return o.push(t),t})),backend:n,attrs:{axis:r}});return o.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),s}},D3=function(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));var r=e.length,a=PJ(r),i=t.map((function(e){return e[0]})).join(","),o=t.map((function(t,n){return t[0]+e[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(value);\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(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n "},M3=function(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));for(var r=e.length,a=PJ(r),i=t.map((function(e){return e[0]})).join(","),o=t.map((function(t,n){return t[0]+e[n]})).join(","),s=gQ("rc",r),u=gQ("source",r),l=s[r-1]+" < "+this.outputShape[r-1],c=1===r?"source":"vec2("+u.slice(-2).join()+")",p=[a+" rc = outputLoc;",s[r-1]+" += 1;\n if("+l+") {\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("+l+") {"],h=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",d="",f=0,m=1===r?2:4;f<m;f++)d+="\n "+p[f]+"\n if ("+h+") {\n result["+f+"] = float(value);\n } else {\n "+a+" source = rc - start;\n result["+f+"] = getChannel(getX("+u.join()+"), "+c+");\n }\n ";d+=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 "+d+"\n setOutput(result);\n }\n "},L3=function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.paddings,o=r.constantValue;if(0===Xv(a.shape)){var s=i.map((function(e,t){return e[0]+a.shape[t]+e[1]}));return X1({backend:n,attrs:{shape:s,value:o,dtype:a.dtype}})}var u=Fg().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new M3(a.shape,i,o):new D3(a.shape,i,o),l=[[o]];return n.runWebGLProgram(u,[a],a.dtype,l)},z3={kernelName:Mb,backendName:"webgl",kernelFunc:L3},P3=JQ({opSnippet:"\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",packedOpSnippet:"\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 bvec4 isNaN1 = lessThan(a, vec4(0.0));\n bvec4 isNaN2 = lessThan(floor(b), b);\n bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w);\n \n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n\n return result;\n"}),B3={kernelName:Lb,backendName:"webgl",kernelFunc:P3};var W3={kernelName:Pb,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.axis,s=a.keepDims,u=i.shape.length,l=[],c=tg(o,i.shape),p=c,h=VS(p,u),d=i;if(null!=h&&(d=m$({inputs:{x:i},backend:r,attrs:{perm:h}}),p=GS(p.length,u),l.push(d)),WS("prod",p,u),r.shouldExecuteOnCPU([d])){var f=r.texData.get(d.dataId).values,m=qZ(d.shape,d.dtype,f,p),v=m.outVals,g=m.outShape,y=m.outDtype;t=r.makeTensorInfo(g,y,v)}else{var b=PS(d.shape,p),x=b[0],w=Xv(b[1]),k=i$({inputs:{x:d},backend:r,attrs:{shape:[-1,w]}}),N=l$(k,fk(i.dtype),"prod",r);t=i$({inputs:{x:N},backend:r,attrs:{shape:x}}),l.push(k),l.push(N)}if(s){l.push(t);var I=BS(t.shape,c);t=i$({inputs:{x:t},backend:r,attrs:{shape:I}})}return l.forEach((function(e){return r.disposeIntermediateTensorInfo(e)})),t}};var V3={kernelName:Bb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.paramsNestedSplits,i=t.paramsDenseValues,o=t.indices,s=r.outputRaggedRank,u=a.map((function(e){return n.readSync(e.dataId)})),l=a.map((function(e){return e.shape})),c=n.readSync(i.dataId),p=n.readSync(o.dataId),h=KZ(u,l,c,i.shape,i.dtype,p,o.shape,s),d=h[0],f=h[1],m=h[2],v=d.map((function(e){return n.makeTensorInfo([e.length],"int32",e)})),g=n.makeTensorInfo(m,i.dtype,f);return v.concat([g])}};var U3={kernelName:Wb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.starts,a=t.limits,i=t.deltas,o=n.readSync(r.dataId),s=n.readSync(a.dataId),u=n.readSync(i.dataId),l=XZ(o,r.shape,r.dtype,s,a.shape,u,i.shape),c=l[0],p=l[1];return[n.makeTensorInfo([c.length],"int32",c),n.makeTensorInfo([p.length],r.dtype,p)]}};var G3={kernelName:Vb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.shape,i=t.values,o=t.defaultValue,s=t.rowPartitionTensors,u=r.rowPartitionTypes,l=n.readSync(a.dataId),c=n.readSync(i.dataId),p=n.readSync(o.dataId),h=s.map((function(e){return n.readSync(e.dataId)})),d=s.map((function(e){return e.shape})),f=YZ(l,a.shape,c,i.shape,i.dtype,p,o.shape,h,d,u),m=f[0],v=f[1];return n.makeTensorInfo(m,i.dtype,v)}},j3=function(e){var t=e.backend,n=e.attrs,r=n.start,a=n.stop,i=n.step,o=n.dtype,s=JZ(r,a,i,o);return t.makeTensorInfo([s.length],o,s)},H3={kernelName:Ub,backendName:"webgl",kernelFunc:j3},q3=YQ({opSnippet:"return 1.0 / x;"}),K3={kernelName:jb,backendName:"webgl",kernelFunc:q3},X3=YQ({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\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"}),Y3={kernelName:Hb,backendName:"webgl",kernelFunc:X3},J3=YQ({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\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"}),Z3={kernelName:Zb,backendName:"webgl",kernelFunc:J3},Q3=function(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3];this.outputShape=[i,t,n,u];var l,c=[r&&t>1?o-1:o,r&&n>1?s-1:s],p=[r&&t>1?t-1:t,r&&n>1?n-1:n];l=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+c[0]/p[0]+",\n "+c[1]/p[1]+");\n const vec2 inputShapeRC = vec2("+o+".0, "+s+".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 = "+l+";\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\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 "},$3=function(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3];this.outputShape=[i,t,n,u];var l,c=[r&&t>1?o-1:o,r&&n>1?s-1:s],p=[r&&t>1?t-1:t,r&&n>1?n-1:n];l=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n "+c[0]/p[0]+",\n "+c[1]/p[1]+",\n "+c[1]/p[1]+");\n const vec3 inputShapeRC = vec3("+o+".0, "+s+".0,\n "+s+".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 = "+l+";\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\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 < "+(u-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 "};var e4={kernelName:Yb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=r.alignCorners,o=r.halfPixelCenters,s=r.size,u=s[0],l=s[1],c=Fg().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new $3(a.shape,u,l,i,o):new Q3(a.shape,u,l,i,o);return n.runWebGLProgram(c,[a],"float32")}},t4=function(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;var r=t[1],a=t[2],i=e[1],o=e[2],s=[n&&i>1?r-1:r,n&&o>1?a-1:a],u=[n&&i>1?i-1:i,n&&o>1?o-1:o],l=s[0]/u[0],c=s[1]/u[1],p=1/l,h=1/c,d=2*Math.ceil(p)+2,f=2*Math.ceil(h)+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("+l+");\n const float widthScale = float("+c+");\n\n const float invHeightScale = float("+p+");\n const float invWidthScale = float("+h+");\n\n const int winHeight = int("+d+");\n const int winWidth = int("+f+");\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 >= "+i+") {\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 >= "+o+") {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), "+(r-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), "+(a-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 "};var n4={kernelName:Jb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=t.dy,o=r.alignCorners,s=new t4(i.shape,a.shape,o);return n.runWebGLProgram(s,[i],i.dtype)}},r4=function(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3];this.outputShape=[i,t,n,u];var l,c=[r&&t>1?o-1:o,r&&n>1?s-1:s],p=[r&&t>1?t-1:t,r&&n>1?n-1:n],h=r?"0.5":"0.0";l=a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+c[0]/p[0]+",\n "+c[1]/p[1]+");\n const vec2 inputShapeRC = vec2("+o+".0, "+s+".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 = "+l+";\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + "+h+")));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n "},a4=function(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3];this.outputShape=[i,t,n,u];var l,c=[r&&t>1?o-1:o,r&&n>1?s-1:s],p=[r&&t>1?t-1:t,r&&n>1?n-1:n],h=r?"0.5":"0.0";l=a?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n "+c[0]/p[0]+",\n "+c[1]/p[1]+",\n "+c[1]/p[1]+");\n const vec3 inputShapeRC = vec3("+o+".0, "+s+".0,\n "+s+".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 = "+l+";\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + "+h+")));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < "+(u-1)+";\n bool hasNextRow = coords.z < "+(n-1)+";\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n "};var i4={kernelName:Kb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=r.alignCorners,o=r.halfPixelCenters,s=r.size,u=s[0],l=s[1],c=Fg().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new a4(a.shape,u,l,i,o):new r4(a.shape,u,l,i,o);return n.runWebGLProgram(c,[a],a.dtype)}},o4=function(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;var r=t[1],a=t[2],i=e[1],o=e[2],s=[n&&i>1?r-1:r,n&&o>1?a-1:a],u=[n&&i>1?i-1:i,n&&o>1?o-1:o],l=s[0]/u[0],c=s[1]/u[1],p=1/l,h=1/c,d=2*Math.ceil(p)+2,f=2*Math.ceil(h)+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("+l+");\n const float widthScale = float("+c+");\n\n const float invHeightScale = float("+p+");\n const float invWidthScale = float("+h+");\n\n const int winHeight = int("+d+");\n const int winWidth = int("+f+");\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 >= "+i+") {\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 >= "+o+") {\n continue;\n }\n\n float sourceFracRow =\n float("+s[0]+") *\n (float(dyR) / float("+u[0]+"));\n\n float sourceFracCol =\n float("+s[1]+") *\n (float(dyC) / float("+u[1]+"));\n\n int sourceNearestRow = int(min(\n float(int("+r+") - 1),\n "+n+" ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int("+a+") - 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 "};var s4={kernelName:Xb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=t.dy,o=r.alignCorners,s=new o4(i.shape,a.shape,o);return n.runWebGLProgram(s,[i],i.dtype)}},u4=function(e,t){this.variableNames=["x"];var n=e.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");if(this.outputShape=e,1!==n){var r=e.map((function(n,r){return function(n){return-1!==t.indexOf(n)&&1!==e[n]?e[n]+" - coords["+n+"] - 1":"coords["+n+"]"}(r)})).join(","),a=PJ(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("+e[0]+" - coord - 1));\n }\n "},l4=function(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var n=e.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");this.outputShape=e;var r=gQ("rc",n),a=r[n-1]+" + 1 < "+this.outputShape[n-1],i=r[n-2]+" + 1 < "+this.outputShape[n-2],o=PJ(n);function s(n){var r=e.map((function(r,a){return function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?e[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("+e[0]+" - rc - 1),\n "+e[0]+" - rc - 1);\n if("+a+"){\n result.g = getChannel(getX("+e[0]+" - (rc + 1) - 1),\n "+e[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(e){return s(e)}(r.slice())+";\n if("+a+"){\n result.g = "+function(e){return e[n-1]="("+e[n-1]+" + 1)",s(e)}(r.slice())+";\n }\n if("+i+") {\n result.b = "+function(e){return e[n-2]="("+e[n-2]+" + 1)",s(e)}(r.slice())+";\n if("+a+") {\n result.a = "+function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",s(e)}(r.slice())+";\n }\n }\n setOutput(result);\n }\n "};var c4={kernelName:Qb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.dims,o=a.shape.length,s=tg(i,a.shape);if(0===o)return BQ({inputs:{x:a},backend:n});var u=Fg().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new l4(a.shape,s):new u4(a.shape,s);return n.runWebGLProgram(u,[a],a.dtype)}},p4=function(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];var n=e[1],r=e[2];this.outputShape=e;var a="";a="number"==typeof t?"float outputValue = "+t.toFixed(2)+";":"\n vec3 fill = vec3("+t.join(",")+");\n float outputValue = fill[coords[3]];",this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n "+a+"\n if(coordX >= 0 && coordX < "+r+" && coordY >= 0 && coordY < "+n+") {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n "},h4={kernelName:Ux,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.image,i=n.radians,o=n.fillValue,s=n.center,u=r,l=new p4(a.shape,o),c=A_(s,a.shape[1],a.shape[2]),p=[[c[0],c[1],Math.sin(i),Math.cos(i)]];return u.runWebGLProgram(l,[a],a.dtype,p)}},d4=YQ({opSnippet:"\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"}),f4={kernelName:$b,backendName:"webgl",kernelFunc:d4},m4=YQ({opSnippet:"return inversesqrt(x);",cpuKernelImpl:ZZ}),v4={kernelName:ex,backendName:"webgl",kernelFunc:m4},g4=function(e,t,n,r,a,i,o,s){void 0===o&&(o=!0),void 0===s&&(s=!1),this.variableNames=["updates","indices","defaultValue"],this.outputShape=i;var u=PJ(a.length),l=PJ(i.length),c="";1===n?c="i":2===n&&(c="i, j");var p="getIndices("+c+")",h="";1===r?h="i":2===r&&(h="i, coords[1]");var d="getUpdates("+h+")",f="";s&&(f="coords[0], coords[1]");var m="getDefaultValue("+f+")",v=t>1?"strides[j]":"strides";this.userCode="\n "+u+" strides = "+u+"("+a+");\n\n void main() {\n "+l+" coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < "+e+"; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < "+t+"; j++) {\n int index = round("+p+");\n flattenedIndex += index * "+v+";\n }\n if (flattenedIndex == coords[0]) {\n sum += "+d+";\n found = true;\n }\n }\n setOutput(mix("+m+", sum, float(found)));\n }\n "},y4=function(e,t,n,r,a,i,o,s){void 0===o&&(o=!0),void 0===s&&(s=!1),this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i;var u=PJ(a.length),l=PJ(i.length),c="";1===n?c="i":2===n&&(c="i, j");var p="getIndices("+c+")",h="";1===r?h="i":2===r&&(h="i, coords[1]");var d="getUpdates("+h+")",f="";s&&(f="coords[0], coords[1]");var m="getDefaultValue("+f+")",v=t>1?"strides[j]":"strides",g=t>1?"strides[j + 1]":"strides";this.userCode="\n "+u+" strides = "+u+"("+a+");\n\n void main() {\n "+l+" coords = getOutputCoords();\n vec4 sum = vec4(0.);\n vec4 found = vec4(0.);\n for (int i = 0; i < "+e+"; i+=2) {\n ivec2 flattenedIndex = ivec2(0);\n for (int j = 0; j < "+t+"; j+=2) {\n ivec4 index = round("+p+");\n flattenedIndex += index.xz * "+v+";\n if (j + 1 < "+t+") {\n flattenedIndex += index.yw * "+g+";\n }\n }\n if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] ||\n flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) {\n vec4 updVals = "+d+";\n if (flattenedIndex[0] == coords[0]) {\n sum.xy += updVals.xy;\n found.xy = vec2(1.);\n } else if (flattenedIndex[0] == coords[0] + 1) {\n sum.zw += updVals.xy;\n found.zw = vec2(1.);\n }\n if (flattenedIndex[1] == coords[0]) {\n sum.xy += updVals.zw;\n found.xy = vec2(1.);\n } else if (flattenedIndex[1] == coords[0] + 1) {\n sum.zw += updVals.zw;\n found.zw = vec2(1.);\n }\n }\n }\n setOutput(mix("+m+", sum, found));\n }\n "};var b4={kernelName:tx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,i=t.updates,o=r.shape,s=NE(0,a,o),u=s.sliceRank,l=s.numUpdates,c=s.sliceSize,p=s.strides,h=s.outputSize,d=[h/c,c];if(0===h)return n.makeTensorInfo(o,a.dtype);var f,m=i$({inputs:{x:a},backend:n,attrs:{shape:[l,u]}}),v=i$({inputs:{x:i},backend:n,attrs:{shape:[l,c]}}),g=n.makeTensorInfo([],"float32",new Float32Array([0]));f=Fg().getBool("WEBGL_PACK")?new y4(l,u,m.shape.length,v.shape.length,p,d):new g4(l,u,m.shape.length,v.shape.length,p,d);var y=n.runWebGLProgram(f,[v,m,g],v.dtype),b=i$({inputs:{x:y},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(g),b}},x4=function(e,t,n,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,n];var a="for (int i = 0; i < "+Math.ceil(Math.log2(t+1))+"; ++i) { if (left >= right) break;",i=2===Fg().getNumber("WEBGL_VERSION")?"while (left < right) {":a,o="left"===r?"<":"<=";this.userCode="\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n "+i+"\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) "+o+" value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n "};var w4={kernelName:rx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.sortedSequence,i=t.values,o=r.side,s=new x4(a.shape[0],a.shape[1],i.shape[1],o),u=[[a.shape[1]]];return n.runWebGLProgram(s,[a,i],"int32",u)}},k4=function(e,t,n){var r,a;if(this.variableNames=["c","a","b"],this.outputShape=t,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<t.length;u++)s.push(""+i[u]),u<e&&o.push(""+i[u]);r=o.join(),a=s.join()}var l=PJ(n);this.userCode="\n void main() {\n "+l+" 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 "};var N4={kernelName:ax,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.condition,a=t.t,i=t.e,o=new k4(r.shape.length,a.shape,a.shape.length);return n.runWebGLProgram(o,[r,a,i],dk(a.dtype,i.dtype))}},I4=YQ({opSnippet:"\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"}),S4={kernelName:ix,backendName:"webgl",kernelFunc:I4},T4=YQ({opSnippet:"if (isnan(x)) return x;\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\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",cpuKernelImpl:$Z}),C4={kernelName:cx,backendName:"webgl",kernelFunc:T4},E4=YQ({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),A4={kernelName:lx,backendName:"webgl",kernelFunc:E4},R4=YQ({opSnippet:"if (isnan(x)) return x;\n return sin(x);\n",packedOpSnippet:"\n vec4 result = sin(x);\n bvec4 isNaN = isnan(x);\n \n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n\n return result;\n"}),_4={kernelName:sx,backendName:"webgl",kernelFunc:R4},F4=YQ({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),O4={kernelName:ux,backendName:"webgl",kernelFunc:F4},D4=YQ({opSnippet:"\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"}),M4={kernelName:px,backendName:"webgl",kernelFunc:D4},L4={kernelName:fx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockShape,o=r.paddings;Hv(a.shape.length<=4,(function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"}));var s=i.reduce((function(e,t){return e*t})),u=[[0,0]];u.push.apply(u,o);for(var l=1+i.length;l<a.shape.length;++l)u.push([0,0]);var c=[],p=L3({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),h=R_(p.shape,i,s,!1),d=__(h.length,i.length,!1),f=F_(p.shape,i,s,!1),m=i$({inputs:{x:p},backend:n,attrs:{shape:h}}),v=m$({inputs:{x:m},backend:n,attrs:{perm:d}}),g=i$({inputs:{x:v},backend:n,attrs:{shape:f}});return c.push(p),c.push(m),c.push(v),c.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),g}};var z4={kernelName:gx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.indices,a=t.values,i=t.denseShape,o=t.defaultValue;if(1!==i.shape.length)throw new Error("Dense shape must be a vector, saw:\n "+i.shape);if(2!==r.shape.length)throw new Error("Indices must be a matrix, saw:\n "+r.shape);if(1!==a.shape.length)throw new Error("Values must be a vector, saw:\n "+a.shape);if(0!==o.shape.length)throw new Error("Default value must be a scalar, saw:\n "+o.shape);var s=n.readSync(r.dataId),u=n.readSync(a.dataId),l=n.readSync(i.dataId),c=n.readSync(o.dataId)[0],p=nQ(s,r.shape,r.dtype,u,a.dtype,l,c),h=p[0],d=p[1],f=p[2],m=p[3],v=p[4];return[n.makeTensorInfo(d,r.dtype,h),n.makeTensorInfo([d[0]],a.dtype,f),n.makeTensorInfo([m.length],"bool",new Uint8Array(m.map((function(e){return Number(e)})))),n.makeTensorInfo([v.length],r.dtype,new Int32Array(v))]}};var P4={kernelName:yx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.inputIndices,a=t.inputShape,i=t.newShape;if(2!==r.shape.length)throw new Error("Input indices should be a matrix but received shape "+r.shape);if(1!==a.shape.length)throw new Error("Input shape should be a vector but received shape "+a.shape);if(1!==i.shape.length)throw new Error("Target shape should be a vector but received shape "+i.shape);var o=Array.from(n.readSync(a.dataId)),s=n.readSync(r.dataId),u=Array.from(n.readSync(i.dataId)),l=rQ(s,r.shape,r.dtype,o,u),c=l[0],p=l[1],h=l[2];return[n.makeTensorInfo(p,r.dtype,c),n.makeTensorInfo([h.length],i.dtype,new Int32Array(h))]}};var B4={kernelName:bx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.data,a=t.indices,i=t.segmentIds;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error("Indices should be a vector but received shape\n "+a.shape);if(1!==i.shape.length)throw new Error("Segment ids should be a vector but received shape\n "+i.shape);var o=n.readSync(r.dataId),s=n.readSync(a.dataId),u=n.readSync(i.dataId),l=aQ(o,r.shape,r.dtype,s,u,!0),c=l[0],p=l[1];return n.makeTensorInfo(p,r.dtype,c)}};var W4={kernelName:xx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.data,a=t.indices,i=t.segmentIds;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error("Indices should be a vector but received shape\n "+a.shape);if(1!==i.shape.length)throw new Error("Segment ids should be a vector but received shape\n "+i.shape);var o=n.readSync(r.dataId),s=n.readSync(a.dataId),u=n.readSync(i.dataId),l=aQ(o,r.shape,r.dtype,s,u),c=l[0],p=l[1];return n.makeTensorInfo(p,r.dtype,c)}};var V4={kernelName:wx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.sparseIndices,i=t.sparseValues,o=t.defaultValue,s=r.outputShape,u=NE(0,a,s),l=u.sliceRank,c=u.numUpdates,p=u.sliceSize,h=u.strides,d=u.outputSize;if("string"===i.dtype){var f=n.bufferSync(a),m=n.bufferSync(i),v=jw(n.readSync(o.dataId)[0]),g=QZ(f,m,s,d,p,c,l,h,v,false);return n.makeTensorInfo(s,g.dtype,g.values)}var y=new g4(c,l,a.shape.length,i.shape.length,h,[d,1],false),b=n.runWebGLProgram(y,[i,a,o],i.dtype),x=i$({inputs:{x:b},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(b),x}};var U4={kernelName:mx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.numOrSizeSplits,o=tg(r.axis,a.shape)[0],s=iF(a,i,o),u=a.shape.length,l=new Array(u).fill(0),c=a.shape.slice();return s.map((function(e){var t=[].concat(c);t[o]=e;var r=p0({inputs:{x:a},backend:n,attrs:{begin:l,size:t}});return l[o]+=e,r}))}},G4="return sqrt(x);",j4=YQ({opSnippet:G4,packedOpSnippet:G4,cpuKernelImpl:iQ}),H4={kernelName:hx,backendName:"webgl",kernelFunc:j4},q4={kernelName:Nx,backendName:"webgl",kernelFunc:YQ({opSnippet:"return x * x;"})},K4="return (a - b) * (a - b);",X4=JQ({opSnippet:K4,packedOpSnippet:K4}),Y4={kernelName:kx,backendName:"webgl",kernelFunc:X4};var J4={kernelName:Ix,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;if("string"!==a.dtype)throw new Error("Input must be of datatype string");var i=wF(n.readSync(a.dataId)),o=oQ(i,"string",r);return n.makeTensorInfo(a.shape,"string",o)}};var Z4={kernelName:Wx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=SQ+"\n return x > 0.0 ? 1.0 : float("+n.alpha+");\n ",o=new IQ(a.shape,i);return r.runWebGLProgram(o,[a],a.dtype)}},Q4=function(e,t,n){this.variableNames=["x"],this.outputShape=n;var r=n.length,a=PJ(n.length),i=PJ(n.length),o="";if(1===r)o="coords * strides + begin";else{var s=0;o=n.map((function(e,t){return s++,1===n.length?"coords * strides["+t+"] + begin["+t+"]":"coords["+(s-1)+"] * strides["+t+"] + begin["+t+"]"})).join(",")}this.userCode="\n "+a+" begin = "+a+"("+e+");\n "+a+" strides = "+a+"("+t+");\n\n void main() {\n "+i+" coords = getOutputCoords();\n setOutput(getX("+o+"));\n }\n "};var $4={kernelName:Sx,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.begin,s=a.end,u=a.strides,l=a.beginMask,c=a.endMask,p=a.ellipsisMask,h=a.newAxisMask,d=a.shrinkAxisMask,f=d_(i.shape,o,s,u,l,c,p,h,d),m=f.finalShapeSparse,v=f.finalShape,g=f.isIdentity,y=f.sliceDim0,b=f.isSimpleSlice,x=f.begin,w=f.end,k=f.strides;if(g)t=i$({inputs:{x:i},backend:r,attrs:{shape:v}});else if(y||b){Hv(i.shape.length>=1,(function(){return"Input must have rank at least 1, got: "+i.shape.length}));var N=t_(x,w,k),I=p0({inputs:{x:i},backend:r,attrs:{begin:x,size:N}});t=i$({inputs:{x:I},backend:r,attrs:{shape:v}}),r.disposeIntermediateTensorInfo(I)}else{if(r.shouldExecuteOnCPU([i])){var S=r.readSync(i.dataId),T=KN(i.shape,i.dtype,S),C=sQ(m,T,k,x);t=r.makeTensorInfo(v,i.dtype,C.values)}else{var E=new Q4(x,k,m);t=r.runWebGLProgram(E,[i],i.dtype)}}var A=i$({inputs:{x:t},backend:r,attrs:{shape:v}});return r.disposeIntermediateTensorInfo(t),A}};var e6={kernelName:Tx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=r.separator,i=r.nGramWidths,o=r.leftPad,s=r.rightPad,u=r.padWidth,l=r.preserveShortSequences,c=t.data,p=t.dataSplits,h=n.readSync(c.dataId),d=n.readSync(p.dataId),f=uQ(h,d,a,i,o,s,u,l),m=f[0],v=f[1];return[n.makeTensorInfo([m.length],"string",m),n.makeTensorInfo(p.shape,"int32",v)]}};var t6={kernelName:Cx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs.skipEmpty,a=t.input,i=t.delimiter;if("string"!==a.dtype)throw new Error("Input must be of datatype string");if(1!==a.shape.length)throw new Error("Input must be a vector, got shape: "+a.shape);if(0!==i.shape.length)throw new Error("Delimiter must be a scalar, got shape: "+i.shape);var o=n.readSync(a.dataId),s=n.readSync(i.dataId)[0],u=lQ(o,s,r),l=u[0],c=u[1],p=u[2],h=c.length;return[n.makeTensorInfo([h,2],"int32",l),n.makeTensorInfo([h],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};var n6={kernelName:Ex,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs.numBuckets,a=t.input;if("string"!==a.dtype)throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");var i=n.readSync(a.dataId),o=cQ(i,r);return n.makeTensorInfo(a.shape,"int32",o)}},r6=YQ({opSnippet:"return tan(x);"}),a6={kernelName:Rx,backendName:"webgl",kernelFunc:r6},i6=YQ({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"});var o6={kernelName:nx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.tensor,i=t.indices,o=t.updates;!function(e){if(null==e)throw new TypeError("Cannot destructure undefined")}(r);var s=NE(0,i,a.shape),u=s.sliceRank,l=s.numUpdates,c=s.sliceSize,p=s.strides,h=s.outputSize,d=[h/c,c];if(0===h)return n.makeTensorInfo(a.shape,i.dtype);var f=i$({inputs:{x:i},backend:n,attrs:{shape:[l,u]}}),m=i$({inputs:{x:o},backend:n,attrs:{shape:[l,c]}}),v=i$({inputs:{x:a},backend:n,attrs:{shape:d}}),g=new g4(l,u,f.shape.length,m.shape.length,p,d,!1,!0),y=n.runWebGLProgram(g,[m,f,v],v.dtype),b=i$({inputs:{x:y},backend:n,attrs:{shape:a.shape}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),n.disposeIntermediateTensorInfo(y),b}},s6=function(e,t){this.variableNames=["A"];for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[r]*t[r];this.outputShape=n,this.rank=n.length;var a=PJ(this.rank),i=function(e){var t=e.length;if(t>5)throw Error("Tile for rank "+t+" is not yet supported");if(1===t)return"imod(resRC, "+e[0]+")";for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],a=0;a<e.length;a++)r.push("imod("+n[a]+", "+e[a]+")");return r.join()}(e);this.userCode="\n void main() {\n "+a+" resRC = getOutputCoords();\n setOutput(getA("+i+"));\n }\n "};function u6(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.reps;if("string"===a.dtype||a.shape.length>5){var o=n.readSync(a.dataId),s="string"===a.dtype?o.map((function(e){return jw(e)})):o,u=KN(a.shape,a.dtype,s),l=hQ(u,i);return n.makeTensorInfo(l.shape,l.dtype,l.values)}var c=new s6(a.shape,i);return n.runWebGLProgram(c,[a],a.dtype)}var l6=function(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n "},c6=function(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode="\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n "};function p6(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function h6(e){for(var t=1;t<e;)t*=2;return t}var d6={kernelName:Ox,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.k,o=r.sorted,s=Fg().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),u=Fg().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),l=a.shape,c=l[l.length-1];if(n.shouldExecuteOnCPU([a])||c<s||i>u){var p=n.readSync(a.dataId),h=dQ(p,l,a.dtype,i,o),d=h[0],f=h[1];return[n.makeTensorInfo(d.shape,d.dtype,d.values),n.makeTensorInfo(f.shape,f.dtype,f.values)]}if(0===i)return l[l.length-1]=0,[n.makeTensorInfo(l,a.dtype,[]),n.makeTensorInfo(l,"int32",[])];if(1===c)return[a,X1({attrs:{shape:l,dtype:"int32",value:0},backend:n})];var m=n.texData.get(a.dataId),v=null!==m&&m.isPacked,g=v?n.unpackTensor(a):a,y=Xv(l)/c,b=i$({inputs:{x:g},attrs:{shape:[y,c]},backend:n});v&&p6(n,g);for(var x=h6(i),w=h6(c),k=null,N=function(){return null===k?[b,b]:[b,k]},I=function(e,t,r){var a=N(),i=new l6(r),o=[[c],[null===k?1:0],[Number.NEGATIVE_INFINITY],[e],[t]],s=k;k=n.runWebGLProgram(i,a,"int32",o),p6(n,s)},S=1;S<x;S*=2)for(var T=2*S,C=S;C>=1;C/=2)I(T,C,[y,w]);for(var E=w;E>x;E/=2){var A=N(),R=new c6([y,E/2]),_=[[c],[null===k?1:0],[x]],F=k;k=n.runWebGLProgram(R,A,"int32",_),p6(n,F);for(var O=x/2,D=2*O,M=O;M>=1;M/=2)I(D,M,k.shape)}var L=k;k=p0({inputs:{x:k},backend:n,attrs:{begin:0,size:[y,i]}}),p6(n,L);var z=d2({inputs:{x:b,indices:k},backend:n,attrs:{axis:1,batchDims:1}});p6(n,b);var P=l.slice(0,-1);P.push(i),L=k,k=i$({inputs:{x:k},attrs:{shape:P},backend:n}),p6(n,L);var B=z;return z=i$({inputs:{x:z},attrs:{shape:P},backend:n}),p6(n,B),[z,k]}},f6=function(e,t,n,r,a,i){this.variableNames=["Image","Transforms"],this.outputShape=i;var o,s="nearest"===n?1:2;switch(r){case"constant":default:o=1;break;case"reflect":o=2;break;case"wrap":o=3;break;case"nearest":o=4}this.userCode="\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if("+o+" == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if ("+o+" == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if ("+o+" == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < "+e+" && 0 <= coordX && coordX < "+t+") {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float("+a+");\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float("+a+");\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float("+t+"));\n float mapY = mapCoord(inY, float("+e+"));\n\n if ("+s+" == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n "};var m6={kernelName:Dx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.image,i=t.transforms,o=r.interpolation,s=r.fillMode,u=r.fillValue,l=r.outputShape,c=a.shape,p=c[0],h=c[1],d=c[2],f=c[3],m=null!=l?l:[h,d],v=m[0],g=m[1],y=new f6(h,d,o,s,u,[p,v,g,f]);return n.runWebGLProgram(y,[a,i],"float32")}};var v6={kernelName:Lx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=n.axis,i=t.x;bJ(i,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");var o=r.readSync(i.dataId),s=mQ(o,a,i.shape,i.dtype),u=s.outputValues,l=s.outputShape,c=s.indices;return[r.makeTensorInfo(l,i.dtype,u),r.makeTensorInfo([c.length],"int32",c)]}};var g6={kernelName:zx,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.value,i=r.axis;i<0&&(i+=a.shape.length);for(var o=a,s=o.shape.length,u=a.shape[i],l=new Array(s-1),c=0,p=0;p<s;p++)p!==i&&(l[c++]=o.shape[p]);var h=[],d=new Array(s).fill(0),f=o.shape.slice();f[i]=1;for(var m=new Array(u),v=0;v<m.length;v++){d[i]=v;var g=p0({inputs:{x:o},backend:n,attrs:{begin:d,size:f}}),y=i$({inputs:{x:g},backend:n,attrs:{shape:l}});m[v]=y,h.push(g)}return h.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),m}},y6=function(e,t){this.variableNames=["x","segmentIds"];var n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.numSegments,o=i*Math.ceil(a/n);this.outputShape=[r,o];var s=4*Math.floor(n/4),u=n%4,l="\n sumValue += dot(values, segFilter);\n ",c="";a%n>0&&(c="\n if (inIdx < 0 || inIdx >= "+a+") {\n return initializationValue;\n }\n ");var p="";a%n>0&&(p="\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 "+c+"\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n "+p+"\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 "+l+"\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 "+l+"\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 "+l+"\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 "+l+"\n }\n setOutput(sumValue);\n }\n "};for(var b6={kernelName:Px,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.segmentIds,o=r.numSegments,s=a.shape.length,u=[],l=0,c=VS([l],s),p=a;null!=c&&(p=m$({inputs:{x:a},backend:n,attrs:{perm:c}}),u.push(p),l=GS(1,s)[0]);var h=bF(p.shape,l,o),d=Xv([p.shape[l]]),f=i$({inputs:{x:p},backend:n,attrs:{shape:[-1,d]}});u.push(f);var m=function e(t,r,a,i,o){var s=t.shape[0],l=t.shape[1],c=yF(l,o),p=new y6({windowSize:c,inSize:l,batchSize:s,numSegments:o},r),h=n.compileAndRun(p,[t,a],i);if(u.push(h),h.shape[1]===o)return h;var d=j3({backend:n,attrs:{start:0,stop:o,step:1,dtype:"float32"}}),f=u6({inputs:{x:d},backend:n,attrs:{reps:[l/c]}});return u.push(d),u.push(f),e(h,r,f,i,o)}(f,"unsortedSegmentSum",i,fk(a.dtype),o),v=i$({inputs:{x:m},backend:n,attrs:{shape:h}}),g=v;if(null!=c){u.push(v);var y=US(c);g=m$({inputs:{x:g},backend:n,attrs:{perm:y}})}return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),g}},x6=0,w6=[y$,x$,k$,I$,C$,R$,_$,F$,P$,B$,V$,G$,H$,K$,Y$,Q$,$$,n0,r0,a0,s0,d0,f0,m0,x0,N0,T0,UQ,A0,z0,H0,J0,Q0,$0,e1,n1,a1,o1,u1,d1,f1,m1,g1,x1,N1,I1,T1,E1,A1,_1,F1,D1,L1,P1,W1,G1,q1,J1,Q1,t2,r2,o2,u2,l2,p2,f2,v2,y2,WQ,b2,D0,w2,N2,S2,HQ,C2,A2,R2,F2,D2,L2,P2,W2,G2,H2,K2,Y2,J2,Z2,e3,t3,n3,r3,a3,o3,l3,p3,x3,a$,w3,N3,S3,C3,g0,A3,F3,O3,z3,B3,XQ,W3,V3,U3,G3,H3,b0,f3,K3,Y3,Z3,o$,e4,n4,i4,s4,c4,h4,f4,v4,b4,w4,N4,S4,C4,A4,_4,O4,h0,b3,M4,L4,z4,P4,B4,W4,V4,U4,H4,q4,Y4,J4,Z4,$4,e6,t6,n6,g3,f$,a6,{kernelName:_x,backendName:"webgl",kernelFunc:i6},o6,{kernelName:Fx,backendName:"webgl",kernelFunc:u6},d6,m6,v$,v6,g6,b6,_3];x6<w6.length;x6++){Qx(w6[x6])}var k6={"tfjs-core":g_,"tfjs-backend-cpu":xH,"tfjs-backend-webgl":DQ,"tfjs-data":HU,"tfjs-layers":$L,"tfjs-converter":LV,tfjs:"4.3.0"};e.Abs=Mg,e.Acos=Lg,e.Acosh=zg,e.AdadeltaOptimizer=vR,e.AdagradOptimizer=gR,e.AdamOptimizer=yR,e.AdamaxOptimizer=bR,e.Add=Pg,e.AddN=Bg,e.All=Wg,e.Any=Vg,e.ArgMax=Ug,e.ArgMin=Gg,e.Asin=jg,e.Asinh=Hg,e.Atan=qg,e.Atan2=Xg,e.Atanh=Kg,e.AvgPool=Yg,e.AvgPool3D=Zg,e.AvgPool3DGrad=Qg,e.AvgPoolGrad=Jg,e.BatchMatMul=$g,e.BatchToSpaceND=ey,e.Bincount=ty,e.BroadcastArgs=ry,e.BroadcastTo=ny,e.Callback=iW,e.CallbackList=pL,e.Cast=ay,e.Ceil=iy,e.ClipByValue=oy,e.Complex=sy,e.ComplexAbs=uy,e.Concat=ly,e.Conv2D=cy,e.Conv2DBackpropFilter=py,e.Conv2DBackpropInput=hy,e.Conv3D=dy,e.Conv3DBackpropFilterV2=fy,e.Conv3DBackpropInputV2=my,e.Cos=vy,e.Cosh=gy,e.CropAndResize=xy,e.Cumprod=yy,e.Cumsum=by,e.CustomCallback=fL,e.DataStorage=zv,e.DenseBincount=wy,e.DepthToSpace=ky,e.DepthwiseConv2dNative=Ny,e.DepthwiseConv2dNativeBackpropFilter=Iy,e.DepthwiseConv2dNativeBackpropInput=Sy,e.Diag=Ty,e.Dilation2D=Cy,e.Dilation2DBackpropFilter=Ay,e.Dilation2DBackpropInput=Ey,e.EarlyStopping=uW,e.Einsum=_y,e.Elu=Fy,e.EluGrad=Oy,e.Environment=Ag,e.Equal=My,e.Erf=Dy,e.Exp=Ly,e.ExpandDims=zy,e.Expm1=Py,e.FFT=By,e.Fill=Wy,e.FlipLeftRight=Vy,e.Floor=Uy,e.FloorDiv=Gy,e.FromPixels=Vx,e.FusedBatchNorm=jy,e.FusedConv2D=jx,e.FusedDepthwiseConv2D=Hx,e.GPGPUContext=wZ,e.GatherNd=qy,e.GatherV2=Hy,e.GraphModel=OV,e.Greater=Ky,e.GreaterEqual=Xy,e.History=dL,e.IFFT=Jy,e.Identity=Yy,e.Imag=Zy,e.InputSpec=FM,e.IsFinite=Qy,e.IsInf=$y,e.IsNan=eb,e.KernelBackend=Pv,e.LRN=pb,e.LRNGrad=hb,e.LayerVariable=AM,e.LayersModel=Tz,e.LeakyRelu=tb,e.Less=nb,e.LessEqual=rb,e.LinSpace=ab,e.Log=ib,e.Log1p=ob,e.LogSoftmax=cb,e.LogicalAnd=sb,e.LogicalNot=ub,e.LogicalOr=lb,e.LogicalXor="LogicalXor",e.LowerBound="LowerBound",e.MathBackendCPU=YU,e.MathBackendWebGL=OQ,e.MatrixBandPart="MatrixBandPart",e.Max=db,e.MaxPool=mb,e.MaxPool3D=gb,e.MaxPool3DGrad=yb,e.MaxPoolGrad=vb,e.MaxPoolWithArgmax=bb,e.Maximum=fb,e.Mean=xb,e.Min=wb,e.Minimum=kb,e.MirrorPad=Nb,e.Mod=Ib,e.MomentumOptimizer=wR,e.Multinomial=Sb,e.Multiply=Tb,e.Neg=Cb,e.NonMaxSuppressionV3=Ab,e.NonMaxSuppressionV4=Rb,e.NonMaxSuppressionV5=_b,e.NotEqual=Eb,e.OP_SCOPE_SUFFIX=Bk,e.OneHot=Ob,e.OnesLike=Fb,e.Optimizer=mR,e.OptimizerConstructors=y_,e.Pack=Db,e.PadV2=Mb,e.Pool="Pool",e.Pow=Lb,e.Prelu=zb,e.Prod=Pb,e.RMSPropOptimizer=kR,e.RNN=DP,e.RaggedGather=Bb,e.RaggedRange=Wb,e.RaggedTensorToTensor=Vb,e.Range=Ub,e.Real=Gb,e.RealDiv=Ry,e.Reciprocal=jb,e.Relu=Hb,e.Relu6=Zb,e.Reshape=qb,e.ResizeBilinear=Yb,e.ResizeBilinearGrad=Jb,e.ResizeNearestNeighbor=Kb,e.ResizeNearestNeighborGrad=Xb,e.Reverse=Qb,e.RotateWithOffset=Ux,e.Round=$b,e.Rsqrt=ex,e.SGDOptimizer=xR,e.ScatterNd=tx,e.SearchSorted=rx,e.Select=ax,e.Selu=ix,e.Sequential=Oz,e.Sigmoid=cx,e.Sign=lx,e.Sin=sx,e.Sinh=ux,e.Slice=ox,e.Softmax=vx,e.Softplus=px,e.SpaceToBatchND=fx,e.SparseFillEmptyRows=gx,e.SparseReshape=yx,e.SparseSegmentMean=bx,e.SparseSegmentSum=xx,e.SparseToDense=wx,e.SplitV=mx,e.Sqrt=hx,e.Square=Nx,e.SquaredDifference=kx,e.StaticRegexReplace=Ix,e.Step=Wx,e.StridedSlice=Sx,e.StringNGrams=Tx,e.StringSplit=Cx,e.StringToHashBucketFast=Ex,e.Sub=Ax,e.Sum=dx,e.SymbolicTensor=OM,e.Tan=Rx,e.Tanh=_x,e.Tensor=ak,e.TensorBuffer=tk,e.TensorScatterUpdate=nx,e.Tile=Fx,e.TopK=Ox,e.Transform=Dx,e.Transpose=Mx,e.Unique=Lx,e.Unpack=zx,e.UnsortedSegmentSum=Px,e.UpperBound="UpperBound",e.Variable=pk,e.ZerosLike=Bx,e._FusedMatMul=Gx,e.abs=cI,e.acos=pI,e.acosh=hI,e.add=oI,e.addN=dI,e.all=fI,e.any=mI,e.argMax=vI,e.argMin=gI,e.asin=yI,e.asinh=bI,e.atan=xI,e.atan2=wI,e.atanh=kI,e.avgPool=BI,e.avgPool3d=WI,e.backend=iI,e.backend_util=NF,e.basicLSTMCell=qI,e.batchNorm=XI,e.batchNorm2d=YI,e.batchNorm3d=JI,e.batchNorm4d=ZI,e.batchToSpaceND=KI,e.bincount=QI,e.booleanMaskAsync=zE,e.broadcastArgs=$I,e.broadcastTo=eS,e.broadcast_util=CS,e.browser=ZR,e.buffer=KN,e.callbacks=pW,e.cast=XN,e.ceil=tS,e.clipByValue=rS,e.clone=YN,e.complex=Vk,e.concat=VI,e.concat1d=aS,e.concat2d=iS,e.concat3d=oS,e.concat4d=sS,e.constraints=aL,e.conv1d=lS,e.conv2d=uS,e.conv2dTranspose=pS,e.conv3d=hS,e.conv3dTranspose=fS,e.copyRegisteredKernels=function(e,t){Zx(e).forEach((function(e){Qx(Object.assign({},e,{backendName:t}))}))},e.cos=mS,e.cosh=vS,e.cosineWindow=HE,e.cumprod=gS,e.cumsum=yS,e.customGrad=wT,e.data=qU,e.denseBincount=bS,e.deprecationWarn=ZN,e.depthToSpace=xS,e.depthwiseConv2d=wS,e.deregisterOp=function(e){delete hW[e]},e.device_util=Fk,e.diag=kS,e.dilation2d=NS,e.disableDeprecationWarnings=function(){Fg().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")},e.dispose=tI,e.disposeVariables=function(){Ek.disposeVariables()},e.div=uI,e.divNoNan=_S,e.dot=FS,e.dropout=GE,e.einsum=OS,e.elu=DS,e.enableDebugMode=function(){Fg().set("DEBUG",!0)},e.enableProdMode=function(){Fg().set("PROD",!0)},e.enclosingPowerOfTwo=jE,e.engine=QN,e.env=Fg,e.equal=ES,e.erf=MS,e.euclideanNorm=$S,e.exp=eT,e.expandDims=tT,e.expm1=nT,e.eye=aT,e.fft=aE,e.fill=nS,e.findBackend=function(e){return Ek.findBackend(e)},e.findBackendFactory=function(e){return Ek.findBackendFactory(e)},e.floor=iT,e.floorDiv=sI,e.forceHalfFloat=MQ,e.fused=aA,e.gather=oT,e.gatherND=UE,e.gather_util=$R,e.getBackend=function(){return Ek.backendName},e.getGradient=Jx,e.getKernel=Yx,e.getKernelsForBackend=Zx,e.gpgpu_util=xZ,e.grad=function(e){return Hv(fg(e),(function(){return"The f passed in grad(f) must be a function"})),function(t,n){var r=zk(t,"x","tf.grad","string_or_numeric"),a=null!=n?zk(n,"dy","tf.grad"):null;return Ek.tidy((function(){var t=Ek.gradients((function(){return e(r)}),[r],a),n=t.value,i=t.grads;return null!=a&&qv(n.shape,a.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),kT(i),i[0]}))}},e.grads=function(e){return Hv(fg(e),(function(){return"The f passed in grads(f) must be a function"})),function(t,n){Hv(Array.isArray(t),(function(){return"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"}));var r=Pk(t,"args","tf.grads","string_or_numeric"),a=null!=n?zk(n,"dy","tf.grads"):null;return Ek.tidy((function(){var t=Ek.gradients((function(){return e.apply(void 0,r)}),r,a),n=t.value,i=t.grads;return null!=a&&qv(n.shape,a.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),kT(i),i}))}},e.greater=sT,e.greaterEqual=uT,e.ifft=iE,e.imag=lT,e.image=oR,e.inTopKAsync=KE,e.initializers=oL,e.input=Dz,e.io=GR,e.irfft=oE,e.isFinite=cT,e.isInf=pT,e.isNaN=hT,e.keep=nI,e.kernel_impls=IF,e.layers=tW,e.leakyRelu=dT,e.less=fT,e.lessEqual=mT,e.linalg=sR,e.linspace=vT,e.loadGraphModel=function(e,t,n){return DV.apply(this,arguments)},e.loadGraphModelSync=function(e){if(null==e)throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model");var t;if(e instanceof Array){var n=e[0],r=e[1];if(!n)throw new Error("modelJSON must be the first element of the array");if(!(r&&r instanceof ArrayBuffer))throw new Error("An ArrayBuffer of weights must be the second element of the array");if(!("modelTopology"in n))throw new Error("Model JSON is missing 'modelTopology'");if(!("weightsManifest"in n))throw new Error("Model JSON is missing 'weightsManifest'");t=UR(nN(n,oN(n.weightsManifest),r))}else if("load"in e)t=e;else{if(!("modelTopology"in e&&"weightSpecs"in e&&"weightData"in e))throw new Error("Unknown model format");t=UR(e)}var a=new OV(t);return a.load(),a},e.loadLayersModel=function(e,t){return Az.apply(this,arguments)},e.localResponseNormalization=gT,e.log=yT,e.log1p=bT,e.logSigmoid=ST,e.logSoftmax=CT,e.logSumExp=ET,e.logicalAnd=AT,e.logicalNot=RT,e.logicalOr=_T,e.logicalXor=FT,e.losses=uR,e.lowerBound=MT,e.matMul=UI,e.math=HR,e.max=jS,e.maxPool=LT,e.maxPool3d=zT,e.maxPoolWithArgmax=PT,e.maximum=BT,e.mean=WT,e.memory=$N,e.meshgrid=GT,e.metrics=nW,e.min=HS,e.minimum=jT,e.mirrorPad=HT,e.mod=qT,e.model=function(e){return new Tz(e)},e.models=rW,e.moments=KT,e.movingAverage=BE,e.mul=lI,e.multiRNNCell=XT,e.multinomial=YT,e.neg=NT,e.nextFrame=w_,e.norm=QS,e.notEqual=JT,e.oneHot=ZT,e.ones=UT,e.onesLike=QT,e.op=Wk,e.outerProduct=$T,e.pad=eC,e.pad1d=tC,e.pad2d=nC,e.pad3d=rC,e.pad4d=aC,e.pool=oC,e.pow=qS,e.prelu=sC,e.print=JN,e.prod=uC,e.profile=function(e){return Ek.profile(e)},e.raggedGather=lC,e.raggedRange=cC,e.raggedTensorToTensor=pC,e.rand=hC,e.randomGamma=RC,e.randomNormal=_C,e.randomStandardNormal=FC,e.randomUniform=OC,e.range=DC,e.ready=function(){return Ek.ready()},e.real=MC,e.reciprocal=LC,e.registerBackend=aI,e.registerCallbackConstructor=function(e,t){vL.registerCallbackConstructor(e,t)},e.registerGradient=$x,e.registerKernel=Qx,e.registerOp=function(e,t){var n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};hW[e]=n},e.regularizers=aW,e.relu=zC,e.relu6=PC,e.removeBackend=function(e){Ek.removeBackend(e)},e.reshape=PI,e.reverse=BC,e.reverse1d=WC,e.reverse2d=VC,e.reverse3d=UC,e.reverse4d=GC,e.rfft=uE,e.round=jC,e.rsqrt=HC,e.scalar=KS,e.scatterND=WE,e.scatter_util=IE,e.searchSorted=DT,e.selu=qC,e.separableConv2d=KC,e.sequential=function(e){return new Oz(e)},e.serialization=fR,e.setBackend=rI,e.setPlatform=function(e,t){Fg().setPlatform(e,t)},e.setWebGLContext=NY,e.setdiff1dAsync=YC,e.shared=bH,e.sigmoid=GI,e.sign=JC,e.signal=iR,e.sin=ZC,e.sinh=QC,e.slice=jI,e.slice1d=$C,e.slice2d=eE,e.slice3d=tE,e.slice4d=nE,e.slice_util=v_,e.softmax=rE,e.softplus=IT,e.spaceToBatchND=iC,e.sparse=lR,e.sparseToDense=VE,e.spectral=aR,e.split=sE,e.sqrt=XS,e.square=YS,e.squaredDifference=lE,e.squeeze=cE,e.stack=pE,e.step=hE,e.stridedSlice=dE,e.string=cR,e.sub=TT,e.sum=JS,e.sumOutType=fk,e.tan=fE,e.tanh=HI,e.tensor=Gk,e.tensor1d=mE,e.tensor2d=vE,e.tensor3d=gE,e.tensor4d=yE,e.tensor5d=bE,e.tensor6d=xE,e.tensorScatterUpdate=SE,e.tensor_util=kk,e.test_util=TC,e.tidy=eI,e.tile=rT,e.time=function(e){return Ek.time(e)},e.topk=TE,e.train=b_,e.transpose=PE,e.truncatedNormal=CE,e.unique=EE,e.unregisterGradient=function(e){if(!Xx.has(e))throw new Error("The gradient '"+e+"' for backend is not registered");Xx.delete(e)},e.unregisterKernel=function(e,t){var n=ew(e,t);if(!Kx.has(n))throw new Error("The kernel '"+e+"' for backend '"+t+"' is not registered");Kx.delete(n)},e.unsortedSegmentSum=AE,e.unstack=RE,e.upcastType=dk,e.upperBound=_E,e.util=Kw,e.valueAndGrad=function(e){return Hv(fg(e),(function(){return"The f passed in valueAndGrad(f) must be a function"})),function(t,n){Hv(t instanceof ak,(function(){return"The x passed in valueAndGrad(f)(x) must be a tensor"})),Hv(null==n||n instanceof ak,(function(){return"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"}));var r=Ek.gradients((function(){return e(t)}),[t],n),a=r.grads,i=r.value;return kT(a),{grad:a[0],value:i}}},e.valueAndGrads=function(e){return Hv(fg(e),(function(){return"The f passed in valueAndGrads(f) must be a function"})),function(t,n){Hv(Array.isArray(t)&&t.every((function(e){return e instanceof ak})),(function(){return"The args passed in valueAndGrads(f)(args) must be array of tensors"})),Hv(null==n||n instanceof ak,(function(){return"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"}));var r=Ek.gradients((function(){return e.apply(void 0,t)}),t,n);return null!=n&&qv(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),kT(r.grads),r}},e.variable=FE,e.variableGrads=xT,e.version=k6,e.version_converter=LV,e.version_core=g_,e.version_cpu=xH,e.version_layers=$L,e.version_webgl=DQ,e.webgl=LQ,e.webgl_util=xJ,e.where=AS,e.whereAsync=ME,e.zeros=VT,e.zerosLike=RS,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=tf.min.js.map