/*! For license information please see 2.e1845539.chunk.js.LICENSE.txt */ (this["webpackJsonprvm-website"]=this["webpackJsonprvm-website"]||[]).push([[2],[function(e,t,n){"use strict";n.d(t,"dc",(function(){return it})),n.d(t,"bd",(function(){return ue.a})),n.d(t,"cd",(function(){return ue.b})),n.d(t,"jf",(function(){return ot.a})),n.d(t,"vf",(function(){return ot.b})),n.d(t,"md",(function(){return st.b})),n.d(t,"nd",(function(){return st.e})),n.d(t,"od",(function(){return st.g})),n.d(t,"pd",(function(){return st.h})),n.d(t,"qd",(function(){return st.i})),n.d(t,"rd",(function(){return st.p})),n.d(t,"sd",(function(){return st.q})),n.d(t,"vd",(function(){return st.t})),n.d(t,"wd",(function(){return st.u})),n.d(t,"xd",(function(){return st.v})),n.d(t,"zd",(function(){return st.A})),n.d(t,"Ad",(function(){return st.B})),n.d(t,"Bd",(function(){return st.D})),n.d(t,"Cd",(function(){return st.E})),n.d(t,"Dd",(function(){return st.G})),n.d(t,"Ed",(function(){return st.H})),n.d(t,"Fd",(function(){return st.I})),n.d(t,"Gd",(function(){return st.J})),n.d(t,"Hd",(function(){return st.K})),n.d(t,"Id",(function(){return st.L})),n.d(t,"Jd",(function(){return st.M})),n.d(t,"Kd",(function(){return st.N})),n.d(t,"Ld",(function(){return st.O})),n.d(t,"Md",(function(){return st.P})),n.d(t,"Nd",(function(){return st.W})),n.d(t,"Qd",(function(){return st.Z})),n.d(t,"Sd",(function(){return st.eb})),n.d(t,"Vd",(function(){return st.gb})),n.d(t,"Wd",(function(){return st.ib})),n.d(t,"Xd",(function(){return st.jb})),n.d(t,"Yd",(function(){return st.lb})),n.d(t,"Zd",(function(){return st.nb})),n.d(t,"ae",(function(){return st.ob})),n.d(t,"ce",(function(){return st.rb})),n.d(t,"de",(function(){return st.tb})),n.d(t,"ee",(function(){return st.ub})),n.d(t,"je",(function(){return st.Db})),n.d(t,"le",(function(){return st.Jb})),n.d(t,"me",(function(){return st.Kb})),n.d(t,"ne",(function(){return st.Mb})),n.d(t,"oe",(function(){return st.Ob})),n.d(t,"pe",(function(){return st.Tb})),n.d(t,"qe",(function(){return st.Ub})),n.d(t,"re",(function(){return st.Vb})),n.d(t,"se",(function(){return st.Wb})),n.d(t,"te",(function(){return st.Yb})),n.d(t,"ue",(function(){return st.Zb})),n.d(t,"we",(function(){return st.cc})),n.d(t,"xe",(function(){return st.fc})),n.d(t,"ye",(function(){return st.hc})),n.d(t,"ze",(function(){return st.kc})),n.d(t,"Be",(function(){return st.mc})),n.d(t,"Ce",(function(){return st.nc})),n.d(t,"De",(function(){return st.oc})),n.d(t,"Ee",(function(){return st.pc})),n.d(t,"Fe",(function(){return st.sc})),n.d(t,"Ge",(function(){return st.yc})),n.d(t,"He",(function(){return st.zc})),n.d(t,"Ie",(function(){return st.Ec})),n.d(t,"Je",(function(){return st.Fc})),n.d(t,"Me",(function(){return st.Jc})),n.d(t,"Ne",(function(){return st.Lc})),n.d(t,"Oe",(function(){return st.Mc})),n.d(t,"Pe",(function(){return st.Uc})),n.d(t,"Qe",(function(){return st.Wc})),n.d(t,"Re",(function(){return st.Xc})),n.d(t,"Ue",(function(){return st.Zc})),n.d(t,"Ve",(function(){return st.ed})),n.d(t,"We",(function(){return st.fd})),n.d(t,"Xe",(function(){return st.gd})),n.d(t,"Ye",(function(){return st.hd})),n.d(t,"Ze",(function(){return st.id})),n.d(t,"bf",(function(){return st.jd})),n.d(t,"cf",(function(){return st.kd})),n.d(t,"df",(function(){return st.pd})),n.d(t,"ef",(function(){return st.qd})),n.d(t,"ff",(function(){return st.td})),n.d(t,"gf",(function(){return st.ud})),n.d(t,"hf",(function(){return st.yd})),n.d(t,"if",(function(){return st.zd})),n.d(t,"kf",(function(){return st.Bd})),n.d(t,"lf",(function(){return st.Cd})),n.d(t,"mf",(function(){return st.Dd})),n.d(t,"nf",(function(){return st.Ed})),n.d(t,"qf",(function(){return st.Jd})),n.d(t,"tf",(function(){return st.Md})),n.d(t,"uf",(function(){return st.Pd})),n.d(t,"xf",(function(){return st.Qd})),n.d(t,"Af",(function(){return st.Rd})),n.d(t,"Bf",(function(){return st.Td})),n.d(t,"Cf",(function(){return st.Ud})),n.d(t,"sf",(function(){return st.Ld})),n.d(t,"Rd",(function(){return st.cb})),n.d(t,"fe",(function(){return st.xb})),n.d(t,"ke",(function(){return st.Gb})),n.d(t,"be",(function(){return st.qb})),n.d(t,"rf",(function(){return It})),n.d(t,"Td",(function(){return nt.c})),n.d(t,"ve",(function(){return nt.e})),n.d(t,"pf",(function(){return nt.h})),n.d(t,"Pd",(function(){return nt.b})),n.d(t,"he",(function(){return nt.d})),n.d(t,"Te",(function(){return nt.g})),n.d(t,"Ke",(function(){return nt.f})),n.d(t,"td",(function(){return nt.a})),n.d(t,"Le",(function(){return Me.e})),n.d(t,"yf",(function(){return rt.b})),n.d(t,"Ud",(function(){return f.b})),n.d(t,"zf",(function(){return Je})),n.d(t,"Ae",(function(){return Ct.a})),n.d(t,"yd",(function(){return a})),n.d(t,"ge",(function(){return r})),n.d(t,"Se",(function(){return i})),n.d(t,"wf",(function(){return Ze})),n.d(t,"ud",(function(){return s})),n.d(t,"of",(function(){return Qe})),n.d(t,"af",(function(){return Ke})),n.d(t,"Od",(function(){return wn})),n.d(t,"ie",(function(){return c})),n.d(t,"wb",(function(){return Nn.b})),n.d(t,"L",(function(){return Nn.a})),n.d(t,"a",(function(){return _e.a})),n.d(t,"b",(function(){return _e.b})),n.d(t,"c",(function(){return _e.c})),n.d(t,"d",(function(){return _e.d})),n.d(t,"e",(function(){return _e.e})),n.d(t,"f",(function(){return _e.f})),n.d(t,"g",(function(){return _e.g})),n.d(t,"h",(function(){return _e.h})),n.d(t,"i",(function(){return _e.i})),n.d(t,"j",(function(){return _e.j})),n.d(t,"k",(function(){return _e.k})),n.d(t,"l",(function(){return _e.l})),n.d(t,"n",(function(){return _e.n})),n.d(t,"m",(function(){return _e.m})),n.d(t,"o",(function(){return _e.o})),n.d(t,"r",(function(){return _e.r})),n.d(t,"p",(function(){return _e.p})),n.d(t,"q",(function(){return _e.q})),n.d(t,"s",(function(){return _e.s})),n.d(t,"t",(function(){return _e.t})),n.d(t,"u",(function(){return _e.u})),n.d(t,"v",(function(){return _e.w})),n.d(t,"w",(function(){return _e.x})),n.d(t,"x",(function(){return _e.y})),n.d(t,"y",(function(){return _e.z})),n.d(t,"z",(function(){return _e.A})),n.d(t,"A",(function(){return _e.B})),n.d(t,"B",(function(){return _e.C})),n.d(t,"C",(function(){return _e.D})),n.d(t,"D",(function(){return _e.E})),n.d(t,"E",(function(){return _e.F})),n.d(t,"F",(function(){return _e.G})),n.d(t,"G",(function(){return _e.H})),n.d(t,"H",(function(){return _e.I})),n.d(t,"I",(function(){return _e.J})),n.d(t,"K",(function(){return _e.L})),n.d(t,"J",(function(){return _e.K})),n.d(t,"M",(function(){return _e.M})),n.d(t,"N",(function(){return _e.N})),n.d(t,"O",(function(){return _e.O})),n.d(t,"P",(function(){return _e.P})),n.d(t,"Q",(function(){return _e.Q})),n.d(t,"R",(function(){return _e.R})),n.d(t,"S",(function(){return _e.S})),n.d(t,"U",(function(){return _e.U})),n.d(t,"T",(function(){return _e.T})),n.d(t,"lc",(function(){return _e.kc})),n.d(t,"V",(function(){return _e.V})),n.d(t,"W",(function(){return _e.W})),n.d(t,"X",(function(){return _e.X})),n.d(t,"Z",(function(){return _e.Z})),n.d(t,"Y",(function(){return _e.Y})),n.d(t,"ab",(function(){return _e.ab})),n.d(t,"bb",(function(){return _e.bb})),n.d(t,"cb",(function(){return _e.cb})),n.d(t,"db",(function(){return _e.db})),n.d(t,"eb",(function(){return _e.eb})),n.d(t,"fb",(function(){return _e.fb})),n.d(t,"gb",(function(){return _e.gb})),n.d(t,"hb",(function(){return _e.hb})),n.d(t,"jb",(function(){return _e.jb})),n.d(t,"nb",(function(){return _e.nb})),n.d(t,"mb",(function(){return _e.mb})),n.d(t,"ob",(function(){return _e.ob})),n.d(t,"pb",(function(){return _e.pb})),n.d(t,"rb",(function(){return _e.rb})),n.d(t,"qb",(function(){return _e.qb})),n.d(t,"sb",(function(){return _e.sb})),n.d(t,"tb",(function(){return _e.tb})),n.d(t,"ub",(function(){return _e.ub})),n.d(t,"vb",(function(){return _e.vb})),n.d(t,"zb",(function(){return _e.yb})),n.d(t,"Ab",(function(){return _e.zb})),n.d(t,"Bb",(function(){return _e.Ab})),n.d(t,"Cb",(function(){return _e.Bb})),n.d(t,"Db",(function(){return _e.Cb})),n.d(t,"Eb",(function(){return _e.Db})),n.d(t,"Fb",(function(){return _e.Fb})),n.d(t,"Gb",(function(){return _e.Gb})),n.d(t,"Hb",(function(){return _e.Hb})),n.d(t,"xb",(function(){return _e.wb})),n.d(t,"yb",(function(){return _e.xb})),n.d(t,"Ib",(function(){return _e.Ib})),n.d(t,"Ob",(function(){return _e.Ob})),n.d(t,"Jb",(function(){return _e.Jb})),n.d(t,"Mb",(function(){return _e.Mb})),n.d(t,"Kb",(function(){return _e.Kb})),n.d(t,"Lb",(function(){return _e.Lb})),n.d(t,"Nb",(function(){return _e.Nb})),n.d(t,"Pb",(function(){return _e.Pb})),n.d(t,"Qb",(function(){return _e.Qb})),n.d(t,"Rb",(function(){return _e.Rb})),n.d(t,"Sb",(function(){return _e.Sb})),n.d(t,"Tb",(function(){return _e.Tb})),n.d(t,"Ub",(function(){return _e.Ub})),n.d(t,"Vb",(function(){return _e.Vb})),n.d(t,"Wb",(function(){return _e.Wb})),n.d(t,"ac",(function(){return _e.ac})),n.d(t,"Xb",(function(){return _e.Xb})),n.d(t,"Yb",(function(){return _e.Yb})),n.d(t,"Zb",(function(){return _e.Zb})),n.d(t,"cc",(function(){return _e.cc})),n.d(t,"bc",(function(){return _e.bc})),n.d(t,"ec",(function(){return _e.dc})),n.d(t,"fc",(function(){return _e.ec})),n.d(t,"gc",(function(){return _e.fc})),n.d(t,"hc",(function(){return _e.gc})),n.d(t,"ic",(function(){return _e.hc})),n.d(t,"jc",(function(){return _e.ic})),n.d(t,"kc",(function(){return _e.jc})),n.d(t,"mc",(function(){return _e.lc})),n.d(t,"nc",(function(){return _e.mc})),n.d(t,"pc",(function(){return _e.oc})),n.d(t,"sc",(function(){return _e.rc})),n.d(t,"tc",(function(){return _e.sc})),n.d(t,"qc",(function(){return _e.pc})),n.d(t,"rc",(function(){return _e.qc})),n.d(t,"oc",(function(){return _e.nc})),n.d(t,"uc",(function(){return _e.tc})),n.d(t,"wc",(function(){return _e.vc})),n.d(t,"xc",(function(){return _e.wc})),n.d(t,"yc",(function(){return _e.xc})),n.d(t,"zc",(function(){return _e.yc})),n.d(t,"Ac",(function(){return _e.zc})),n.d(t,"Fc",(function(){return _e.Ec})),n.d(t,"Dc",(function(){return _e.Cc})),n.d(t,"Ec",(function(){return _e.Dc})),n.d(t,"Cc",(function(){return _e.Bc})),n.d(t,"Bc",(function(){return _e.Ac})),n.d(t,"Hc",(function(){return _e.Gc})),n.d(t,"Pc",(function(){return _e.Oc})),n.d(t,"Yc",(function(){return _e.Xc})),n.d(t,"Ic",(function(){return _e.Hc})),n.d(t,"Oc",(function(){return _e.Nc})),n.d(t,"Gc",(function(){return _e.Fc})),n.d(t,"Jc",(function(){return _e.Ic})),n.d(t,"Kc",(function(){return _e.Jc})),n.d(t,"Lc",(function(){return _e.Kc})),n.d(t,"Mc",(function(){return _e.Lc})),n.d(t,"Nc",(function(){return _e.Mc})),n.d(t,"Rc",(function(){return _e.Qc})),n.d(t,"Qc",(function(){return _e.Pc})),n.d(t,"Tc",(function(){return _e.Sc})),n.d(t,"Uc",(function(){return _e.Tc})),n.d(t,"Vc",(function(){return _e.Uc})),n.d(t,"Wc",(function(){return _e.Vc})),n.d(t,"Xc",(function(){return _e.Wc})),n.d(t,"Zc",(function(){return _e.Yc})),n.d(t,"ad",(function(){return _e.Zc})),n.d(t,"dd",(function(){return _e.ad})),n.d(t,"ed",(function(){return _e.bd})),n.d(t,"fd",(function(){return _e.cd})),n.d(t,"gd",(function(){return _e.dd})),n.d(t,"hd",(function(){return _e.ed})),n.d(t,"id",(function(){return _e.fd})),n.d(t,"jd",(function(){return _e.gd})),n.d(t,"kd",(function(){return _e.hd})),n.d(t,"Sc",(function(){return _e.Rc})),n.d(t,"ib",(function(){return _e.ib})),n.d(t,"vc",(function(){return _e.uc})),n.d(t,"ld",(function(){return _e.id})),n.d(t,"kb",(function(){return _e.kb})),n.d(t,"lb",(function(){return _e.lb}));var r={};n.r(r),n.d(r,"copyModel",(function(){return ee})),n.d(r,"listModels",(function(){return $})),n.d(r,"moveModel",(function(){return ne})),n.d(r,"removeModel",(function(){return Z})),n.d(r,"browserFiles",(function(){return be})),n.d(r,"browserHTTPRequest",(function(){return Te})),n.d(r,"concatenateArrayBuffers",(function(){return v.d})),n.d(r,"decodeWeights",(function(){return v.e})),n.d(r,"encodeWeights",(function(){return v.f})),n.d(r,"fromMemory",(function(){return Re})),n.d(r,"getLoadHandlers",(function(){return k})),n.d(r,"getModelArtifactsForJSON",(function(){return v.g})),n.d(r,"getModelArtifactsInfoForJSON",(function(){return v.h})),n.d(r,"getSaveHandlers",(function(){return x})),n.d(r,"http",(function(){return Ce})),n.d(r,"isHTTPScheme",(function(){return Ne})),n.d(r,"loadWeights",(function(){return xe})),n.d(r,"registerLoadRouter",(function(){return O})),n.d(r,"registerSaveRouter",(function(){return y})),n.d(r,"weightsLoaderFactory",(function(){return we})),n.d(r,"withSaveHandler",(function(){return Fe}));var a={};n.r(a),n.d(a,"fromPixelsAsync",(function(){return Ue})),n.d(a,"toPixels",(function(){return He})),n.d(a,"fromPixels",(function(){return qe}));var i={};n.r(i),n.d(i,"Serializable",(function(){return Xe})),n.d(i,"SerializationMap",(function(){return Ye})),n.d(i,"registerClass",(function(){return $e}));var o={};n.r(o),n.d(o,"segOpComputeOptimalWindowSize",(function(){return gn})),n.d(o,"computeOutShape",(function(){return yn})),n.d(o,"collectGatherOpShapeInfo",(function(){return On}));var s={};n.r(s),n.d(s,"axesAreInnerMostDims",(function(){return Tt.b})),n.d(s,"combineLocations",(function(){return Tt.c})),n.d(s,"computeOutAndReduceShapes",(function(){return Tt.d})),n.d(s,"expandShapeToKeepDim",(function(){return Tt.e})),n.d(s,"assertAxesAreInnerMostDims",(function(){return Tt.a})),n.d(s,"getAxesPermutation",(function(){return Tt.f})),n.d(s,"getUndoAxesPermutation",(function(){return Tt.h})),n.d(s,"getInnerMostAxes",(function(){return Tt.g})),n.d(s,"getBroadcastDims",(function(){return Et.b})),n.d(s,"getReductionAxes",(function(){return Et.c})),n.d(s,"assertAndGetBroadcastShape",(function(){return Et.a})),n.d(s,"assertParamsConsistent",(function(){return At})),n.d(s,"computeOutShape",(function(){return Rt})),n.d(s,"computeDilation2DInfo",(function(){return Ft.d})),n.d(s,"computePool2DInfo",(function(){return Ft.e})),n.d(s,"computePool3DInfo",(function(){return Ft.f})),n.d(s,"computeConv2DInfo",(function(){return Ft.a})),n.d(s,"computeConv3DInfo",(function(){return Ft.b})),n.d(s,"computeDefaultPad",(function(){return Ft.c})),n.d(s,"tupleValuesAreOne",(function(){return Ft.i})),n.d(s,"eitherStridesOrDilationsAreOne",(function(){return Ft.h})),n.d(s,"convertConv2DDataFormat",(function(){return Ft.g})),n.d(s,"getFusedDyActivation",(function(){return Dt.c})),n.d(s,"getFusedBiasGradient",(function(){return Dt.b})),n.d(s,"applyActivation",(function(){return Dt.a})),n.d(s,"shouldFuse",(function(){return Dt.d})),n.d(s,"PARALLELIZE_THRESHOLD",(function(){return _t})),n.d(s,"computeOptimalWindowSize",(function(){return Mt})),n.d(s,"slice_util",(function(){return Ke})),n.d(s,"upcastType",(function(){return ot.b})),n.d(s,"getImageCenter",(function(){return zt})),n.d(s,"getReshaped",(function(){return Lt})),n.d(s,"getPermuted",(function(){return Pt})),n.d(s,"getReshapedPermuted",(function(){return Bt})),n.d(s,"getSliceBeginCoords",(function(){return Wt})),n.d(s,"getSliceSize",(function(){return Ut})),n.d(s,"prepareAndValidate",(function(){return Vt})),n.d(s,"validateUpdateShape",(function(){return Ht.c})),n.d(s,"validateInput",(function(){return Ht.b})),n.d(s,"calculateShapes",(function(){return Ht.a})),n.d(s,"SELU_SCALEALPHA",(function(){return Gt.b})),n.d(s,"SELU_SCALE",(function(){return Gt.a})),n.d(s,"ERF_P",(function(){return qt})),n.d(s,"ERF_A1",(function(){return Kt})),n.d(s,"ERF_A2",(function(){return Xt})),n.d(s,"ERF_A3",(function(){return Yt})),n.d(s,"ERF_A4",(function(){return $t})),n.d(s,"ERF_A5",(function(){return Qt})),n.d(s,"warn",(function(){return Zt})),n.d(s,"log",(function(){return Jt})),n.d(s,"mergeRealAndImagArrays",(function(){return en})),n.d(s,"splitRealAndImagArrays",(function(){return tn})),n.d(s,"complexWithEvenIndex",(function(){return nn})),n.d(s,"complexWithOddIndex",(function(){return rn})),n.d(s,"getComplexWithIndex",(function(){return an})),n.d(s,"assignToTypedArray",(function(){return on})),n.d(s,"exponents",(function(){return sn})),n.d(s,"exponent",(function(){return cn})),n.d(s,"decodeEinsumEquation",(function(){return dn})),n.d(s,"getEinsumPermutation",(function(){return fn})),n.d(s,"checkEinsumDimSizes",(function(){return pn})),n.d(s,"getEinsumComputePath",(function(){return hn})),n.d(s,"isIdentityPermutation",(function(){return bn})),n.d(s,"prepareSplitSize",(function(){return vn})),n.d(s,"segment_util",(function(){return o})),n.d(s,"fromUint8ToStringArray",(function(){return xn})),n.d(s,"fromStringArrayToUint8",(function(){return kn}));var c={};n.r(c),n.d(c,"nonMaxSuppressionV3Impl",(function(){return jn.a})),n.d(c,"nonMaxSuppressionV4Impl",(function(){return jn.b})),n.d(c,"nonMaxSuppressionV5Impl",(function(){return jn.c})),n.d(c,"whereImpl",(function(){return Sn.a}));var u=n(9),l=(n(176),n(7)),d=n(11),f=n(38),p=n(20),h=n(5),b=n.n(h),m=n(12),v=n(52),g=function(){function e(){Object(l.a)(this,e),this.saveRouters=[],this.loadRouters=[]}return Object(d.a)(e,null,[{key:"getInstance",value:function(){return null==e.instance&&(e.instance=new e),e.instance}},{key:"registerSaveRouter",value:function(t){e.getInstance().saveRouters.push(t)}},{key:"registerLoadRouter",value:function(t){e.getInstance().loadRouters.push(t)}},{key:"getSaveHandlers",value:function(t){return e.getHandlers(t,"save")}},{key:"getLoadHandlers",value:function(t,n){return e.getHandlers(t,"load",n)}},{key:"getHandlers",value: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}(),y=function(e){return g.registerSaveRouter(e)},O=function(e){return g.registerLoadRouter(e)},x=function(e){return g.getSaveHandlers(e)},k=function(e,t){return g.getLoadHandlers(e,t)},w="tensorflowjs",j="models_store",S="model_info_store";function N(){if(!Object(f.b)().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 I(e){var t=e.result;t.createObjectStore(j,{keyPath:"modelPath"}),t.createObjectStore(S,{keyPath:"modelPath"})}var C=function(){function e(t){if(Object(l.a)(this,e),this.indexedDB=N(),null==t||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t}return Object(d.a)(e,[{key:"save",value:function(){var e=Object(m.a)(b.a.mark((function e(t){return b.a.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)}}()},{key:"load",value:function(){var e=Object(m.a)(b.a.mark((function e(){return b.a.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)}}()},{key:"databaseAction",value:function(e,t){var n=this;return new Promise((function(e,r){var a=n.indexedDB.open(w,1);a.onupgradeneeded=function(){return I(a)},a.onsuccess=function(){var i=a.result;if(null==t){var o=i.transaction(j,"readonly"),s=o.objectStore(j).get(n.modelPath);s.onsuccess=function(){if(null==s.result)return i.close(),r(new Error("Cannot find model with path '".concat(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 c,u=Object(v.h)(t),l=i.transaction(S,"readwrite"),d=l.objectStore(S),f=d.put({modelPath:n.modelPath,modelArtifactsInfo:u});f.onsuccess=function(){var a=(c=i.transaction(j,"readwrite")).objectStore(j).put({modelPath:n.modelPath,modelArtifacts:t,modelArtifactsInfo:u});a.onsuccess=function(){return e({modelArtifactsInfo:u})},a.onerror=function(e){var t=(d=l.objectStore(S)).delete(n.modelPath);t.onsuccess=function(){return i.close(),r(a.error)},t.onerror=function(e){return i.close(),r(a.error)}}},f.onerror=function(e){return i.close(),r(f.error)},l.oncomplete=function(){null==c?i.close():c.oncomplete=function(){return i.close()}}}},a.onerror=function(e){return r(a.error)}}))}}]),e}();C.URL_SCHEME="indexeddb://";var T=function(e){return Object(f.b)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(C.URL_SCHEME)?(t=e.slice(C.URL_SCHEME.length),new C(t)):null;var t};g.registerSaveRouter(T),g.registerLoadRouter(T);var E=function(){function e(){Object(l.a)(this,e),this.indexedDB=N()}return Object(d.a)(e,[{key:"listModels",value:function(){var e=Object(m.a)(b.a.mark((function e(){var t=this;return b.a.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(w,1);r.onupgradeneeded=function(){return I(r)},r.onsuccess=function(){var t=r.result,a=t.transaction(S,"readonly"),i=a.objectStore(S).getAll();i.onsuccess=function(){var t,n={},r=Object(p.a)(i.result);try{for(r.s();!(t=r.n()).done;){var a=t.value;n[a.modelPath]=a.modelArtifactsInfo}}catch(o){r.e(o)}finally{r.f()}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)}}()},{key:"removeModel",value:function(){var e=Object(m.a)(b.a.mark((function e(t){var n=this;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=(r=t).startsWith(C.URL_SCHEME)?r.slice(C.URL_SCHEME.length):r,e.abrupt("return",new Promise((function(e,r){var a=n.indexedDB.open(w,1);a.onupgradeneeded=function(){return I(a)},a.onsuccess=function(){var n,i=a.result,o=i.transaction(S,"readwrite"),s=o.objectStore(S),c=s.get(t);c.onsuccess=function(){if(null==c.result)return i.close(),r(new Error("Cannot find model with path '".concat(t,"' ")+"in IndexedDB."));var a=s.delete(t),o=function(){var a=(n=i.transaction(j,"readwrite")).objectStore(j).delete(t);a.onsuccess=function(){return e(c.result.modelArtifactsInfo)},a.onerror=function(e){return r(c.error)}};a.onsuccess=o,a.onerror=function(e){return o(),i.close(),r(c.error)}},c.onerror=function(e){return i.close(),r(c.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()}var r}),e)})));return function(t){return e.apply(this,arguments)}}()}]),e}(),A=n(15),R="/",F="tensorflowjs_models",D="info",_="model_topology",M="weight_specs",z="weight_data",L="model_metadata";function P(e){return{info:[F,e,D].join(R),topology:[F,e,_].join(R),weightSpecs:[F,e,M].join(R),weightData:[F,e,z].join(R),modelMetadata:[F,e,L].join(R)}}function B(e){for(var t=0,n=Object.values(e);t0,(function(){return"scheme must not be an empty string."}));var r=e.getInstance();Object(A.b)(null==r.managers[t],(function(){return"A model store manager is already registered for scheme '".concat(t,"'.")})),r.managers[t]=n}},{key:"getManager",value:function(e){var t=this.getInstance().managers[e];if(null==t)throw new Error("Cannot find model manager for scheme '".concat(e,"'"));return t}},{key:"getSchemes",value:function(){return Object.keys(this.getInstance().managers)}}]),e}();function K(e){if(-1===e.indexOf(G))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+"".concat(q.getSchemes().join(",")));return{scheme:e.split(G)[0],path:e.split(G)[1]}}function X(e,t){return Y.apply(this,arguments)}function Y(){return(Y=Object(m.a)(b.a.mark((function e(t,n){var r,a,i,o,s,c,u,l,d,f,p=arguments;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=p.length>2&&void 0!==p[2]&&p[2],Object(A.b)(t!==n,(function(){return"Old path and new path are the same: '".concat(t,"'")})),a=g.getLoadHandlers(t),Object(A.b)(a.length>0,(function(){return"Copying failed because no load handler is found for source URL ".concat(t,".")})),Object(A.b)(a.length<2,(function(){return"Copying failed because more than one (".concat(a.length,") ")+"load handlers for source URL ".concat(t,".")})),i=a[0],o=g.getSaveHandlers(n),Object(A.b)(o.length>0,(function(){return"Copying failed because no save handler is found for destination "+"URL ".concat(n,".")})),Object(A.b)(o.length<2,(function(){return"Copying failed because more than one (".concat(a.length,") ")+"save handlers for destination URL ".concat(n,".")})),s=o[0],c=K(t).scheme,u=K(t).path,l=c===K(t).scheme,e.next=15,i.load();case 15:if(d=e.sent,!r||!l){e.next=19;break}return e.next=19,q.getManager(c).removeModel(u);case 19:return e.next=21,s.save(d);case 21:if(f=e.sent,!r||l){e.next=25;break}return e.next=25,q.getManager(c).removeModel(u);case 25:return e.abrupt("return",f.modelArtifactsInfo);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $(){return Q.apply(this,arguments)}function Q(){return(Q=Object(m.a)(b.a.mark((function e(){var t,n,r,a,i,o,s;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=q.getSchemes(),n={},r=Object(p.a)(t),e.prev=3,r.s();case 5:if((a=r.n()).done){e.next=13;break}return i=a.value,e.next=9,q.getManager(i).listModels();case 9:for(s in o=e.sent)n[i+G+s]=o[s];case 11:e.next=5;break;case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(3),r.e(e.t0);case 18:return e.prev=18,r.f(),e.finish(18);case 21:return e.abrupt("return",n);case 22:case"end":return e.stop()}}),e,null,[[3,15,18,21]])})))).apply(this,arguments)}function Z(e){return J.apply(this,arguments)}function J(){return(J=Object(m.a)(b.a.mark((function e(t){var n,r;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=K(t),r=q.getManager(n.scheme),e.abrupt("return",r.removeModel(n.path));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ee(e,t){return te.apply(this,arguments)}function te(){return(te=Object(m.a)(b.a.mark((function e(t,n){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!1,e.abrupt("return",X(t,n,false));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ne(e,t){return re.apply(this,arguments)}function re(){return(re=Object(m.a)(b.a.mark((function e(t,n){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!0,e.abrupt("return",X(t,n,true));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ae=function(){function e(){Object(l.a)(this,e)}return Object(d.a)(e,[{key:"fetch",value: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)}))},{key:"now",value:function(){return performance.now()}},{key:"encode",value:function(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error("Browser's encoder only supports utf-8, but got ".concat(t));return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}},{key:"decode",value:function(e,t){return new TextDecoder(t).decode(e)}}]),e}();if(Object(f.b)().get("IS_BROWSER")){Object(f.b)().setPlatform("browser",new ae);try{q.registerManager(U.URL_SCHEME,new H)}catch(In){}try{q.registerManager(C.URL_SCHEME,new E)}catch(In){}}n(332);var ie=n(68),oe=n(24),se=n(92),ce=n(189),ue=n(10);Object(u.b)();var le={buffer:ie.a,cast:oe.a,clone:se.a,print:ce.a};Object(ue.f)(le);var de=n(21);function fe(e){return new Promise((function(e){return setTimeout(e)})).then(e)}var pe=function(){function e(t){if(Object(l.a)(this,e),!Object(f.b)().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 Object(d.a)(e,[{key:"save",value:function(){var e=Object(m.a)(b.a.mark((function e(t){var n,r,a,i,o,s;return b.a.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=Object(v.i)(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,fe((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,fe((function(){return s.dispatchEvent(new MouseEvent("click"))}));case 21:return e.abrupt("return",{modelArtifactsInfo:Object(v.h)(t)});case 22:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}();pe.URL_SCHEME="downloads://";var he=function(){function e(t){if(Object(l.a)(this,e),null==t||t.length<1)throw new Error("When calling browserFiles, at least 1 file is required, "+"but received ".concat(t));this.jsonFile=t[0],this.weightsFiles=t.slice(1)}return Object(d.a)(e,[{key:"load",value:function(){var e=Object(m.a)(b.a.mark((function e(){var t=this;return b.a.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=Object(v.g)(a,(function(e){return t.loadWeights(e)}));e(o)}else e({modelTopology:i});else n(new Error("weightManifest field is missing from file ".concat(t.jsonFile.name)));else n(new Error("modelTopology field is missing from file ".concat(t.jsonFile.name)))},r.onerror=function(e){return n("Failed to read model topology and weights manifest JSON "+"from file '".concat(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)}}()},{key:"loadWeights",value:function(e){var t,n=this,r=[],a=[],i=Object(p.a)(e);try{for(i.s();!(t=i.n()).done;){var o=t.value;r.push.apply(r,Object(de.a)(o.weights)),a.push.apply(a,Object(de.a)(o.paths))}}catch(In){i.e(In)}finally{i.f()}var s=this.checkManifestAndWeightFiles(e),c=a.map((function(e){return n.loadWeightsFile(e,s[e])}));return Promise.all(c).then((function(e){return[r,Object(v.d)(e)]}))}},{key:"loadWeightsFile",value: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 '".concat(e,"'."))},a.readAsArrayBuffer(t)}))}},{key:"checkManifestAndWeightFiles",value:function(e){var t,n=this,r=[],a=this.weightsFiles.map((function(e){return Object(v.c)(e.name)})),i={},o=Object(p.a)(e);try{for(o.s();!(t=o.n()).done;){t.value.paths.forEach((function(e){var t=Object(v.c)(e);if(-1!==r.indexOf(t))throw new Error("Duplicate file basename found in weights manifest: "+"'".concat(t,"'"));if(r.push(t),-1===a.indexOf(t))throw new Error("Weight file with basename '".concat(t,"' is not provided."));i[e]=n.weightsFiles[a.indexOf(t)]}))}}catch(In){o.e(In)}finally{o.f()}if(r.length!==this.weightsFiles.length)throw new Error("Mismatch in the number of files in weights manifest "+"(".concat(r.length,") and the number of weight files provided ")+"(".concat(this.weightsFiles.length,")."));return i}}]),e}();function be(e){return new he(e)}g.registerSaveRouter((function(e){return Object(f.b)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(pe.URL_SCHEME)?function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"model";return new pe(e)}(e.slice(pe.URL_SCHEME.length)):null}));var me=n(6);function ve(e,t,n,r){!function(e){Object(A.b)(null!=e&&Array.isArray(e)&&e.length>0,(function(){return"promises must be a none empty array"}))}(e),function(e,t){Object(A.b)(e>=0&&e<=1,(function(){return"Progress fraction must be in range [0, 1], but "+"got startFraction ".concat(e)})),Object(A.b)(t>=0&&t<=1,(function(){return"Progress fraction must be in range [0, 1], but "+"got endFraction ".concat(t)})),Object(A.b)(t>=e,(function(){return"startFraction must be no more than endFraction, but "+"got startFraction ".concat(e," and endFraction ")+"".concat(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})))}var ge=n(183);function ye(e,t){return Oe.apply(this,arguments)}function Oe(){return(Oe=Object(m.a)(b.a.mark((function e(t,n){var r,a,i,o,s,c,u,l,d;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n&&(n={}),r=null==n.fetchFunc?Object(f.b)().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,ve(a,n.onProgress,i,o);case 13:e.t0=e.sent;case 14:if(s=e.t0,c=s.map((function(e){return e.arrayBuffer()})),u=.5,l=1,null!=n.onProgress){e.next=24;break}return e.next=21,Promise.all(c);case 21:e.t1=e.sent,e.next=27;break;case 24:return e.next=26,ve(c,n.onProgress,u,l);case 26:e.t1=e.sent;case 27:return d=e.t1,e.abrupt("return",d);case 29:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(e){return ke.apply(this,arguments)}function ke(){return(ke=Object(m.a)(b.a.mark((function e(t){var n,r,a,i,o=arguments;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:"",r=o.length>2?o[2]:void 0,a=o.length>3?o[3]:void 0,i=we((function(e){return ye(e,{requestInit:a})})),e.abrupt("return",i(t,n,r));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function we(e){return function(){var t=Object(m.a)(b.a.mark((function t(n){var r,a,i,o,s,c,u,l,d,f,p,h,m=arguments;return b.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=m.length>1&&void 0!==m[1]?m[1]:"",a=m.length>2?m[2]:void 0,i=n.map((function(){return!1})),o={},s=null!=a?a.map((function(){return!1})):[],c=[],n.forEach((function(e,t){var n=0;e.weights.forEach((function(e){var r="quantization"in e?e.quantization.dtype:e.dtype,u=ge.a[r]*A.O(e.shape),l=function(){i[t]=!0,null==o[t]&&(o[t]=[]),o[t].push({manifestEntry:e,groupOffset:n,sizeBytes:u})};null!=a?a.forEach((function(t,n){t===e.name&&(l(),s[n]=!0)})):l(),c.push(e.name),n+=u}))})),s.every((function(e){return e}))){t.next=10;break}throw u=a.filter((function(e,t){return!s[t]})),new Error("Could not find weights in manifest with names: "+"".concat(u.join(", "),". \n")+"Manifest JSON has weights with names: "+"".concat(c.join(", "),"."));case 10:return l=i.reduce((function(e,t,n){return t&&e.push(n),e}),[]),d=[],l.forEach((function(e){n[e].paths.forEach((function(e){var t=r+(r.endsWith("/")?"":"/")+e;d.push(t)}))})),t.next=15,e(d);case 15:return f=t.sent,p={},h=0,l.forEach((function(e){for(var t=n[e].paths.length,r=0,a=0;a0,(function(){return"URL path for http must not be null, undefined or empty."})),Array.isArray(t)&&Object(A.b)(2===t.length,(function(){return"URL paths for http must have a length of 2, "+"(actual length is ".concat(t.length,").")})),this.path=t,null!=n.requestInit&&null!=n.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=n.requestInit||{}}return Object(d.a)(e,[{key:"save",value:function(){var e=Object(m.a)(b.a.mark((function e(t){var n,r,a,i;return b.a.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=Object(v.i)(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:Object(v.h)(t),responses:[i]});case 15:throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+"".concat(i.status,"."));case 16:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"load",value:function(){var e=Object(m.a)(b.a.mark((function e(){var t,n,r,a,i,o=this;return b.a.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 ".concat(this.path," failed with status code ")+"".concat(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 ".concat(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 ".concat(this.path," contains neither model ")+"topology or manifest for weights.");case 20:return e.abrupt("return",Object(v.g)(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)}}()},{key:"loadWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){var n,r,a,i,o,s,c,u,l,d,f,h,m,g,y,O,x,k,w;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=Array.isArray(this.path)?this.path[1]:this.path,r=Se(n),a=Object(me.a)(r,2),i=a[0],o=a[1],s=this.weightPathPrefix||i,c=[],u=Object(p.a)(t);try{for(u.s();!(l=u.n()).done;)d=l.value,c.push.apply(c,Object(de.a)(d.weights))}catch(In){u.e(In)}finally{u.f()}f=[],h=[],m=Object(p.a)(t);try{for(m.s();!(g=m.n()).done;){y=g.value,O=Object(p.a)(y.paths);try{for(O.s();!(x=O.n()).done;)k=x.value,null!=this.weightUrlConverter?h.push(this.weightUrlConverter(k)):f.push(s+k+o)}catch(In){O.e(In)}finally{O.f()}}}catch(In){m.e(In)}finally{m.f()}if(!this.weightUrlConverter){e.next=19;break}return e.t0=f.push,e.t1=f,e.t2=de.a,e.next=16,Promise.all(h);case 16:e.t3=e.sent,e.t4=(0,e.t2)(e.t3),e.t0.apply.call(e.t0,e.t1,e.t4);case 19:return e.next=21,ye(f,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});case 21:return w=e.sent,e.abrupt("return",[c,Object(v.d)(w)]);case 23:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}();function Se(e){var t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}function Ne(e){return null!=e.match(je.URL_SCHEME_REGEX)}je.URL_SCHEME_REGEX=/^https?:\/\//;var Ie=function(e,t){if("undefined"===typeof fetch&&(null==t||null==t.fetchFunc))return null;return(Array.isArray(e)?e.every((function(e){return Ne(e)})):Ne(e))?Ce(e,t):null};function Ce(e,t){return new je(e,t)}function Te(e,t){return Ce(e,t)}g.registerSaveRouter(Ie),g.registerLoadRouter(Ie);var Ee=function(){function e(t){Object(l.a)(this,e),this.modelArtifacts=t}return Object(d.a)(e,[{key:"load",value:function(){var e=Object(m.a)(b.a.mark((function e(){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.modelArtifacts);case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),e}(),Ae=function(){function e(t){Object(l.a)(this,e),this.saveHandler=t}return Object(d.a)(e,[{key:"save",value:function(){var e=Object(m.a)(b.a.mark((function e(t){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.saveHandler(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}();function Re(e,t,n,r){if(1===arguments.length){var a=null!=e.modelTopology||null!=e.weightSpecs;return a?new Ee(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 Ee({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 Ee({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r})}function Fe(e){return new Ae(e)}var De,_e=n(3),Me=n(85),ze=n(2),Le=n(8),Pe=n(220);function Be(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;if(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 ".concat(e.constructor.name));s=!0}if(a){var c=2;if(a&&e.readyState element.")}var l=Object(Me.b)(_e.ib,u.a.backendName);if(null!=l){var d={pixels:e},f={numChannels:t};return u.a.runKernel(_e.ib,d,f)}var p,h,b=a?[e.videoWidth,e.videoHeight]:[e.width,e.height],m=Object(me.a)(b,2),v=m[0],g=m[1];if(o?p=e.getContext("2d").getImageData(0,0,v,g).data:r||n?p=e.data:(i||a||s)&&(null==De&&(De=document.createElement("canvas").getContext("2d")),De.canvas.width=v,De.canvas.height=g,De.drawImage(e,0,0,v,g),p=De.getImageData(0,0,v,g).data),4===t)h=new Int32Array(p);else{var y=v*g;h=new Int32Array(y*t);for(var O=0;O1&&void 0!==i[1]?i[1]:3,r=null,!Object(f.b)().getBool("WRAP_TO_IMAGEBITMAP")||!We(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",Be(r,n));case 17:case"end":return e.stop()}}),e,null,[[3,9]])})))).apply(this,arguments)}function He(e,t){return Ge.apply(this,arguments)}function Ge(){return(Ge=Object(m.a)(b.a.mark((function e(t,n){var r,a,i,o,s,c,u,l,d,f,p,h,m,v,g,y,O;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Object(ze.a)(t,"img","toPixels"),t instanceof ue.a||(a=r,r=Object(oe.a)(a,"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 ".concat(r.rank,"."));case 4:if(i=r.shape.slice(0,2),o=Object(me.a)(i,2),s=o[0],c=o[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 ".concat(u));case 8:if("float32"===r.dtype||"int32"===r.dtype){e.next=10;break}throw new Error("Unsupported type for toPixels: ".concat(r.dtype,".")+" Please use float32 or int32 tensors.");case 10:return e.next=12,r.data();case 12:l=e.sent,d="float32"===r.dtype?255:1,f=new Uint8ClampedArray(c*s*4),p=0;case 16:if(!(p1)){e.next=24;break}throw new Error("Tensor values for a float32 Tensor must be in the "+"range [0 - 1] but encountered ".concat(v,"."));case 24:e.next=29;break;case 26:if("int32"!==r.dtype){e.next=29;break}if(!(v<0||v>255)){e.next=29;break}throw new Error("Tensor values for a int32 Tensor must be in the "+"range [0 - 255] but encountered ".concat(v,"."));case 29:1===u?(h[0]=v*d,h[1]=v*d,h[2]=v*d):h[m]=v*d;case 30:m++,e.next=19;break;case 33:f[(g=4*p)+0]=Math.round(h[0]),f[g+1]=Math.round(h[1]),f[g+2]=Math.round(h[2]),f[g+3]=Math.round(h[3]);case 38:++p,e.next=16;break;case 41:return null!=n&&(n.width=c,n.height=s,y=n.getContext("2d"),O=new ImageData(f,c,s),y.putImageData(O,0,0)),r!==t&&r.dispose(),e.abrupt("return",f);case 44:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var qe=Object(Le.b)({fromPixels_:Be}),Ke=n(142),Xe=function(){function e(){Object(l.a)(this,e)}return Object(d.a)(e,[{key:"getClassName",value:function(){return this.constructor.className}}],[{key:"fromConfig",value:function(e,t){return new e(t)}}]),e}(),Ye=function(){function e(){Object(l.a)(this,e),this.classNameMap={}}return Object(d.a)(e,null,[{key:"getMap",value:function(){return null==e.instance&&(e.instance=new e),e.instance}},{key:"register",value:function(t){e.getMap().classNameMap[t.className]=[t,t.fromConfig]}}]),e}();function $e(e){Object(A.b)(null!=e.className,(function(){return"Class being registered does not have the static className property defined."})),Object(A.b)("string"===typeof e.className,(function(){return"className is required to be a string, but got type "+typeof e.className})),Object(A.b)(e.className.length>0,(function(){return"Class being registered has an empty-string as its className, which is disallowed."})),Ye.register(e)}var Qe=n(39),Ze=n(19),Je="3.8.0",et=n(16),tt=n(17),nt=n(44),rt=n(55),at=n(33),it=function(e){Object(et.a)(n,e);var t=Object(tt.a)(n);function n(){return Object(l.a)(this,n),t.apply(this,arguments)}return Object(d.a)(n,[{key:"minimize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,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 Object(nt.b)(i),t?a:(a.dispose(),null)}},{key:"iterations",get:function(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}},{key:"incrementIterations",value:function(){this.iterations_=this.iterations+1}},{key:"computeGradients",value:function(e,t){return Object(rt.b)(e,t)}},{key:"dispose",value:function(){null!=this.iterations_&&Object(nt.b)(this.iterations_)}},{key:"saveIterations",value:function(){var e=Object(m.a)(b.a.mark((function e(){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==this.iterations_&&(this.iterations_=0),e.abrupt("return",{name:"iter",tensor:Object(at.a)(this.iterations_,"int32")});case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"getWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(){return b.a.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)}}()},{key:"setWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("setWeights() is not implemented for this optimizer class "+"".concat(this.getClassName()));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"extractIterations",value:function(){var e=Object(m.a)(b.a.mark((function e(t){return b.a.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)}}()}]),n}(Xe);Object.defineProperty(it,Symbol.hasInstance,{value:function(e){return null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients}});var ot=n(114),st=n(37),ct=n(27),ut=n(31),lt=n(18),dt=n(58),ft=n(40),pt=n(36),ht=function(e){Object(et.a)(n,e);var t=Object(tt.a)(n);function n(e,r){var a,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return Object(l.a)(this,n),(a=t.call(this)).learningRate=e,a.rho=r,a.epsilon=i,a.accumulatedGrads=[],a.accumulatedUpdates=[],null==i&&(a.epsilon=u.a.backend.epsilon()),a}return Object(d.a)(n,[{key:"applyGradients",value:function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=u.a.registeredVariables[n];null==t.accumulatedGrads[r]&&(t.accumulatedGrads[r]={originalName:"".concat(n,"/accum_grad"),variable:Object(nt.h)((function(){return Object(pt.a)(a).variable(false)}))}),null==t.accumulatedUpdates[r]&&(t.accumulatedUpdates[r]={originalName:"".concat(n,"/accum_var"),variable:Object(nt.h)((function(){return Object(pt.a)(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;Object(nt.h)((function(){var e=Object(ct.a)(Object(lt.a)(o,t.rho),Object(lt.a)(Object(ft.a)(i),1-t.rho)),n=Object(lt.a)(Object(ut.a)(Object(dt.a)(Object(ct.a)(s,t.epsilon)),Object(dt.a)(Object(ct.a)(o,t.epsilon))),i),r=Object(ct.a)(Object(lt.a)(s,t.rho),Object(lt.a)(Object(ft.a)(n),1-t.rho));o.assign(e),s.assign(r);var c=Object(ct.a)(Object(lt.a)(n,-t.learningRate),a);a.assign(c)}))}})),this.incrementIterations()}},{key:"dispose",value:function(){null!=this.accumulatedUpdates&&(Object(nt.b)(this.accumulatedGrads.map((function(e){return e.variable}))),Object(nt.b)(this.accumulatedUpdates.map((function(e){return e.variable}))))}},{key:"getWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(){var t;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(Object(de.a)(this.accumulatedGrads),Object(de.a)(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)}}()},{key:"setWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){var n;return b.a.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)}}()},{key:"getConfig",value:function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}}],[{key:"fromConfig",value:function(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}]),n}(it);ht.className="Adadelta",$e(ht);var bt=n(118),mt=function(e){Object(et.a)(n,e);var t=Object(tt.a)(n);function n(e){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.1;return Object(l.a)(this,n),(r=t.call(this)).learningRate=e,r.initialAccumulatorValue=a,r.accumulatedGrads=[],r}return Object(d.a)(n,[{key:"applyGradients",value:function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=u.a.registeredVariables[n];if(null==t.accumulatedGrads[r]){t.accumulatedGrads[r]={originalName:"".concat(n,"/accumulator"),variable:Object(nt.h)((function(){return Object(bt.a)(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;Object(nt.h)((function(){var e=Object(ct.a)(o,Object(ft.a)(i));o.assign(e);var n=Object(ct.a)(Object(lt.a)(Object(ut.a)(i,Object(dt.a)(Object(ct.a)(e,u.a.backend.epsilon()))),-t.learningRate),a);a.assign(n)}))}})),this.incrementIterations()}},{key:"dispose",value:function(){null!=this.accumulatedGrads&&Object(nt.b)(this.accumulatedGrads.map((function(e){return e.variable})))}},{key:"getWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(){return b.a.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)}}()},{key:"setWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){return b.a.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)}}()},{key:"getConfig",value:function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}}],[{key:"fromConfig",value:function(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}]),n}(it);mt.className="Adagrad",$e(mt);var vt=n(73),gt=n(29),yt=function(e){Object(et.a)(n,e);var t=Object(tt.a)(n);function n(e,r,a){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return Object(l.a)(this,n),(i=t.call(this)).learningRate=e,i.beta1=r,i.beta2=a,i.epsilon=o,i.accumulatedFirstMoment=[],i.accumulatedSecondMoment=[],Object(nt.h)((function(){i.accBeta1=Object(at.a)(r).variable(),i.accBeta2=Object(at.a)(a).variable()})),null==o&&(i.epsilon=u.a.backend.epsilon()),i}return Object(d.a)(n,[{key:"applyGradients",value:function(e){var t=this,n=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e);Object(nt.h)((function(){var r=Object(gt.a)(1,t.accBeta1),a=Object(gt.a)(1,t.accBeta2);n.forEach((function(n,i){var o=u.a.registeredVariables[n];null==t.accumulatedFirstMoment[i]&&(t.accumulatedFirstMoment[i]={originalName:"".concat(n,"/m"),variable:Object(nt.h)((function(){return Object(pt.a)(o).variable(false)}))}),null==t.accumulatedSecondMoment[i]&&(t.accumulatedSecondMoment[i]={originalName:"".concat(n,"/v"),variable:Object(nt.h)((function(){return Object(pt.a)(o).variable(false)}))});var s=Array.isArray(e)?e[i].tensor:e[n];if(null!=s){var c=t.accumulatedFirstMoment[i].variable,l=t.accumulatedSecondMoment[i].variable,d=Object(ct.a)(Object(lt.a)(c,t.beta1),Object(lt.a)(s,1-t.beta1)),f=Object(ct.a)(Object(lt.a)(l,t.beta2),Object(lt.a)(Object(ft.a)(s),1-t.beta2)),p=Object(ut.a)(d,r),h=Object(ut.a)(f,a);c.assign(d),l.assign(f);var b=Object(ct.a)(Object(lt.a)(Object(ut.a)(p,Object(ct.a)(Object(dt.a)(h),t.epsilon)),-t.learningRate),o);o.assign(b)}})),t.accBeta1.assign(Object(lt.a)(t.accBeta1,t.beta1)),t.accBeta2.assign(Object(lt.a)(t.accBeta2,t.beta2))})),this.incrementIterations()}},{key:"dispose",value:function(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&Object(nt.b)(this.accumulatedFirstMoment.map((function(e){return e.variable}))),null!=this.accumulatedSecondMoment&&Object(nt.b)(this.accumulatedSecondMoment.map((function(e){return e.variable})))}},{key:"getWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(){var t;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(Object(de.a)(this.accumulatedFirstMoment),Object(de.a)(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)}}()},{key:"setWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){var n,r=this;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,Object(nt.h)((function(){r.accBeta1.assign(Object(vt.a)(r.beta1,r.iterations_+1)),r.accBeta2.assign(Object(vt.a)(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)}}()},{key:"getConfig",value:function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}}],[{key:"fromConfig",value:function(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}]),n}(it);yt.className="Adam",$e(yt);var Ot=n(65),xt=n(121),kt=function(e){Object(et.a)(n,e);var t=Object(tt.a)(n);function n(e,r,a){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;return Object(l.a)(this,n),(i=t.call(this)).learningRate=e,i.beta1=r,i.beta2=a,i.epsilon=o,i.decay=s,i.accumulatedFirstMoment=[],i.accumulatedWeightedInfNorm=[],Object(nt.h)((function(){i.iteration=Object(at.a)(0).variable(),i.accBeta1=Object(at.a)(r).variable()})),null==o&&(i.epsilon=u.a.backend.epsilon()),i}return Object(d.a)(n,[{key:"applyGradients",value:function(e){var t=this,n=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e);Object(nt.h)((function(){var r=Object(gt.a)(1,t.accBeta1),a=Object(ut.a)(-t.learningRate,Object(ct.a)(Object(lt.a)(t.iteration,t.decay),1));n.forEach((function(n,i){var o=u.a.registeredVariables[n];null==t.accumulatedFirstMoment[i]&&(t.accumulatedFirstMoment[i]={originalName:"".concat(n,"/m"),variable:Object(pt.a)(o).variable(false)}),null==t.accumulatedWeightedInfNorm[i]&&(t.accumulatedWeightedInfNorm[i]={originalName:"".concat(n,"/v"),variable:Object(pt.a)(o).variable(false)});var s=Array.isArray(e)?e[i].tensor:e[n];if(null!=s){var c=t.accumulatedFirstMoment[i].variable,l=t.accumulatedWeightedInfNorm[i].variable,d=Object(ct.a)(Object(lt.a)(c,t.beta1),Object(lt.a)(s,1-t.beta1)),f=Object(lt.a)(l,t.beta2),p=Object(Ot.a)(s),h=Object(xt.a)(f,p);c.assign(d),l.assign(h);var b=Object(ct.a)(Object(lt.a)(Object(ut.a)(a,r),Object(ut.a)(d,Object(ct.a)(h,t.epsilon))),o);o.assign(b)}})),t.iteration.assign(Object(ct.a)(t.iteration,1)),t.accBeta1.assign(Object(lt.a)(t.accBeta1,t.beta1))})),this.incrementIterations()}},{key:"dispose",value:function(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&Object(nt.b)(this.accumulatedFirstMoment.map((function(e){return e.variable}))),null!=this.accumulatedWeightedInfNorm&&Object(nt.b)(this.accumulatedWeightedInfNorm.map((function(e){return e.variable})))}},{key:"getWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(){return b.a.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)}}()},{key:"setWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){return b.a.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)}}()},{key:"getConfig",value:function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}}],[{key:"fromConfig",value:function(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}]),n}(it);kt.className="Adamax",$e(kt);var wt=function(e){Object(et.a)(n,e);var t=Object(tt.a)(n);function n(e){var r;return Object(l.a)(this,n),(r=t.call(this)).learningRate=e,r.setLearningRate(e),r}return Object(d.a)(n,[{key:"applyGradients",value: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=u.a.registeredVariables[n];Object(nt.h)((function(){var e=Object(ct.a)(Object(lt.a)(t.c,a),i);i.assign(e)}))}})),this.incrementIterations()}},{key:"setLearningRate",value:function(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=Object(nt.d)(Object(at.a)(-e))}},{key:"dispose",value:function(){this.c.dispose()}},{key:"getWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(){return b.a.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)}}()},{key:"setWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){return b.a.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)}}()},{key:"getConfig",value:function(){return{learningRate:this.learningRate}}}],[{key:"fromConfig",value:function(e,t){return new e(t.learningRate)}}]),n}(it);wt.className="SGD",$e(wt);var jt=function(e){Object(et.a)(n,e);var t=Object(tt.a)(n);function n(e,r){var a,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Object(l.a)(this,n),(a=t.call(this,e)).learningRate=e,a.momentum=r,a.useNesterov=i,a.accumulations=[],a.m=Object(at.a)(a.momentum),a}return Object(d.a)(n,[{key:"applyGradients",value:function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=u.a.registeredVariables[n];if(null==t.accumulations[r]){t.accumulations[r]={originalName:"".concat(n,"/momentum"),variable:Object(nt.h)((function(){return Object(pt.a)(a).variable(false)}))}}var i=t.accumulations[r].variable,o=Array.isArray(e)?e[r].tensor:e[n];null!=o&&Object(nt.h)((function(){var e,n=Object(ct.a)(Object(lt.a)(t.m,i),o);e=t.useNesterov?Object(ct.a)(Object(lt.a)(t.c,Object(ct.a)(o,Object(lt.a)(n,t.m))),a):Object(ct.a)(Object(lt.a)(t.c,n),a),i.assign(n),a.assign(e)}))})),this.incrementIterations()}},{key:"dispose",value:function(){this.m.dispose(),null!=this.accumulations&&Object(nt.b)(this.accumulations.map((function(e){return e.variable})))}},{key:"setMomentum",value:function(e){this.momentum=e}},{key:"getWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(){return b.a.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)}}()},{key:"setWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){return b.a.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)}}()},{key:"getConfig",value:function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}}],[{key:"fromConfig",value:function(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}]),n}(wt);jt.className="Momentum",$e(jt);var St=function(e){Object(et.a)(n,e);var t=Object(tt.a)(n);function n(e){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.9,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Object(l.a)(this,n),(r=t.call(this)).learningRate=e,r.decay=a,r.momentum=i,r.epsilon=o,r.accumulatedMeanSquares=[],r.accumulatedMoments=[],r.accumulatedMeanGrads=[],r.centered=s,null==o&&(r.epsilon=u.a.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.");return r}return Object(d.a)(n,[{key:"applyGradients",value:function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=u.a.registeredVariables[n],i=!1;null==t.accumulatedMeanSquares[r]&&(t.accumulatedMeanSquares[r]={originalName:"".concat(n,"/rms"),variable:Object(nt.h)((function(){return Object(pt.a)(a).variable(i)}))}),null==t.accumulatedMoments[r]&&(t.accumulatedMoments[r]={originalName:"".concat(n,"/momentum"),variable:Object(nt.h)((function(){return Object(pt.a)(a).variable(i)}))}),null==t.accumulatedMeanGrads[r]&&t.centered&&(t.accumulatedMeanGrads[r]={originalName:"".concat(n,"/mg"),variable:Object(nt.h)((function(){return Object(pt.a)(a).variable(i)}))});var o=Array.isArray(e)?e[r].tensor:e[n];if(null!=o){var s=t.accumulatedMeanSquares[r].variable,c=t.accumulatedMoments[r].variable;Object(nt.h)((function(){var e=Object(ct.a)(Object(lt.a)(s,t.decay),Object(lt.a)(Object(ft.a)(o),1-t.decay));if(t.centered){var n=t.accumulatedMeanGrads[r].variable,i=Object(ct.a)(Object(lt.a)(n,t.decay),Object(lt.a)(o,1-t.decay)),u=Object(ut.a)(Object(lt.a)(o,t.learningRate),Object(dt.a)(Object(gt.a)(e,Object(ct.a)(Object(ft.a)(i),t.epsilon)))),l=Object(ct.a)(Object(lt.a)(c,t.momentum),u);s.assign(e),n.assign(i),c.assign(l);var d=Object(gt.a)(a,l);a.assign(d)}else{var f=Object(ct.a)(Object(lt.a)(s,t.decay),Object(lt.a)(Object(ft.a)(o),1-t.decay)),p=Object(ct.a)(Object(lt.a)(c,t.momentum),Object(ut.a)(Object(lt.a)(o,t.learningRate),Object(dt.a)(Object(ct.a)(f,t.epsilon))));s.assign(f),c.assign(p);var h=Object(gt.a)(a,p);a.assign(h)}}))}})),this.incrementIterations()}},{key:"dispose",value:function(){null!=this.accumulatedMeanSquares&&Object(nt.b)(this.accumulatedMeanSquares.map((function(e){return e.variable}))),null!=this.accumulatedMeanGrads&&this.centered&&Object(nt.b)(this.accumulatedMeanGrads.map((function(e){return e.variable}))),null!=this.accumulatedMoments&&Object(nt.b)(this.accumulatedMoments.map((function(e){return e.variable})))}},{key:"getWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(){var t;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(Object(de.a)(this.accumulatedMeanSquares),Object(de.a)(this.accumulatedMoments)),this.centered&&t.push.apply(t,Object(de.a)(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)}}()},{key:"setWeights",value:function(){var e=Object(m.a)(b.a.mark((function e(t){var n,r;return b.a.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)}}()},{key:"getConfig",value:function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}}],[{key:"fromConfig",value:function(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}]),n}(it);St.className="RMSProp",$e(St);var Nt=function(){function e(){Object(l.a)(this,e)}return Object(d.a)(e,null,[{key:"sgd",value:function(e){return new wt(e)}},{key:"momentum",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return new jt(e,t,n)}},{key:"rmsprop",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.9,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return new St(e,t,n,r,a)}},{key:"adam",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.001,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.9,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.999,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return new yt(e,t,n,r)}},{key:"adadelta",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.001,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.95,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new ht(e,t,n)}},{key:"adamax",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.002,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.9,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.999,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;return new kt(e,t,n,r,a)}},{key:"adagrad",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.1;return new mt(e,t)}}]),e}(),It={sgd:Nt.sgd,momentum:Nt.momentum,adadelta:Nt.adadelta,adagrad:Nt.adagrad,rmsprop:Nt.rmsprop,adamax:Nt.adamax,adam:Nt.adam},Ct=n(283),Tt=n(60),Et=n(34);function At(e,t){var n=e[0].length;e.forEach((function(e,t){A.b(e.length===n,(function(){return"Error in concat".concat(n,"D: rank of tensors[").concat(t,"] must be the same ")+"as the rank of the rest (".concat(n,")")}))})),A.b(t>=0&&t3&&void 0!==arguments[3])||arguments[3],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;o2&&void 0!==arguments[2])||arguments[2],r=[];if(n){r.push(t);for(var a=t+1;a=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 Bt(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(var i=1;in)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+"".concat(t.shape[r-1]," vs. ").concat(n));if(0===Object(A.O)(e.shape))throw new Error("Requested more than 0 entries, but input is empty."+" Input shape: ".concat(e.shape,"."));for(var a=t.shape,i=a[a.length-1],o=1,s=0;s/g;function dn(e,t){var n=((e=e.replace(/\s/g,"")).length-e.replace(ln,"").length)/un.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 ("'.concat(un,'").'));var r=e.split(un),a=Object(me.a)(r,2),i=a[0],o=a[1];Object(A.b)(-1===i.indexOf("..."),(function(){return'The ellipsis notation ("'.concat("...",'") is not supported yet.')}));var s=i.split(","),c=s.length;if(t!==c)throw new Error("Expected ".concat(c," input tensors, received ").concat(t));if(c>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");for(var u=[],l=function(e){var t=o[e];if(!s.some((function(e){return-1!==e.indexOf(t)})))throw new Error("Output subscripts contain the label ".concat(t," ")+"not present in the input subscripts.");-1===u.indexOf(t)&&u.push(t)},d=0;d2&&void 0!==arguments[2]?arguments[2]:0,r=[];if("number"===typeof t)Object(A.b)(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);Object(A.b)(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}Object(A.b)(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 gn(e,t){var n,r=!1;for(e<=_t?(n=e,r=!0):n=Object(A.G)(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=Object(A.G)(e,n+1);return n}function yn(e,t,n){for(var r=[],a=e.length,i=0;ia))throw new Error("Expect batchDims in the range of [-".concat(a,", ").concat(a,"], but got ").concat(r));if(r<0&&(r+=a),r>i)throw new Error("batchDims (".concat(r,") must be less than rank(x) (\n ").concat(i,")."));if(n0,(function(){return"Element arr[".concat(n.join("]["),"] should be a primitive, ")+"but is an array of ".concat(e.length," elements")})),Object(o.b)(e.length===t[0],(function(){return"Element arr[".concat(n.join("]["),"] should have ").concat(t[0]," ")+"elements, but has ".concat(e.length," elements")}));for(var r=t.slice(1),a=0;a3&&void 0!==arguments[3]?arguments[3]:"numeric";if(e instanceof i.a)return l(a,e.dtype,t,n),e;var u=Object(o.r)(e);if("string"!==u&&["bool","int32","float32"].indexOf(a)>=0&&(u=a),l(a,u,t,n),null==e||!Object(o.A)(e)&&!Array.isArray(e)&&"number"!==typeof e&&"boolean"!==typeof e&&"string"!==typeof e){var d=null==e?"null":e.constructor.name;throw new Error("Argument '".concat(t,"' passed to '").concat(n,"' must be a ")+"Tensor or TensorLike, but got '".concat(d,"'"))}var f=c(e,u);Object(o.A)(e)||Array.isArray(e)||(e=[e]);var p=!0,h="string"!==u?Object(s.toTypedArray)(e,u):Object(o.m)(e,[],p);return r.a.makeTensor(h,f,u)}function f(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"numeric";if(!Array.isArray(e))throw new Error("Argument ".concat(t," passed to ").concat(n," must be a ")+"`Tensor[]` or `TensorLike[]`");var a=e;return a.map((function(e,a){return d(e,"".concat(t,"[").concat(a,"]"),n,r)}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return i})),n.d(t,"d",(function(){return o})),n.d(t,"e",(function(){return s})),n.d(t,"f",(function(){return c})),n.d(t,"g",(function(){return u})),n.d(t,"h",(function(){return l})),n.d(t,"i",(function(){return d})),n.d(t,"j",(function(){return f})),n.d(t,"k",(function(){return p})),n.d(t,"l",(function(){return h})),n.d(t,"n",(function(){return b})),n.d(t,"m",(function(){return m})),n.d(t,"o",(function(){return v})),n.d(t,"r",(function(){return g})),n.d(t,"p",(function(){return y})),n.d(t,"q",(function(){return O})),n.d(t,"s",(function(){return x})),n.d(t,"t",(function(){return k})),n.d(t,"u",(function(){return w})),n.d(t,"v",(function(){return j})),n.d(t,"w",(function(){return S})),n.d(t,"x",(function(){return N})),n.d(t,"y",(function(){return I})),n.d(t,"z",(function(){return C})),n.d(t,"A",(function(){return T})),n.d(t,"B",(function(){return E})),n.d(t,"C",(function(){return A})),n.d(t,"D",(function(){return R})),n.d(t,"E",(function(){return F})),n.d(t,"F",(function(){return D})),n.d(t,"G",(function(){return _})),n.d(t,"H",(function(){return M})),n.d(t,"I",(function(){return z})),n.d(t,"J",(function(){return L})),n.d(t,"L",(function(){return P})),n.d(t,"K",(function(){return B})),n.d(t,"M",(function(){return W})),n.d(t,"N",(function(){return U})),n.d(t,"O",(function(){return V})),n.d(t,"P",(function(){return H})),n.d(t,"Q",(function(){return G})),n.d(t,"R",(function(){return q})),n.d(t,"S",(function(){return K})),n.d(t,"U",(function(){return X})),n.d(t,"T",(function(){return Y})),n.d(t,"kc",(function(){return $})),n.d(t,"V",(function(){return Q})),n.d(t,"W",(function(){return Z})),n.d(t,"X",(function(){return J})),n.d(t,"Z",(function(){return ee})),n.d(t,"Y",(function(){return te})),n.d(t,"ab",(function(){return ne})),n.d(t,"bb",(function(){return re})),n.d(t,"cb",(function(){return ae})),n.d(t,"db",(function(){return ie})),n.d(t,"eb",(function(){return oe})),n.d(t,"fb",(function(){return se})),n.d(t,"gb",(function(){return ce})),n.d(t,"hb",(function(){return ue})),n.d(t,"jb",(function(){return le})),n.d(t,"nb",(function(){return de})),n.d(t,"mb",(function(){return fe})),n.d(t,"ob",(function(){return pe})),n.d(t,"pb",(function(){return he})),n.d(t,"rb",(function(){return be})),n.d(t,"qb",(function(){return me})),n.d(t,"sb",(function(){return ve})),n.d(t,"tb",(function(){return ge})),n.d(t,"ub",(function(){return ye})),n.d(t,"vb",(function(){return Oe})),n.d(t,"yb",(function(){return xe})),n.d(t,"zb",(function(){return ke})),n.d(t,"Ab",(function(){return we})),n.d(t,"Bb",(function(){return je})),n.d(t,"Cb",(function(){return Se})),n.d(t,"Db",(function(){return Ne})),n.d(t,"Fb",(function(){return Ie})),n.d(t,"Gb",(function(){return Ce})),n.d(t,"Hb",(function(){return Te})),n.d(t,"Eb",(function(){return Ee})),n.d(t,"wb",(function(){return Ae})),n.d(t,"xb",(function(){return Re})),n.d(t,"Ib",(function(){return Fe})),n.d(t,"Ob",(function(){return De})),n.d(t,"Jb",(function(){return _e})),n.d(t,"Mb",(function(){return Me})),n.d(t,"Kb",(function(){return ze})),n.d(t,"Lb",(function(){return Le})),n.d(t,"Nb",(function(){return Pe})),n.d(t,"Pb",(function(){return Be})),n.d(t,"Qb",(function(){return We})),n.d(t,"Rb",(function(){return Ue})),n.d(t,"Sb",(function(){return Ve})),n.d(t,"Tb",(function(){return He})),n.d(t,"Ub",(function(){return Ge})),n.d(t,"Vb",(function(){return qe})),n.d(t,"Wb",(function(){return Ke})),n.d(t,"ac",(function(){return Xe})),n.d(t,"Xb",(function(){return Ye})),n.d(t,"Yb",(function(){return $e})),n.d(t,"Zb",(function(){return Qe})),n.d(t,"cc",(function(){return Ze})),n.d(t,"bc",(function(){return Je})),n.d(t,"dc",(function(){return et})),n.d(t,"ec",(function(){return tt})),n.d(t,"fc",(function(){return nt})),n.d(t,"gc",(function(){return rt})),n.d(t,"hc",(function(){return at})),n.d(t,"ic",(function(){return it})),n.d(t,"jc",(function(){return ot})),n.d(t,"lc",(function(){return st})),n.d(t,"mc",(function(){return ct})),n.d(t,"oc",(function(){return ut})),n.d(t,"rc",(function(){return lt})),n.d(t,"sc",(function(){return dt})),n.d(t,"pc",(function(){return ft})),n.d(t,"qc",(function(){return pt})),n.d(t,"nc",(function(){return ht})),n.d(t,"tc",(function(){return bt})),n.d(t,"vc",(function(){return mt})),n.d(t,"wc",(function(){return vt})),n.d(t,"xc",(function(){return gt})),n.d(t,"yc",(function(){return yt})),n.d(t,"zc",(function(){return Ot})),n.d(t,"Ec",(function(){return xt})),n.d(t,"Cc",(function(){return kt})),n.d(t,"Dc",(function(){return wt})),n.d(t,"Bc",(function(){return jt})),n.d(t,"Ac",(function(){return St})),n.d(t,"Gc",(function(){return Nt})),n.d(t,"Oc",(function(){return It})),n.d(t,"Xc",(function(){return Ct})),n.d(t,"Hc",(function(){return Tt})),n.d(t,"Nc",(function(){return Et})),n.d(t,"Fc",(function(){return At})),n.d(t,"Ic",(function(){return Rt})),n.d(t,"Jc",(function(){return Ft})),n.d(t,"Kc",(function(){return Dt})),n.d(t,"Lc",(function(){return _t})),n.d(t,"Mc",(function(){return Mt})),n.d(t,"Qc",(function(){return zt})),n.d(t,"Pc",(function(){return Lt})),n.d(t,"Sc",(function(){return Pt})),n.d(t,"Tc",(function(){return Bt})),n.d(t,"Uc",(function(){return Wt})),n.d(t,"Vc",(function(){return Ut})),n.d(t,"Wc",(function(){return Vt})),n.d(t,"Yc",(function(){return Ht})),n.d(t,"Zc",(function(){return Gt})),n.d(t,"ad",(function(){return qt})),n.d(t,"bd",(function(){return Kt})),n.d(t,"cd",(function(){return Xt})),n.d(t,"dd",(function(){return Yt})),n.d(t,"ed",(function(){return $t})),n.d(t,"fd",(function(){return Qt})),n.d(t,"gd",(function(){return Zt})),n.d(t,"hd",(function(){return Jt})),n.d(t,"Rc",(function(){return en})),n.d(t,"ib",(function(){return tn})),n.d(t,"uc",(function(){return nn})),n.d(t,"id",(function(){return rn})),n.d(t,"kb",(function(){return an})),n.d(t,"lb",(function(){return on}));var r="Abs",a="Acos",i="Acosh",o="Add",s="AddN",c="All",u="Any",l="ArgMax",d="ArgMin",f="Asin",p="Asinh",h="Atan",b="Atanh",m="Atan2",v="AvgPool",g="AvgPoolGrad",y="AvgPool3D",O="AvgPool3DGrad",x="BatchMatMul",k="BatchToSpaceND",w="Bincount",j="BroadcastTo",S="Cast",N="Ceil",I="ClipByValue",C="Complex",T="ComplexAbs",E="Concat",A="Conv2D",R="Conv2DBackpropFilter",F="Conv2DBackpropInput",D="Conv3D",_="Conv3DBackpropFilterV2",M="Conv3DBackpropInputV2",z="Cos",L="Cosh",P="Cumsum",B="CropAndResize",W="DenseBincount",U="DepthToSpace",V="DepthwiseConv2dNative",H="DepthwiseConv2dNativeBackpropFilter",G="DepthwiseConv2dNativeBackpropInput",q="Diag",K="Dilation2D",X="Dilation2DBackpropInput",Y="Dilation2DBackpropFilter",$="RealDiv",Q="Einsum",Z="Elu",J="EluGrad",ee="Erf",te="Equal",ne="Exp",re="ExpandDims",ae="Expm1",ie="FFT",oe="Fill",se="FlipLeftRight",ce="Floor",ue="FloorDiv",le="FusedBatchNorm",de="GatherV2",fe="GatherNd",pe="Greater",he="GreaterEqual",be="Identity",me="IFFT",ve="Imag",ge="IsFinite",ye="IsInf",Oe="IsNan",xe="LeakyRelu",ke="Less",we="LessEqual",je="LinSpace",Se="Log",Ne="Log1p",Ie="LogicalAnd",Ce="LogicalNot",Te="LogicalOr",Ee="LogSoftmax",Ae="LRN",Re="LRNGrad",Fe="Max",De="Maximum",_e="MaxPool",Me="MaxPoolGrad",ze="MaxPool3D",Le="MaxPool3DGrad",Pe="MaxPoolWithArgmax",Be="Mean",We="Min",Ue="Minimum",Ve="MirrorPad",He="Mod",Ge="Multinomial",qe="Multiply",Ke="Neg",Xe="NotEqual",Ye="NonMaxSuppressionV3",$e="NonMaxSuppressionV4",Qe="NonMaxSuppressionV5",Ze="OnesLike",Je="OneHot",et="Pack",tt="PadV2",nt="Pow",rt="Prelu",at="Prod",it="Range",ot="Real",st="Reciprocal",ct="Relu",ut="Reshape",lt="ResizeNearestNeighbor",dt="ResizeNearestNeighborGrad",ft="ResizeBilinear",pt="ResizeBilinearGrad",ht="Relu6",bt="Reverse",mt="Round",vt="Rsqrt",gt="ScatterNd",yt="Select",Ot="Selu",xt="Slice",kt="Sin",wt="Sinh",jt="Sign",St="Sigmoid",Nt="Softplus",It="Sqrt",Ct="Sum",Tt="SpaceToBatchND",Et="SplitV",At="Softmax",Rt="SparseFillEmptyRows",Ft="SparseReshape",Dt="SparseSegmentMean",_t="SparseSegmentSum",Mt="SparseToDense",zt="SquaredDifference",Lt="Square",Pt="StridedSlice",Bt="StringNGrams",Wt="StringSplit",Ut="StringToHashBucketFast",Vt="Sub",Ht="Tan",Gt="Tanh",qt="Tile",Kt="TopK",Xt="Transform",Yt="Transpose",$t="Unique",Qt="Unpack",Zt="UnsortedSegmentSum",Jt="ZerosLike",en="Step",tn="FromPixels",nn="RotateWithOffset",rn="_FusedMatMul",an="FusedConv2D",on="FusedDepthwiseConv2D"},function(e,t,n){"use strict";e.exports=n(324)},function(e,t,n){e.exports=n(328)},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(225);var a=n(124),i=n(226);function o(e,t){return Object(r.a)(e)||function(e,t){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,a=!1,i=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(c){a=!0,i=c}finally{try{r||null==s.return||s.return()}finally{if(a)throw i}}return n}}(e,t)||Object(a.a)(e,t)||Object(i.a)()}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return o}));var r=n(9),a=n(15),i="__op";function o(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 "+"".concat(t.length," keys."));var n=t[0],o=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=i;var s=function(){r.a.startScope(n);try{var e=o.apply(void 0,arguments);return Object(a.x)(e)&&console.error("Cannot return a Promise inside of tidy."),r.a.endScope(e),e}catch(t){throw r.a.endScope(null),t}};return Object.defineProperty(s,"name",{value:n,configurable:!0}),s}},function(e,t,n){"use strict";n.d(t,"b",(function(){return I})),n.d(t,"a",(function(){return C}));var r=n(20),a=n(21),i=n(5),o=n.n(i),s=n(12),c=n(7),u=n(11),l=n(178),d=n(38),f=n(136),p=n(3),h=n(85),b=n(19),m=n(15),v=function(){function e(t,n){Object(c.a)(this,e),this.backendTimer=t,this.logger=n,null==n&&(this.logger=new g)}return Object(u.a)(e,[{key:"profileKernel",value:function(e,t,n){var a,i,o=function(){a=n()},s=b.now();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(o);else{o();var c,u=Object(r.a)(a);try{for(u.s();!(c=u.n()).done;){c.value.dataSync()}}catch(p){u.e(p)}finally{u.f()}i=Promise.resolve({kernelMs:b.now()-s})}if(Object(d.b)().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(var l=function(t){var n=a[t];n.data().then((function(t){!function(e,t,n){if("float32"!==t)return!1;for(var r=0;r0?h:""," ")}}console.log("%c".concat(s,"\t%c").concat(o,"\t%c").concat(c,"D ").concat(l,"\t%c").concat(u,"\t%c").concat(d,"\t%c").concat(i),"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}]),e}();function y(e,t,n){for(var r={},a={},i=0;i=0;b--)for(var m=e[b],v=m.inputs,g=0;g=0;i--)a(i)}var x=n(10),k=n(39);function w(e){return null!=e.kernelName}var j=function(){function e(){Object(c.a)(this,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 Object(u.a)(e,[{key:"dispose",value:function(){for(var e in this.registeredVariables)this.registeredVariables[e].dispose()}}]),e}(),S=function(){function e(t){Object(c.a)(this,e),this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new j}return Object(u.a)(e,[{key:"ready",value:function(){var e=Object(s.a)(o.a.mark((function e(){var t,n,r;return o.a.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(!(n2&&void 0!==arguments[2]?arguments[2]:1;return e in this.registryFactory?(console.warn("".concat(e," backend was already registered. ")+"Reusing existing backend factory."),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}},{key:"setBackend",value:function(){var e=Object(s.a)(o.a.mark((function e(t){var n,r;return o.a.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 '".concat(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 v(this.backendInstance),e.abrupt("return",!0);case 20:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"setupRegisteredKernels",value:function(){var e=this;Object(h.c)(this.backendName).forEach((function(t){null!=t.setupFunc&&t.setupFunc(e.backendInstance)}))}},{key:"disposeRegisteredKernels",value:function(e){var t=this;Object(h.c)(e).forEach((function(n){null!=n.disposeFunc&&n.disposeFunc(t.registry[e])}))}},{key:"initializeBackend",value:function(e){var t=this,n=this.registryFactory[e];if(null==n)throw new Error("Cannot initialize backend ".concat(e,", no registration found."));try{var r=n.factory();if(!r||r instanceof l.b||"function"!==typeof r.then)return this.registry[e]=r,{success:!0,asyncInit:!1};var a=++this.pendingBackendInitId,i=r.then((function(n){return!(a0)throw new Error("Backend '".concat(this.backendName,"' has an internal memory leak ")+"(".concat(o," data ids) after running '").concat(e,"'"))}},{key:"runKernelFunc",value:function(e){var t,n,r,a=this,i=[],o=this.isTapeOn(),s=this.state.numBytes,c=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;var u=w(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(w(e)){var l=e.kernelName,d=e.inputs,f=e.attrs;null==this.backendName&&this.backend;var p=Object(h.b)(l,this.backendName);m.b(null!=p,(function(){return"Cannot find registered kernel '".concat(l,"' for backend '").concat(a.backendName,"'")})),n=function(){var e=a.backend.numDataIds();r=p.kernelFunc({inputs:d,attrs:f,backend:a.backend});var t=Array.isArray(r)?r:[r];a.shouldCheckForMemLeaks()&&a.checkKernelForMemLeak(l,e,t);var n=t.map((function(e){if(null!=e.rank)return e;var t=e.dataId,n=e.shape,r=e.dtype;return a.makeTensorFromDataId(t,n,r)}));if(o){var s=a.getTensorsForGradient(l,d,n);i=a.saveTensorsForBackwardMode(s)}return n}}else{var b=e.forwardFunc,v=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 b(a.backend,v)}));var t=Array.isArray(r)?r:[r];return a.shouldCheckForMemLeaks()&&a.checkKernelForMemLeak(u,e,t),t}}var g,y=e.inputs,O=e.attrs,x=w(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?(g=a.profiler.profileKernel(u,y,(function(){return n()})),a.ENV.getBool("DEBUG")&&a.profiler.logKernelProfile(g),t=g.outputs):t=n()})),o&&this.addTapeNode(u,y,t,x,i,O),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-s,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-c,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(y).map((function(e){return null!=y[e]?y[e].shape:null})),outputShapes:t.map((function(e){return e.shape})),kernelTimeMs:g.timeMs,extraInfo:g.extraInfo}),Array.isArray(r)?t:t[0]}},{key:"saveTensorsForBackwardMode",value:function(e){var t=this;return e.map((function(e){return t.keep(t.clone(e))}))}},{key:"getTensorsForGradient",value:function(e,t,n){var r=Object(h.a)(e);if(null!=r){var a,i=r.inputsToSave||[],o=r.outputsToSave||[];r.saveAllInputs?(m.b(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[]}},{key:"makeTensor",value: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&&m.z(e[0])&&(a=e.map((function(e){return b.encodeString(e)})));var i=r.write(a,t,n),o=new x.a(t,n,i,this.nextTensorId());if(this.trackTensor(o,r),"string"===n){var s=this.state.tensorInfo.get(i),c=Object(m.f)(a);this.state.numBytes+=c-s.bytes,s.bytes=c}return o}},{key:"makeTensorFromDataId",value:function(e,t,n,r){n=n||"float32";var a=new x.a(t,n,e,this.nextTensorId());return this.trackTensor(a,r),a}},{key:"makeVariable",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));var a=new x.c(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error("Variable with name ".concat(a.name," was already registered"));return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}},{key:"trackTensor",value:function(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;var n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*m.g(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 x.c||this.track(e)}},{key:"incRef",value:function(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}},{key:"removeDataId",value:function(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}},{key:"disposeTensor",value: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*m.g(e.dtype);this.state.numBytes-=n}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}}},{key:"disposeVariables",value:function(){for(var e in this.state.registeredVariables){var t=this.state.registeredVariables[e];this.disposeVariable(t)}}},{key:"disposeVariable",value:function(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}},{key:"memory",value: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}},{key:"profile",value:function(){var e=Object(s.a)(o.a.mark((function e(t){var n,i,s,c,u;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.state.profiling=!0,n=this.state.numBytes,i=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,Object(a.a)(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-i,s=Object(r.a)(this.state.activeProfile.kernels),e.prev=12,s.s();case 14:if((c=s.n()).done){e.next=24;break}return u=c.value,e.next=18,u.kernelTimeMs;case 18:return u.kernelTimeMs=e.sent,e.next=21,u.extraInfo;case 21:u.extraInfo=e.sent;case 22:e.next=14;break;case 24:e.next=29;break;case 26:e.prev=26,e.t0=e.catch(12),s.e(e.t0);case 29:return e.prev=29,s.f(),e.finish(29);case 32:return e.abrupt("return",this.state.activeProfile);case 33:case"end":return e.stop()}}),e,this,[[12,26,29,32]])})));return function(t){return e.apply(this,arguments)}}()},{key:"isTapeOn",value:function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}},{key:"addTapeNode",value:function(e,t,n,r,a,i){var o=this,s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},c=Object(h.a)(e);null!=c&&(r=c.gradFunc),null!=r&&(s.gradient=function(e){return e=e.map((function(e,t){if(null==e){var r=n[t],a=m.F(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)}},{key:"keep",value:function(e){return e.kept=!0,e}},{key:"startTape",value:function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}},{key:"endTape",value:function(){this.state.gradientDepth--}},{key:"startScope",value: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}},{key:"endScope",value:function(e){for(var t=this,n=Object(k.getTensorsInContainer)(e),r=new Set(n.map((function(e){return e.id}))),a=0;a3&&void 0!==arguments[3]&&arguments[3];if(m.b(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 '".concat(n.dtype,"'"));var o=this.scopedRun((function(){return a.startTape()}),(function(){return a.endTape()}),(function(){return a.tidy("forward",e)}));m.b(o instanceof x.a,(function(){return"The result y returned by f() must be a tensor."}));var s=y(this.state.activeTape,t,o);if(!i&&0===s.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={};e[o.id]=null==n?N(o.shape):n,O(e,s,(function(e){return a.tidy(e)}),T);var i=t.map((function(t){return e[t.id]}));return 0===a.state.gradientDepth&&(a.state.activeTape.forEach((function(e){var t,n=Object(r.a)(e.saved);try{for(n.s();!(t=n.n()).done;){t.value.dispose()}}catch(a){n.e(a)}finally{n.f()}})),a.state.activeTape=null),{value:o,grads:i}}))}},{key:"customGrad",value:function(e){var t=this;return m.b(m.u(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;a1)for(var u=0;u5&&void 0!==arguments[5])||arguments[5],o="complex64"===n?2:1,s=t[0],c=t.length;if(0===c){if("complex64"===n){var u=v(e);return[h(u[0],0,n)]}return"bool"===n?[b(e[0])]:[e[0].toString()]}if(1===c){if(s>20){var l=3*o,f=Array.from(e.slice(0,l)),p=Array.from(e.slice((s-3)*o,s*o));return"complex64"===n&&(f=v(f),p=v(p)),["["+f.map((function(e,t){return h(e,a[t],n)})).join(", ")+", ..., "+p.map((function(e,t){return h(e,a[s-3+t],n)})).join(", ")+"]"]}var g="complex64"===n?v(e):Array.from(e);return["["+g.map((function(e,t){return h(e,a[t],n)})).join(", ")+"]"]}var y=t.slice(1),O=r.slice(1),x=r[0]*o,k=[];if(s>20){for(var w=0;w<3;w++){var j=w*x,S=j+x;k.push.apply(k,Object(d.a)(m(e.slice(j,S),y,n,O,a,!1)))}k.push("...");for(var N=s-3;N1?n-1:0),a=1;a=this.shape[r]){var s="Requested out of range element at ".concat(t,". ")+" Buffer shape=".concat(this.shape);throw new Error(s)}r++}for(var c=t[t.length-1],u=0;u0&&void 0!==arguments[0]&&arguments[0];return x.print(this,e)}},{key:"clone",value:function(){return this.throwIfDisposed(),x.clone(this)}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.dataSync();return p(t,this.shape,this.dtype,e)}},{key:"cast",value:function(e){return this.throwIfDisposed(),x.cast(this,e)}},{key:"variable",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;return this.throwIfDisposed(),O().makeVariable(this,e,t,n)}}]),e}();function N(){return Object(l.a)("Tensor",(function(){return S}))}Object.defineProperty(S,Symbol.hasInstance,{value:function(e){return!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}}),N();var I=function(e){Object(r.a)(n,e);var t=Object(a.a)(n);function n(e,r,a,i){var o;return Object(c.a)(this,n),(o=t.call(this,e.shape,e.dtype,e.dataId,i)).trainable=r,o.name=a,o}return Object(u.a)(n,[{key:"assign",value:function(e){if(e.dtype!==this.dtype)throw new Error("dtype of the new value (".concat(e.dtype,") and ")+"previous value (".concat(this.dtype,") must match"));if(!f.a(e.shape,this.shape))throw new Error("shape of the new value (".concat(e.shape,") and ")+"previous value (".concat(this.shape,") must match"));O().disposeTensor(this),this.dataId=e.dataId,O().incRef(this,null)}},{key:"dispose",value:function(){O().disposeVariable(this),this.isDisposedInternal=!0}}]),n}(S);Object.defineProperty(I,Symbol.hasInstance,{value:function(e){return e instanceof S&&null!=e.assign&&e.assign instanceof Function}})},function(e,t,n){"use strict";function r(e,t){for(var n=0;n0;)n=Math.random()*t|0,s(e,--t,n)}function a(e,t){if(e.length!==t.length)throw new Error("Array sizes must match to be shuffled together "+"First array length was ".concat(e.length)+"Second array length was ".concat(t.length));for(var n=e.length,r=0;n>0;)r=Math.random()*n|0,s(e,--n,r),s(t,n,r)}function i(e,t,n){return Math.max(e,Math.min(t,n))}function o(e){return e%2===0?e:e+1}function s(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function c(e){for(var t=0,n=0;n2&&void 0!==arguments[2]?arguments[2]:"";d(v(e,t),(function(){return n+" Shapes ".concat(e," and ").concat(t," must match")}))}function p(e){d(null!=e,(function(){return"The input to the tensor constructor must be a non-null value."}))}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(null==t&&(t=[]),Array.isArray(e)||R(e)&&!n)for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:function(e){return 0},n=arguments.length>2?arguments[2]:void 0;return new Promise((function(r,a){var i=0;!function o(){if(e())r();else{i++;var s=t(i);null!=n&&i>=n?a():setTimeout(o,s)}}()}))}function j(e,t){for(var n=1,r=-1,a=0;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 ".concat(r," and dim ").concat(a));r=a}else if(e[a]<0)throw Error("Shapes can not be < 0. Found ".concat(e[a]," at dim ").concat(a));if(-1===r){if(t>0&&t!==n)throw Error("Size(".concat(t,") must match the product of shape ").concat(e));return e}if(0===n)throw Error("Cannot infer the missing size in [".concat(e,"] when ")+"there are 0 elements");if(t%n!==0)throw Error("The implicit shape can't be a fractional number. "+"Got ".concat(t," / ").concat(n));var i=e.slice();return i[r]=t/n,i}function S(e,t){var n=t.length;return d((e=null==e?t.map((function(e,t){return t})):[].concat(e)).every((function(e){return e>=-n&&es)&&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 I(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)throw new Error("Unknown data type ".concat(e));n=new Uint8Array(t)}return n}function C(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 ".concat(e));n=new Array(t)}return n}function T(e,t){for(var n=0;n=0;--r)n[r]=n[r+1]*e[r+1];return n}function U(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=new Array;if(1===t.length)for(var i=t[0]*(r?2:1),o=0;o2&&void 0!==arguments[2]&&arguments[2];if(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("[".concat(e,"] does not match the input size ").concat(t.length).concat(n?" for a complex tensor":"","."));return U(0,e,t,n)}function H(e,t){for(var n=G(e,t),r=0;r=0,(function(){return"Tensor must have a shape comprised of positive integers but got "+"shape [".concat(e,"].")}))}))}function X(e,t,n){if(0===t)return 0;if(1===t)return e[0];for(var r=e[e.length-1],a=0;a2&&void 0!==arguments[2]?arguments[2]:s("9ddfea08eb382d69"),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 v(e,t,n,r){return function(e,t,n,r,a,i){a=a.add(e),i=b(i.add(a).add(r),21);var o=a;return a=(a=a.add(t)).add(n),i=i.add(b(a,44)),[a.add(r),i.add(o)]}(p(e,t),p(e,t+8),p(e,t+16),p(e,t+24),n,r)}function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.length;if(t>=8){var n=l.add(2*t),r=p(e,0).add(l),a=p(e,t-8),i=b(a,37).mul(n).add(r),o=b(r,25).add(a).mul(n);return m(i,o,n)}if(t>=4){var s=l.add(2*t),u=h(e,0);return m(u.shl(3).add(t),h(e,t-4),s)}if(t>0){var f=e[0],v=e[t>>1],g=e[t-1],y=f+(v<<8),O=t+(g<<2);return d(l.mul(y).xor(c.mul(O))).mul(l)}return l}function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.length,n=l.add(2*t),r=p(e,0).mul(u),a=p(e,8),i=p(e,t-8).mul(n),o=p(e,t-16).mul(l);return m(b(r.add(a),43).add(b(i,30)).add(o),r.add(b(a.add(l),18)).add(i),n)}function O(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.length,n=l.add(2*t),r=p(e,0).mul(l),a=p(e,8),i=p(e,t-8).mul(n),o=p(e,t-16).mul(l),s=b(r.add(a),43).add(b(i,30)).add(o),c=m(s,r.add(b(a.add(l),18)).add(i),n),u=p(e,16).mul(n),d=p(e,24),f=s.add(p(e,t-32)).mul(n),h=c.add(p(e,t-24)).mul(n);return m(b(u.add(d),43).add(b(f,30)).add(h),u.add(b(d.add(r),18)).add(f),n)}function x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.length,n=o.fromNumber(81,!0);if(t<=32)return t<=16?g(e,t):y(e,t);if(t<=64)return O(e,t);var r=n,a=n.mul(u).add(113),i=d(a.mul(l).add(113)).mul(l),s=[o.UZERO,o.UZERO],f=[o.UZERO,o.UZERO];r=r.mul(l).add(p(e,0));var h=0,x=64*(t-1>>6),k=x+(t-1&63)-63;do{r=b(r.add(a).add(s[0]).add(p(e,h+8)),37).mul(u),a=b(a.add(s[1]).add(p(e,h+48)),42).mul(u),r=r.xor(f[1]),a=a.add(s[0]).add(p(e,h+40)),i=b(i.add(f[0]),33).mul(u),s=v(e,h,s[1].mul(u),r.add(f[0])),f=v(e,h+32,i.add(f[1]),a.add(p(e,h+16)));var w=[r,i];i=w[0],r=w[1],h+=64}while(h!==x);var j=u.add(i.and(255).shl(1));h=k,f[0]=f[0].add(t-1&63),s[0]=s[0].add(f[0]),f[0]=f[0].add(s[0]),r=b(r.add(a).add(s[0]).add(p(e,h+8)),37).mul(j),a=b(a.add(s[1]).add(p(e,h+48)),42).mul(j),r=r.xor(f[1].mul(9)),a=a.add(s[0].mul(9).add(p(e,h+40))),i=b(i.add(f[0]),33).mul(j),s=v(e,h,s[1].mul(j),r.add(f[0])),f=v(e,h+32,i.add(f[1]),a.add(p(e,h+16)));var S=[r,i];return i=S[0],r=S[1],m(m(s[0],f[0],j).add(d(a).mul(c)).add(i),m(s[1],f[1],j).add(r),j)}function k(e,t){return"string"===t?N(e):w([e],t)}function w(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=a.m(e)),Object(r.b)().getBool("DEBUG")&&a.h(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),i=0;i1&&void 0!==arguments[1]?arguments[1]:"utf-8";return t=t||"utf-8",Object(r.b)().platform.encode(e,t)}function I(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf-8";return t=t||"utf-8",Object(r.b)().platform.decode(e,t)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(124);function a(e,t){var n;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=Object(r.a)(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var a=0,i=function(){};return{s:i,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,c=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){c=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(c)throw o}}}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(182);var a=n(227),i=n(124);function o(e){return function(e){if(Array.isArray(e))return Object(r.a)(e)}(e)||Object(a.a)(e)||Object(i.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},function(e,t,n){"use strict";e.exports=n(349)},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(75);function a(e,t){if(null==e)return{};var n,a,i=Object(r.a)(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({cast_:function(e,t){var n=Object(i.a)(e,"x","cast");if(!o.B(t))throw new Error("Failed to cast to unknown dtype ".concat(t));if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var s={x:n},c={dtype:t};return r.a.runKernel(a.w,s,c)}})},function(e,t,n){"use strict";function r(e){var t,n,a="";if("string"===typeof e||"number"===typeof e)a+=e;else if("object"===typeof e)if(Array.isArray(e))for(t=0;t1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=Object(i.a)(e,"x","sum");"bool"===s.dtype&&(s=Object(o.a)(s,"int32"));var c={x:s},u={axis:t,keepDims:n};return r.a.runKernel(a.Xc,c,u)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(15),a=n(71);function i(e,t){if((Object(r.A)(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&&Object(r.A)(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Object(a.a)(e,[],[],t)}},function(e,t,n){"use strict";function r(e,t){for(var n=e.length,r=[],a=0;a1&&1===o&&r.unshift(i)}return r}function a(e,t){for(var n=[],r=0;r1)&&n.unshift(i)}return n}function i(e,t){for(var n=[],r=Math.max(e.length,t.length),a=0;a1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var i=t.defaultTheme,s=t.withTheme,f=void 0!==s&&s,p=t.name,h=Object(a.a)(t,["defaultTheme","withTheme","name"]);var b=p,m=Object(u.a)(e,Object(r.a)({defaultTheme:i,Component:n,name:p||n.displayName,classNamePrefix:b},h)),v=o.a.forwardRef((function(e,t){e.classes;var s,c=e.innerRef,u=Object(a.a)(e,["classes","innerRef"]),h=m(Object(r.a)({},n.defaultProps,e)),b=u;return("string"===typeof p||f)&&(s=Object(d.a)()||i,p&&(b=Object(l.a)({theme:s,name:p,props:u})),f&&!b.theme&&(b.theme=s)),o.a.createElement(n,Object(r.a)({ref:c||t,classes:h},b))}));return c()(v,n),v}},p=n(129);t.a=function(e,t){return f(e,Object(r.a)({defaultTheme:p.a},t))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({zerosLike_:function(e){var t={x:Object(i.a)(e,"x","zerosLike")};return r.a.runKernel(a.hd,t)}})},function(e,t,n){"use strict";n.d(t,"b",(function(){return a.a})),n.d(t,"c",(function(){return i.a})),n.d(t,"d",(function(){return o.a})),n.d(t,"e",(function(){return s.a})),n.d(t,"f",(function(){return c.a})),n.d(t,"g",(function(){return u.a})),n.d(t,"h",(function(){return l.a})),n.d(t,"i",(function(){return d.a})),n.d(t,"j",(function(){return f.a})),n.d(t,"k",(function(){return p.a})),n.d(t,"l",(function(){return h.a})),n.d(t,"m",(function(){return b.a})),n.d(t,"n",(function(){return m.a})),n.d(t,"o",(function(){return v.a})),n.d(t,"p",(function(){return g.a})),n.d(t,"q",(function(){return y.a})),n.d(t,"r",(function(){return C})),n.d(t,"w",(function(){return T.a})),n.d(t,"s",(function(){return E.a})),n.d(t,"t",(function(){return R})),n.d(t,"u",(function(){return F})),n.d(t,"v",(function(){return D})),n.d(t,"x",(function(){return _.a})),n.d(t,"z",(function(){return M.a})),n.d(t,"A",(function(){return z.a})),n.d(t,"B",(function(){return L.a})),n.d(t,"C",(function(){return P.a})),n.d(t,"D",(function(){return B.a})),n.d(t,"E",(function(){return W.a})),n.d(t,"F",(function(){return U.a})),n.d(t,"G",(function(){return x.a})),n.d(t,"H",(function(){return V})),n.d(t,"I",(function(){return H})),n.d(t,"J",(function(){return G})),n.d(t,"K",(function(){return q})),n.d(t,"L",(function(){return K.a})),n.d(t,"M",(function(){return X.a})),n.d(t,"N",(function(){return Y.a})),n.d(t,"O",(function(){return $.a})),n.d(t,"P",(function(){return Z})),n.d(t,"Q",(function(){return J.a})),n.d(t,"R",(function(){return ee.a})),n.d(t,"T",(function(){return te.a})),n.d(t,"U",(function(){return ne.a})),n.d(t,"V",(function(){return re.a})),n.d(t,"W",(function(){return ae.a})),n.d(t,"X",(function(){return se})),n.d(t,"Y",(function(){return ce.a})),n.d(t,"Z",(function(){return ue.a})),n.d(t,"ab",(function(){return le.a})),n.d(t,"bb",(function(){return de.a})),n.d(t,"db",(function(){return fe.a})),n.d(t,"eb",(function(){return pe.a})),n.d(t,"gb",(function(){return he.a})),n.d(t,"hb",(function(){return be.a})),n.d(t,"ib",(function(){return me.a})),n.d(t,"jb",(function(){return ve.a})),n.d(t,"kb",(function(){return ge.a})),n.d(t,"lb",(function(){return xe})),n.d(t,"nb",(function(){return ke.a})),n.d(t,"ob",(function(){return we.a})),n.d(t,"pb",(function(){return je.a})),n.d(t,"rb",(function(){return Se.a})),n.d(t,"tb",(function(){return Ne.a})),n.d(t,"ub",(function(){return Ie.a})),n.d(t,"wb",(function(){return Ce.a})),n.d(t,"Ab",(function(){return Te.a})),n.d(t,"Bb",(function(){return Ee.a})),n.d(t,"Cb",(function(){return Ae.a})),n.d(t,"Db",(function(){return Re.a})),n.d(t,"Eb",(function(){return Fe.a})),n.d(t,"Fb",(function(){return De.a})),n.d(t,"Hb",(function(){return _e.a})),n.d(t,"Ib",(function(){return Me.a})),n.d(t,"Jb",(function(){return ze.a})),n.d(t,"Kb",(function(){return Le.a})),n.d(t,"Lb",(function(){return Pe.a})),n.d(t,"Mb",(function(){return Be.a})),n.d(t,"Nb",(function(){return We.a})),n.d(t,"Ob",(function(){return Ue.a})),n.d(t,"Pb",(function(){return Ve.a})),n.d(t,"Qb",(function(){return He.a})),n.d(t,"Rb",(function(){return Ge.a})),n.d(t,"Tb",(function(){return k.a})),n.d(t,"Ub",(function(){return qe.a})),n.d(t,"Vb",(function(){return Ke.a})),n.d(t,"Wb",(function(){return Xe.a})),n.d(t,"Xb",(function(){return Ye.a})),n.d(t,"Yb",(function(){return $e.a})),n.d(t,"Zb",(function(){return Qe.a})),n.d(t,"ac",(function(){return et})),n.d(t,"bc",(function(){return tt.a})),n.d(t,"cc",(function(){return nt.a})),n.d(t,"dc",(function(){return rt.a})),n.d(t,"ec",(function(){return at.a})),n.d(t,"fc",(function(){return ct})),n.d(t,"hc",(function(){return w.a})),n.d(t,"ic",(function(){return ut})),n.d(t,"jc",(function(){return lt.a})),n.d(t,"kc",(function(){return dt.a})),n.d(t,"mc",(function(){return ft.a})),n.d(t,"nc",(function(){return pt.a})),n.d(t,"oc",(function(){return Ze.a})),n.d(t,"pc",(function(){return ht.a})),n.d(t,"rc",(function(){return bt})),n.d(t,"sc",(function(){return mt.a})),n.d(t,"tc",(function(){return vt})),n.d(t,"uc",(function(){return gt})),n.d(t,"vc",(function(){return yt})),n.d(t,"wc",(function(){return Ot})),n.d(t,"xc",(function(){return xt.a})),n.d(t,"yc",(function(){return kt.a})),n.d(t,"zc",(function(){return wt.a})),n.d(t,"Ac",(function(){return jt.a})),n.d(t,"Bc",(function(){return St.a})),n.d(t,"Cc",(function(){return Nt})),n.d(t,"Dc",(function(){return Ct})),n.d(t,"Ec",(function(){return Tt})),n.d(t,"Fc",(function(){return Et.a})),n.d(t,"Gc",(function(){return At.a})),n.d(t,"Hc",(function(){return Rt.a})),n.d(t,"Ic",(function(){return Ft.a})),n.d(t,"Jc",(function(){return Dt.a})),n.d(t,"Kc",(function(){return _t.a})),n.d(t,"Lc",(function(){return ye.a})),n.d(t,"Mc",(function(){return Mt.a})),n.d(t,"Nc",(function(){return zt})),n.d(t,"Oc",(function(){return Lt})),n.d(t,"Pc",(function(){return Pt})),n.d(t,"Qc",(function(){return Bt})),n.d(t,"Sc",(function(){return Wt.a})),n.d(t,"Tc",(function(){return Ut.a})),n.d(t,"Uc",(function(){return Vt.a})),n.d(t,"Wc",(function(){return Ht.a})),n.d(t,"Xc",(function(){return Gt.a})),n.d(t,"Yc",(function(){return qt.a})),n.d(t,"Zc",(function(){return S.a})),n.d(t,"ad",(function(){return Kt.a})),n.d(t,"cd",(function(){return Xt.a})),n.d(t,"dd",(function(){return Yt.a})),n.d(t,"ed",(function(){return N.a})),n.d(t,"fd",(function(){return $t})),n.d(t,"gd",(function(){return Qt})),n.d(t,"hd",(function(){return Zt})),n.d(t,"id",(function(){return Jt})),n.d(t,"jd",(function(){return en.a})),n.d(t,"kd",(function(){return tn.a})),n.d(t,"ld",(function(){return nn.a})),n.d(t,"mb",(function(){return rn.a})),n.d(t,"vb",(function(){return an.a})),n.d(t,"zb",(function(){return on.a})),n.d(t,"Rc",(function(){return sn.a})),n.d(t,"pd",(function(){return cn.a})),n.d(t,"qd",(function(){return un.a})),n.d(t,"rd",(function(){return ot.a})),n.d(t,"sd",(function(){return ln.a})),n.d(t,"td",(function(){return dn.a})),n.d(t,"ud",(function(){return fn.a})),n.d(t,"vd",(function(){return pn.a})),n.d(t,"wd",(function(){return hn.a})),n.d(t,"yd",(function(){return st.a})),n.d(t,"zd",(function(){return bn.a})),n.d(t,"Ad",(function(){return mn.a})),n.d(t,"Bd",(function(){return I.a})),n.d(t,"Cd",(function(){return vn.a})),n.d(t,"Dd",(function(){return gn.a})),n.d(t,"Ed",(function(){return On})),n.d(t,"Fd",(function(){return xn.a})),n.d(t,"Gd",(function(){return kn})),n.d(t,"Hd",(function(){return wn})),n.d(t,"Id",(function(){return jn})),n.d(t,"Jd",(function(){return Oe.a})),n.d(t,"Kd",(function(){return Sn.a})),n.d(t,"Md",(function(){return Nn.a})),n.d(t,"Nd",(function(){return In.a})),n.d(t,"Od",(function(){return Cn.a})),n.d(t,"Pd",(function(){return Tn.a})),n.d(t,"Qd",(function(){return En})),n.d(t,"Rd",(function(){return An.a})),n.d(t,"Sd",(function(){return Rn.a})),n.d(t,"Td",(function(){return Fn.a})),n.d(t,"Ud",(function(){return Dn.a})),n.d(t,"y",(function(){return Pn})),n.d(t,"Ld",(function(){return Bn.a})),n.d(t,"lc",(function(){return Wn.a})),n.d(t,"gc",(function(){return Vn})),n.d(t,"Vc",(function(){return Hn.a})),n.d(t,"nd",(function(){return Gn.a})),n.d(t,"sb",(function(){return qn.a})),n.d(t,"cb",(function(){return Kn})),n.d(t,"fb",(function(){return Xn})),n.d(t,"S",(function(){return Yn})),n.d(t,"yb",(function(){return Qn})),n.d(t,"qc",(function(){return j.b})),n.d(t,"a",(function(){return j.a})),n.d(t,"xb",(function(){return ia})),n.d(t,"Gb",(function(){return oa})),n.d(t,"Sb",(function(){return sa})),n.d(t,"od",(function(){return ra})),n.d(t,"qb",(function(){return r})),n.d(t,"bd",(function(){return aa})),n.d(t,"md",(function(){return ca})),n.d(t,"xd",(function(){return ua}));var r={};n.r(r),n.d(r,"conv2d",(function(){return ir})),n.d(r,"depthwiseConv2d",(function(){return cr})),n.d(r,"matMul",(function(){return ur}));var a=n(65),i=n(249),o=n(250),s=n(27),c=n(251),u=n(190),l=n(191),d=n(192),f=n(193),p=n(252),h=n(253),b=n(254),m=n(194),v=n(255),g=n(143),y=n(256),O=n(2),x=n(49),k=n(41),w=n(18),j=n(8),S=n(93),N=n(43),I=n(179);var C=Object(j.b)({basicLSTMCell_:function(e,t,n,r,a,i){var o=Object(O.a)(e,"forgetBias","basicLSTMCell"),c=Object(O.a)(t,"lstmKernel","basicLSTMCell"),u=Object(O.a)(n,"lstmBias","basicLSTMCell"),l=Object(O.a)(r,"data","basicLSTMCell"),d=Object(O.a)(a,"c","basicLSTMCell"),f=Object(O.a)(i,"h","basicLSTMCell"),p=Object(x.a)([l,f],1),h=Object(k.a)(p,c),b=Object(s.a)(h,u),m=b.shape[0],v=b.shape[1]/4,g=[m,v],y=Object(N.a)(b,[0,0],g),j=Object(N.a)(b,[0,v],g),C=Object(N.a)(b,[0,2*v],g),T=Object(N.a)(b,[0,3*v],g),E=Object(s.a)(Object(w.a)(Object(S.a)(y),Object(I.a)(j)),Object(w.a)(d,Object(S.a)(Object(s.a)(o,C))));return[E,Object(w.a)(Object(I.a)(E),Object(S.a)(T))]}}),T=n(115),E=n(104),A=n(15);var R=Object(j.b)({batchNorm2d_:function(e,t,n,r,a,i){var o,s,c=Object(O.a)(e,"x","batchNorm"),u=Object(O.a)(t,"mean","batchNorm"),l=Object(O.a)(n,"variance","batchNorm");return null!=a&&(o=Object(O.a)(a,"scale","batchNorm")),null!=r&&(s=Object(O.a)(r,"offset","batchNorm")),A.b(2===c.rank,(function(){return"Error in batchNorm2D: x must be rank 2 but got rank "+"".concat(c.rank,".")})),A.b(2===u.rank||1===u.rank,(function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but "+"got rank ".concat(u.rank,".")})),A.b(2===l.rank||1===l.rank,(function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 "+"but got rank ".concat(l.rank,".")})),null!=o&&A.b(2===o.rank||1===o.rank,(function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 "+"but got rank ".concat(o.rank,".")})),null!=s&&A.b(2===s.rank||1===s.rank,(function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 "+"but got rank ".concat(s.rank,".")})),Object(E.a)(c,u,l,s,o,i)}});var F=Object(j.b)({batchNorm3d_:function(e,t,n,r,a,i){var o,s,c=Object(O.a)(e,"x","batchNorm"),u=Object(O.a)(t,"mean","batchNorm"),l=Object(O.a)(n,"variance","batchNorm");return null!=a&&(o=Object(O.a)(a,"scale","batchNorm")),null!=r&&(s=Object(O.a)(r,"offset","batchNorm")),A.b(3===c.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+"".concat(c.rank,".")})),A.b(3===u.rank||1===u.rank,(function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but "+"got rank ".concat(u.rank,".")})),A.b(3===l.rank||1===l.rank,(function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 "+"but got rank ".concat(l.rank,".")})),null!=o&&A.b(3===o.rank||1===o.rank,(function(){return"Error in batchNorm3D: scale must be rank 3 or rank 1 "+"but got rank ".concat(o.rank,".")})),null!=s&&A.b(3===s.rank||1===s.rank,(function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 "+"but got rank ".concat(s.rank,".")})),Object(E.a)(c,u,l,s,o,i)}});var D=Object(j.b)({batchNorm4d_:function(e,t,n,r,a,i){var o,s,c=Object(O.a)(e,"x","batchNorm"),u=Object(O.a)(t,"mean","batchNorm"),l=Object(O.a)(n,"variance","batchNorm");return null!=a&&(o=Object(O.a)(a,"scale","batchNorm")),null!=r&&(s=Object(O.a)(r,"offset","batchNorm")),A.b(4===c.rank,(function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+"".concat(c.rank,".")})),A.b(4===u.rank||1===u.rank,(function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but "+"got rank ".concat(u.rank,".")})),A.b(4===l.rank||1===l.rank,(function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 "+"but got rank ".concat(l.rank,".")})),null!=o&&A.b(4===o.rank||1===o.rank,(function(){return"Error in batchNorm4D: scale must be rank 4 or rank 1 "+"but got rank ".concat(o.rank,".")})),null!=s&&A.b(4===s.rank||1===s.rank,(function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 "+"but got rank ".concat(s.rank,".")})),Object(E.a)(c,u,l,s,o,i)}}),_=n(195),M=n(125),z=n(68),L=n(24),P=n(257),B=n(258),W=n(92),U=n(81);var V=Object(j.b)({concat1d_:function(e){return Object(x.a)(e,0)}});var H=Object(j.b)({concat2d_:function(e,t){return Object(x.a)(e,t)}});var G=Object(j.b)({concat3d_:function(e,t){return Object(x.a)(e,t)}});var q=Object(j.b)({concat4d_:function(e,t){return Object(x.a)(e,t)}}),K=n(196),X=n(90),Y=n(197),$=n(259),Q=n(229);var Z=Object(j.b)({conv3dTranspose_:function(e,t,n,r,a){var i=Object(O.a)(e,"x","conv3dTranspose"),o=Object(O.a)(t,"filter","conv3dTranspose");return Object(Q.a)(n,i,o,r,a)}}),J=n(144),ee=n(198),te=n(145),ne=n(260),re=n(199),ae=n(116),ie=n(9),oe=n(3);var se=Object(j.b)({diag_:function(e){var t={x:Object(O.a)(e,"x","diag")};return ie.a.runKernel(oe.R,t)}}),ce=n(200),ue=n(31),le=n(201),de=n(202),fe=n(261),pe=n(147),he=n(117),be=n(262),me=n(61),ve=n(86),ge=n(263),ye=n(13),Oe=n(106);var xe=Object(j.b)({eye_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"float32";null==t&&(t=e);for(var a=Object(z.a)([e,t],r),i=e<=t?e:t,o=0;o2&&void 0!==arguments[2]?arguments[2]:{},r=n.indexing,a=void 0===r?"xy":r;if("xy"!==a&&"ij"!==a)throw new TypeError("".concat(a," is not a valid third argument to meshgrid"));if(void 0===e)return[];var i=Object(O.a)(e,"x","meshgrid",e instanceof Je.a?e.dtype:"float32");if(void 0===t)return[i];var o=Object(O.a)(t,"y","meshgrid",t instanceof Je.a?t.dtype:"float32"),s=Object(A.O)(i.shape),c=Object(A.O)(o.shape);return"xy"===a?(i=Object(ye.a)(i,[1,-1]),o=Object(ye.a)(o,[-1,1]),[Object(k.a)(Object(Ze.a)([c,1],i.dtype),i),Object(k.a)(o,Object(Ze.a)([1,s],o.dtype))]):(i=Object(ye.a)(i,[-1,1]),o=Object(ye.a)(o,[1,-1]),[Object(k.a)(i,Object(Ze.a)([1,c],i.dtype)),Object(k.a)(Object(Ze.a)([s,1],o.dtype),o)])}var tt=n(132),nt=n(155),rt=n(207),at=n(208),it=n(60),ot=n(40),st=n(29);var ct=Object(j.b)({moments_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e=Object(O.a)(e,"x","moments");var r=Object(A.I)(t,e.shape),a=Object(Qe.a)(e,r,n),i=a.shape;n||(i=Object(it.e)(a.shape,r));var o=Object(ot.a)(Object(st.a)(Object(L.a)(e,"float32"),Object(ye.a)(a,i))),s=Object(Qe.a)(o,r,n);return{mean:a,variance:s}}});var ut=Object(j.b)({multiRNNCell_:function(e,t,n,r){for(var a=Object(O.a)(t,"data","multiRNNCell"),i=Object(O.b)(n,"c","multiRNNCell"),o=Object(O.b)(r,"h","multiRNNCell"),s=a,c=[],u=0;u2&&void 0!==arguments[2]?arguments[2]:0;return Object(A.b)(2===t.length,(function(){return"Invalid number of paddings. Must be length of 2."})),Object(mt.a)(e,[t],n)}});var gt=Object(j.b)({pad2d_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Object(A.b)(2===t.length&&2===t[0].length&&2===t[1].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Object(mt.a)(e,t,n)}});var yt=Object(j.b)({pad3d_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Object(A.b)(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."})),Object(mt.a)(e,t,n)}});var Ot=Object(j.b)({pad4d_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Object(A.b)(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."})),Object(mt.a)(e,t,n)}}),xt=n(210),kt=n(73),wt=n(157),jt=n(189),St=n(211);var Nt=Object(j.b)({rand_:function(e,t,n){var r=Object(A.O)(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 ".concat(n));a=new Uint8Array(r)}for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"float32",a=arguments.length>4?arguments[4]:void 0;if(null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type ".concat(r));for(var i=new It.b(t,n,r,a),o=Object(z.a)(e,r),s=0;s1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(null!=r&&"bool"===r)throw new Error("Unsupported data type ".concat(r));for(var i=new It.a(t,n,r,!1,a),o=Object(z.a)(e,r),s=0;s1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;return ie.a.makeVariable(e,t,n,r)}var An=n(51),Rn=n(223),Fn=n(100),Dn=n(36),_n=n(5),Mn=n.n(_n),zn=n(12);function Ln(){return(Ln=Object(zn.a)(Mn.a.mark((function e(t,n,r){var a,i,o,s,c,u,l,d,f,p,h,b,m;return Mn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(a=Object(O.a)(t,"tensor","boolMask"),i=Object(O.a)(n,"mask","boolMask","bool"),o=null==r?0:r,s=i.rank,c=a.shape,A.b(s>0,(function(){return"mask cannot be scalar"})),A.e(c.slice(o,o+s),i.shape,"mask's shape must match the first K dimensions of tensor's shape,"),u=1,l=o;l4&&void 0!==arguments[4])||arguments[4],i=Object(O.a)(e,"v","movingAverage"),o=Object(O.a)(t,"x","movingAverage"),c=Object(O.a)(n,"decay","movingAverage");Object(Un.assertTypesMatch)(i,o),A.b(A.a(i.shape,o.shape),(function(){return"Shape mismatch in v and x"}));var u=Object(Vt.a)(1),l=Object(st.a)(u,c),d=Object(w.a)(Object(st.a)(o,i),l);if(a){A.b(null!=r,(function(){return"When using zeroDebias: true, step is required."}));var f=Object(O.a)(r,"step","movingAverage");d=Object(ue.a)(d,Object(st.a)(u,Object(kt.a)(c,f)))}return Object(s.a)(i,d)}}),Hn=n(281),Gn=n(284),qn=n(282);var Kn=Object(j.b)({dropout_:function(e,t,n,r){var a=Object(O.a)(e,"x","dropout");if(A.b("float32"===a.dtype,(function(){return"x has to be a floating point tensor since it's going to be "+"scaled, but got a ".concat(a.dtype," tensor instead.")})),A.b(t>=0&&t<1,(function(){return"rate must be a float in the range [0, 1), but got ".concat(t,".")})),0===t)return e instanceof Je.a?a.clone():a;var i=function(e,t){if(null==t)return e.shape.slice();if(A.a(e.shape,t))return t;if(e.shape.length===t.length){for(var n=[],r=0;r2&&void 0!==g[2]?g[2]:1,a=Object(O.a)(t,"predictions","inTopK"),i=Object(O.a)(n,"targets","inTopK"),Object(A.b)(a.rank>1,(function(){return"inTopK() expects the predictions to be of rank 2 or higher, "+"but got ".concat(a.rank)})),Object(A.b)(a.rank-1===i.rank,(function(){return"predictions rank should be 1 larger than targets rank, but got predictions rank "+"".concat(a.rank," and targets rank ").concat(i.rank)})),Object(A.e)(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],Object(A.b)(r>0&&r<=o,(function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last "+"dimension (".concat(o,"), but got ").concat(r)})),e.next=10,a.data();case 10:return s=e.sent,e.next=13,i.data();case 13:c=e.sent,u=s.length/o,l=o,d=Object(A.o)("bool",u),f=0;case 17:if(!(f=2&&b.rank>=2&&h.rank===b.rank,(function(){return"Error in fused matMul: inputs must have the same rank of at "+"least 2, got ranks ".concat(h.rank," and ").concat(b.rank,".")})),A.b(A.a(j,S),(function(){return"Error in fused matMul: outer dimensions (".concat(j,") and (")+"".concat(S,") of Tensors with shapes ").concat(h.shape," and ")+"".concat(b.shape," must match.")})),A.b(g===y,(function(){return"Error in fused matMul: inner shapes (".concat(g,") and (")+"".concat(y,") of Tensors with shapes ").concat(h.shape," and ")+"".concat(b.shape," and transposeA=").concat(a)+" and transposeB=".concat(o," must match.")}));var C,T,E=h.shape.slice(0,-2).concat([x,w]),R=a?Object(ye.a)(h,[N,g,x]):Object(ye.a)(h,[N,x,g]),F=o?Object(ye.a)(b,[I,w,y]):Object(ye.a)(b,[I,y,w]);if(null!=c){C=Object(O.a)(c,"bias","fused matMul");var D=Object(Un.makeTypesMatch)(C,h);C=Object(Zn.a)(D,1)[0],er.a(E,C.shape)}null!=d&&(T=Object(O.a)(d,"prelu weights","fused matMul"));var _=function(e,t){var n,r,i=Object(Zn.a)(t,4),s=i[0],u=i[1],d=i[2],f=i[3],p=Object(ar.c)(Object(ye.a)(e,d.shape),d,l);return a||o?!a&&o?(n=Object(k.a)(p,u,!1,!1),r=Object(k.a)(p,s,!0,!1)):a&&!o?(n=Object(k.a)(u,p,!1,!0),r=Object(k.a)(s,p,!1,!1)):(n=Object(k.a)(u,p,!0,!0),r=Object(k.a)(p,s,!0,!0)):(n=Object(k.a)(p,u,!1,!0),r=Object(k.a)(s,p,!0,!1)),null!=c?[n,r,Object(ar.b)(f,p)]:[n,r]},M={a:R,b:F,bias:C,preluActivationWeights:T},z={transposeA:a,transposeB:o,activation:l,leakyreluAlpha:f};return null==c?Object(Jn.a)((function(e,t,n){var r=ie.a.runKernel(oe.id,M,z);return n([e,t,r]),{value:Object(ye.a)(r,E),gradFunc:_}}))(R,F):Object(Jn.a)((function(e,t,n,r){var a=ie.a.runKernel(oe.id,M,z);return r([e,t,a,n]),{value:Object(ye.a)(a,E),gradFunc:_}}))(R,F,C)}});var lr=Object(j.b)({hammingWindow_:function(e){return Yn(e,.54,.46)}});var dr=Object(j.b)({hannWindow_:function(e){return Yn(e,.5,.5)}});var fr=Object(j.b)({frame_:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=0,o=[];i+t<=e.size;)o.push(Object(N.a)(e,i,t)),i+=n;if(r)for(;i4&&void 0!==arguments[4]?arguments[4]:dr;null==r&&(r=Xn(t));var i=fr(e,t,n),o=Object(w.a)(i,a(t));return Object(sn.a)(o,r)}});var hr=Object(j.b)({cropAndResize_:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"bilinear",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=Object(O.a)(e,"image","cropAndResize"),s=Object(O.a)(t,"boxes","cropAndResize","float32"),c=Object(O.a)(n,"boxInd","cropAndResize","int32"),u=s.shape[0];A.b(4===o.rank,(function(){return"Error in cropAndResize: image must be rank 4,"+"but got rank ".concat(o.rank,".")})),A.b(2===s.rank&&4===s.shape[1],(function(){return"Error in cropAndResize: boxes must be have size [".concat(u,",4] ")+"but had shape ".concat(s.shape,".")})),A.b(1===c.rank&&c.shape[0]===u,(function(){return"Error in cropAndResize: boxInd must be have size [".concat(u,"] ")+"but had shape ".concat(s.shape,".")})),A.b(2===r.length,(function(){return"Error in cropAndResize: cropSize must be of length 2, but got "+"length ".concat(r.length,".")})),A.b(r[0]>=1&&r[1]>=1,(function(){return"cropSize must be atleast [1,1], but was ".concat(r)})),A.b("bilinear"===a||"nearest"===a,(function(){return"method must be bilinear or nearest, but was ".concat(a)}));var l={image:o,boxes:s,boxInd:c},d={method:a,extrapolationValue:i,cropSize:r},f=ie.a.runKernel(oe.K,l,d);return f}});var br=Object(j.b)({flipLeftRight_:function(e){var t=Object(O.a)(e,"image","flipLeftRight","float32");A.b(4===t.rank,(function(){return"Error in flipLeftRight: image must be rank 4,"+"but got rank ".concat(t.rank,".")}));var n={image:t};return ie.a.runKernel(oe.fb,n,{})}});var mr=Object(j.b)({rotateWithOffset_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,a=Object(O.a)(e,"image","rotateWithOffset","float32");A.b(4===a.rank,(function(){return"Error in rotateWithOffset: image must be rank 4,"+"but got rank ".concat(a.rank,".")}));var i={image:a},o={radians:t,fillValue:n,center:r},s=ie.a.runKernel(oe.uc,i,o);return s}});function vr(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),A.b(0<=r&&r<=1,(function(){return"iouThreshold must be in [0, 1], but was '".concat(r,"'")})),A.b(2===e.rank,(function(){return"boxes must be a 2D tensor, but was of rank '".concat(e.rank,"'")})),A.b(4===e.shape[1],(function(){return"boxes must have 4 columns, but 2nd dimension was ".concat(e.shape[1])})),A.b(1===t.rank,(function(){return"scores must be a 1D tensor"})),A.b(t.shape[0]===o,(function(){return"scores has incompatible shape with boxes. Expected ".concat(o,", ")+"but was ".concat(t.shape[0])})),A.b(0<=i&&i<=1,(function(){return"softNmsSigma must be in [0, 1], but was '".concat(i,"'")})),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}var gr=Object(j.b)({nonMaxSuppression_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Number.NEGATIVE_INFINITY,i=Object(O.a)(e,"boxes","nonMaxSuppression"),o=Object(O.a)(t,"scores","nonMaxSuppression"),s=vr(i,o,n,r,a),c={maxOutputSize:n=s.maxOutputSize,iouThreshold:r=s.iouThreshold,scoreThreshold:a=s.scoreThreshold};return ie.a.runKernel(oe.Xb,{boxes:i,scores:o},c)}}),yr=n(99);function Or(){return(Or=Object(zn.a)(Mn.a.mark((function e(t,n,r){var a,i,o,s,c,u,l,d,f,p,h=arguments;return Mn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=h.length>3&&void 0!==h[3]?h[3]:.5,i=h.length>4&&void 0!==h[4]?h[4]:Number.NEGATIVE_INFINITY,o=Object(O.a)(t,"boxes","nonMaxSuppressionAsync"),s=Object(O.a)(n,"scores","nonMaxSuppressionAsync"),c=vr(o,s,r,a,i),r=c.maxOutputSize,a=c.iouThreshold,i=c.scoreThreshold,e.next=10,Promise.all([o.data(),s.data()]);case 10:return u=e.sent,l=u[0],d=u[1],f=Object(yr.a)(l,d,r,a,i),p=f.selectedIndices,o!==t&&o.dispose(),s!==n&&s.dispose(),e.abrupt("return",Object(gn.a)(p,"int32"));case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var xr=function(e,t,n){return Or.apply(this,arguments)};var kr=Object(j.b)({nonMaxSuppressionWithScore_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Number.NEGATIVE_INFINITY,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=Object(O.a)(e,"boxes","nonMaxSuppression"),s=Object(O.a)(t,"scores","nonMaxSuppression"),c=vr(o,s,n,r,a,i),u={boxes:o,scores:s},l={maxOutputSize:n=c.maxOutputSize,iouThreshold:r=c.iouThreshold,scoreThreshold:a=c.scoreThreshold,softNmsSigma:i=c.softNmsSigma},d=ie.a.runKernel(oe.Zb,u,l);return{selectedIndices:d[0],selectedScores:d[1]}}});function wr(){return(wr=Object(zn.a)(Mn.a.mark((function e(t,n,r){var a,i,o,s,c,u,l,d,f,p,h,b,m=arguments;return Mn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=m.length>3&&void 0!==m[3]?m[3]:.5,i=m.length>4&&void 0!==m[4]?m[4]:Number.NEGATIVE_INFINITY,o=m.length>5&&void 0!==m[5]?m[5]:0,s=Object(O.a)(t,"boxes","nonMaxSuppressionAsync"),c=Object(O.a)(n,"scores","nonMaxSuppressionAsync"),u=vr(s,c,r,a,i,o),r=u.maxOutputSize,a=u.iouThreshold,i=u.scoreThreshold,o=u.softNmsSigma,e.next=12,Promise.all([s.data(),c.data()]);case 12:return l=e.sent,d=l[0],f=l[1],p=Object(yr.c)(d,f,r,a,i,o),h=p.selectedIndices,b=p.selectedScores,s!==t&&s.dispose(),c!==n&&c.dispose(),e.abrupt("return",{selectedIndices:Object(gn.a)(h,"int32"),selectedScores:Object(gn.a)(b)});case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var jr=function(e,t,n){return wr.apply(this,arguments)};var Sr=Object(j.b)({nonMaxSuppressionPadded_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Number.NEGATIVE_INFINITY,i=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=Object(O.a)(e,"boxes","nonMaxSuppression"),s=Object(O.a)(t,"scores","nonMaxSuppression"),c=vr(o,s,n,r,a,null),u=c.maxOutputSize,l=c.iouThreshold,d=c.scoreThreshold,f={boxes:o,scores:s},p={maxOutputSize:u,iouThreshold:l,scoreThreshold:d,padToMaxOutputSize:i},h=ie.a.runKernel(oe.Yb,f,p);return{selectedIndices:h[0],validOutputs:h[1]}}});function Nr(){return(Nr=Object(zn.a)(Mn.a.mark((function e(t,n,r){var a,i,o,s,c,u,l,d,f,p,h,b,m,v,g,y,x=arguments;return Mn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=x.length>3&&void 0!==x[3]?x[3]:.5,i=x.length>4&&void 0!==x[4]?x[4]:Number.NEGATIVE_INFINITY,o=x.length>5&&void 0!==x[5]&&x[5],s=Object(O.a)(t,"boxes","nonMaxSuppressionAsync"),c=Object(O.a)(n,"scores","nonMaxSuppressionAsync"),u=vr(s,c,r,a,i,null),l=u.maxOutputSize,d=u.iouThreshold,f=u.scoreThreshold,e.next=11,Promise.all([s.data(),c.data()]);case 11:return p=e.sent,h=Object(Zn.a)(p,2),b=h[0],m=h[1],v=Object(yr.b)(b,m,l,d,f,o),g=v.selectedIndices,y=v.validOutputs,s!==t&&s.dispose(),c!==n&&c.dispose(),e.abrupt("return",{selectedIndices:Object(gn.a)(g,"int32"),validOutputs:Object(Vt.a)(y,"int32")});case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ir=function(e,t,n){return Nr.apply(this,arguments)},Cr=n(232),Tr=n(230);function Er(e,t){for(var n,r,a,i,o,c,u=Object(gn.a)([-1]),l=Object(gn.a)([0]),d=Object(gn.a)([0]),f=0;f1&&void 0!==arguments[1]?arguments[1]:"binary",o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,u=Object(O.a)(e,"image","threshold"),l=.2989,d=.587,f=.114,p=u.shape[0]*u.shape[1],h=Object(w.a)(Object(gn.a)([c]),255);if(A.b(3===u.rank,(function(){return"Error in threshold: image must be rank 3,"+"but got rank ".concat(u.rank,".")})),A.b(3===u.shape[2]||1===u.shape[2],(function(){return"Error in threshold: image color channel must be equal to 3 or 1"+"but got ".concat(u.shape[2],".")})),A.b("int32"===u.dtype||"float32"===u.dtype,(function(){return"Error in dtype: image dtype must be int32 or float32,"+"but got dtype ".concat(u.dtype,".")})),A.b("otsu"===i||"binary"===i,(function(){return"Method must be binary or otsu, but was ".concat(i)})),3===u.shape[2]){var b=Object(cn.a)(u,[1,1,1],-1),m=Object(Zn.a)(b,3);t=m[0],n=m[1],r=m[2];var v=Object(w.a)(t,l),g=Object(w.a)(n,d),y=Object(w.a)(r,f);a=Object(s.a)(Object(s.a)(v,g),y)}else a=e;if("otsu"===i){var x=Object(_.a)(Object(L.a)(Object(Wt.a)(a),"int32"),Object(vn.a)([]),256);h=Er(x,p)}var k=o?Object(De.a)(a,h):Object(Ne.a)(a,h),j=Object(L.a)(Object(w.a)(k,255),"int32");return j}});var Rr=Object(j.b)({transform_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"nearest",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"constant",a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5?arguments[5]:void 0,o=Object(O.a)(e,"image","transform","float32"),s=Object(O.a)(t,"transforms","transform","float32");A.b(4===o.rank,(function(){return"Error in transform: image must be rank 4,"+"but got rank ".concat(o.rank,".")})),A.b(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"})),A.b(null==i||2===i.length,(function(){return"Error in transform: outputShape must be [height, width] or null, "+"but got ".concat(i,".")}));var c={image:o,transforms:s},u={interpolation:n,fillMode:r,fillValue:a,outputShape:i};return ie.a.runKernel(oe.cd,c,u)}});var Fr=Object(j.b)({bandPart_:function(e,t,n){Object(A.b)(t%1===0,(function(){return"bandPart(): numLower must be an integer, got ".concat(t,".")})),Object(A.b)(n%1===0,(function(){return"bandPart(): numUpper must be an integer, got ".concat(n,".")}));var r=Object(O.a)(e,"a","bandPart");Object(A.b)(r.rank>=2,(function(){return"bandPart(): Rank must be at least 2, got ".concat(r.rank,".")}));var a=r.shape,i=r.shape.slice(-2),o=Object(Zn.a)(i,2),s=o[0],c=o[1];if(!(t<=s))throw new Error("bandPart(): numLower (".concat(t,")")+" must not be greater than the number of rows (".concat(s,")."));if(!(n<=c))throw new Error("bandPart(): numUpper (".concat(n,")")+" must not be greater than the number of columns (".concat(c,")."));t<0&&(t=s),n<0&&(n=c);var u=Object(ye.a)(Object(At.a)(0,s,1,"int32"),[-1,1]),l=Object(At.a)(0,c,1,"int32"),d=Object(st.a)(u,l),f=Object(Ue.a)(Object(De.a)(d,Object(Vt.a)(+t,"int32")),Object(Ie.a)(d,Object(Vt.a)(-n,"int32"))),p=Object(Fn.a)([s,c],r.dtype);return Object(ye.a)(Object(fn.a)(Object(Tn.a)(Object(ye.a)(r,[-1,s,c])).map((function(e){return Object(An.a)(f,e,p)}))),a)}});var Dr=Object(j.b)({gramSchmidt_:function(e){var t;Array.isArray(e)?function(){t=!1,Object(A.b)(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){Object(A.b)(e[t].shape[0]===n,(function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: "+"(".concat(e[t].shape[0]," vs. ").concat(n,")")}))},a=1;a0)for(var a=0;a1&&void 0!==arguments[1]&&arguments[1];return ie.a.tidy((function(){Object(A.b)(2===e.shape.length,(function(){return"qr2d() requires a 2D Tensor, but got a ".concat(e.shape.length,"D Tensor.")}));for(var n=e.shape[0],r=e.shape[1],a=xe(n),i=Object(W.a)(e),o=On([[1]],[1,1]),s=Object(W.a)(o),c=n>=r?r:n,u=function(e){var t=i,c=s,u=a,l=ie.a.tidy((function(){var t=Object(N.a)(i,[e,e],[n-e,1]),c=Object(Wn.a)(t),u=Object(N.a)(i,[e,e],[1,1]),l=Object(An.a)(Object(Ne.a)(u,0),On([[-1]]),On([[1]])),d=Object(st.a)(u,Object(w.a)(l,c)),f=Object(ue.a)(t,d);s=1===f.shape[0]?Object(W.a)(o):Object(x.a)([o,Object(N.a)(f,[1,0],[f.shape[0]-1,f.shape[1]])],0);var p=Object(dt.a)(Object(ue.a)(Object(k.a)(l,d),c)),h=Object(N.a)(i,[e,0],[n-e,r]),b=Object(w.a)(p,s),m=Object(Bn.a)(s);if(0===e)i=Object(st.a)(h,Object(k.a)(b,Object(k.a)(m,h)));else{var v=Object(st.a)(h,Object(k.a)(b,Object(k.a)(m,h)));i=Object(x.a)([Object(N.a)(i,[0,0],[e,r]),v],0)}var g=Object(Bn.a)(b),y=Object(N.a)(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=Object(st.a)(y,Object(k.a)(Object(k.a)(y,s),g));else{var O=Object(st.a)(y,Object(k.a)(Object(k.a)(y,s),g));a=Object(x.a)([Object(N.a)(a,[0,0],[n,e]),O],1)}return[s,i,a]})),d=Object(Zn.a)(l,3);s=d[0],i=d[1],a=d[2],Object(_r.b)([t,c,u])},l=0;lr&&(a=Object(N.a)(a,[0,0],[n,r]),i=Object(N.a)(i,[0,0],[r,r])),[a,i]}))}var zr=Object(j.b)({qr_:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Object(A.b)(e.rank>=2,(function(){return"qr() requires input tensor to have a rank >= 2, but got rank ".concat(e.rank)})),2===e.rank)return Mr(e,t);var n=e.shape.slice(0,e.shape.length-2).reduce((function(e,t){return e*t})),r=Object(Tn.a)(Object(ye.a)(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],i=[];r.forEach((function(e){var n=Mr(e,t),r=Object(Zn.a)(n,2),o=r[0],s=r[1];a.push(o),i.push(s)}));var o=Object(ye.a)(Object(fn.a)(a,0),e.shape),s=Object(ye.a)(Object(fn.a)(i,0),e.shape);return[o,s]}}),Lr=n(56);var Pr=Object(j.b)({computeWeightedLoss_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Lr.a.SUM_BY_NONZERO_WEIGHTS,r=Object(O.a)(e,"losses","computeWeightedLoss"),a=null;null!=t&&(a=Object(O.a)(t,"weights","computeWeightedLoss"));var i=null==a?r:Object(w.a)(r,a);if(n===Lr.a.NONE)return i;if(n===Lr.a.SUM)return Object(bn.a)(i);if(n===Lr.a.MEAN){if(null==a)return Object(Qe.a)(i);var o=r.size/a.size,s=Object(ue.a)(Object(bn.a)(i),Object(bn.a)(a));return o>1?Object(ue.a)(s,Object(Vt.a)(o)):s}if(n===Lr.a.SUM_BY_NONZERO_WEIGHTS){if(null==a)return Object(ue.a)(Object(bn.a)(i),Object(Vt.a)(r.size));var c=Object(w.a)(a,Object(Ze.a)(r.shape)),u=Object(L.a)(Object(bn.a)(Object(ft.a)(c,Object(Vt.a)(0))),"float32");return Object(ue.a)(Object(bn.a)(i),u)}throw Error("Unknown reduction: ".concat(n))}});var Br=Object(j.b)({absoluteDifference_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Lr.a.SUM_BY_NONZERO_WEIGHTS,i=Object(O.a)(e,"labels","absoluteDifference"),o=Object(O.a)(t,"predictions","absoluteDifference"),s=null;null!=n&&(s=Object(O.a)(n,"weights","absoluteDifference")),Object(A.e)(i.shape,o.shape,"Error in absoluteDifference: ");var c=Object(a.a)(Object(st.a)(i,o));return Pr(c,s,r)}});var Wr=Object(j.b)({cosineDistance_:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Lr.a.SUM_BY_NONZERO_WEIGHTS,i=Object(O.a)(e,"labels","cosineDistance"),o=Object(O.a)(t,"predictions","cosineDistance"),s=null;null!=r&&(s=Object(O.a)(r,"weights","cosineDistance")),Object(A.e)(i.shape,o.shape,"Error in cosineDistance: ");var c=Object(Vt.a)(1),u=Object(st.a)(c,Object(bn.a)(Object(w.a)(i,o),n,!0));return Pr(u,s,a)}});var Ur=Object(j.b)({hingeLoss_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Lr.a.SUM_BY_NONZERO_WEIGHTS,a=Object(O.a)(e,"labels","hingeLoss"),i=Object(O.a)(t,"predictions","hingeLoss"),o=null;null!=n&&(o=Object(O.a)(n,"weights","hingeLoss")),Object(A.e)(a.shape,i.shape,"Error in hingeLoss: ");var s=Object(Vt.a)(1);a=Object(st.a)(Object(w.a)(Object(Vt.a)(2),a),s);var c=Object(Dt.a)(Object(st.a)(s,Object(w.a)(a,i)));return Pr(c,o,r)}});var Vr=Object(j.b)({huberLoss_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Lr.a.SUM_BY_NONZERO_WEIGHTS,o=Object(O.a)(e,"labels","huberLoss"),c=Object(O.a)(t,"predictions","huberLoss"),u=null;null!=n&&(u=Object(O.a)(n,"weights","huberLoss")),Object(A.e)(o.shape,c.shape,"Error in huberLoss: ");var l=Object(Vt.a)(r),d=Object(a.a)(Object(st.a)(c,o)),f=Object(nt.a)(d,l),p=Object(st.a)(d,f),h=Object(s.a)(Object(w.a)(Object(Vt.a)(.5),Object(ot.a)(f)),Object(w.a)(l,p));return Pr(h,u,i)}});var Hr=Object(j.b)({logLoss_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e-7,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Lr.a.SUM_BY_NONZERO_WEIGHTS,i=Object(O.a)(e,"labels","logLoss"),o=Object(O.a)(t,"predictions","logLoss"),c=null;null!=n&&(c=Object(O.a)(n,"weights","logLoss")),Object(A.e)(i.shape,o.shape,"Error in logLoss: ");var u=Object(Vt.a)(1),l=Object(Vt.a)(r),d=Object(dt.a)(Object(w.a)(i,Object(ze.a)(Object(s.a)(o,l)))),f=Object(w.a)(Object(st.a)(u,i),Object(ze.a)(Object(s.a)(Object(st.a)(u,o),l))),p=Object(st.a)(d,f);return Pr(p,c,a)}});var Gr=Object(j.b)({meanSquaredError_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Lr.a.SUM_BY_NONZERO_WEIGHTS,a=Object(O.a)(e,"labels","meanSquaredError"),i=Object(O.a)(t,"predictions","meanSquaredError"),o=null;null!=n&&(o=Object(O.a)(n,"weights","meanSquaredError")),Object(A.e)(a.shape,i.shape,"Error in meanSquaredError: ");var s=Object(ln.a)(a,i);return Pr(s,o,r)}});function qr(e,t){var n=Object(O.a)(e,"labels","sigmoidCrossEntropyWithLogits"),r=Object(O.a)(t,"logits","sigmoidCrossEntropyWithLogits");Object(A.e)(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var i=Object(Dt.a)(r),o=Object(w.a)(r,n),c=Object(Le.a)(Object(me.a)(Object(dt.a)(Object(a.a)(r))));return Object(s.a)(Object(st.a)(i,o),c)}var Kr=Object(j.b)({sigmoidCrossEntropy_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Lr.a.SUM_BY_NONZERO_WEIGHTS,i=Object(O.a)(e,"multiClassLabels","sigmoidCrossEntropy"),o=Object(O.a)(t,"logits","sigmoidCrossEntropy"),c=null;if(null!=n&&(c=Object(O.a)(n,"weights","sigmoidCrossEntropy")),Object(A.e)(i.shape,o.shape,"Error in sigmoidCrossEntropy: "),r>0){var u=Object(Vt.a)(r),l=Object(Vt.a)(1),d=Object(Vt.a)(.5);i=Object(s.a)(Object(w.a)(i,Object(st.a)(l,u)),Object(w.a)(d,u))}var f=qr(i,o);return Pr(f,c,a)}});function Xr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;if(-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 ".concat(t.rank," ")+"and dim was ".concat(n));var r=Object(Jn.a)((function(e,t,r){var a=Object(We.a)(t,[n],!0),i=Object(st.a)(Object(L.a)(t,"float32"),a);r([e,i]);var o=Object(dt.a)(Object(w.a)(i,e));return{value:Object(bn.a)(o,[n]),gradFunc:function(e,t){var r=Object(Zn.a)(t,2),a=r[0],i=r[1],o=Object(it.e)(e.shape,[n]);return[Object(w.a)(Object(ye.a)(e,o),Object(st.a)(Object(L.a)(a,"float32"),Object(me.a)(i))),Object(w.a)(Object(ye.a)(e,o),Object(st.a)(Object(me.a)(i),Object(L.a)(a,"float32")))]}}}));return r(e,t)}var Yr=Object(j.b)({softmaxCrossEntropy_:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Lr.a.SUM_BY_NONZERO_WEIGHTS,i=Object(O.a)(e,"onehotLabels","softmaxCrossEntropy"),o=Object(O.a)(t,"logits","softmaxCrossEntropy"),c=null;if(null!=n&&(c=Object(O.a)(n,"weights","softmaxCrossEntropy")),Object(A.e)(i.shape,o.shape,"Error in softmaxCrossEntropy: "),r>0){var u=Object(Vt.a)(r),l=Object(Vt.a)(1),d=Object(Vt.a)(i.shape[1]);i=Object(s.a)(Object(w.a)(i,Object(st.a)(l,u)),Object(ue.a)(u,d))}var f=Xr(i,o);return Pr(f,c,a)}});var $r=Object(j.b)({sparseFillEmptyRows_:function(e,t,n,r){var a=Object(O.a)(e,"indices","sparseFillEmptyRows"),i=Object(O.a)(t,"values","sparseFillEmptyRows"),o=Object(O.a)(n,"denseShape","sparseFillEmptyRows"),s=Object(O.a)(r,"defaultValue","sparseFillEmptyRows",i.dtype);if(2!==a.rank)throw new Error("Indices should be Tensor2D but received shape\n ".concat(a.shape));if(1!==i.rank)throw new Error("Values should be Tensor1D but received shape ".concat(i.shape));if(1!==o.rank)throw new Error("Dense shape should be Tensor1D but received shape ".concat(o.shape));if(0!==s.rank)throw new Error("Default value should be a scalar but received shape ".concat(s.shape));var c={indices:a,values:i,denseShape:o,defaultValue:s},u=ie.a.runKernel(oe.Ic,c);return{outputIndices:u[0],outputValues:u[1],emptyRowIndicator:u[2],reverseIndexMap:u[3]}}});var Qr=Object(j.b)({sparseReshape_:function(e,t,n){var r=Object(O.a)(e,"inputIndices","sparseReshape"),a=Object(O.a)(t,"inputShape","sparseReshape"),i=Object(O.a)(n,"newShape","sparseReshape");if(2!==r.rank)throw new Error("Input indices should be Tensor2D but received shape\n ".concat(r.shape));if(1!==a.rank)throw new Error("Input shape should be Tensor1D but received shape ".concat(a.shape));if(1!==i.rank)throw new Error("New shape should be Tensor1D but received shape ".concat(i.shape));var o={inputIndices:r,inputShape:a,newShape:i},s=ie.a.runKernel(oe.Jc,o);return{outputIndices:s[0],outputShape:s[1]}}});var Zr=Object(j.b)({sparseSegmentMean_:function(e,t,n){var r=Object(O.a)(e,"data","sparseSegmentMean"),a=Object(O.a)(t,"indices","sparseSegmentMean"),i=Object(O.a)(n,"segmentIds","sparseSegmentMean");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 ".concat(a.shape));if(1!==i.rank)throw new Error("Segment ids should be Tensor1D but received shape\n ".concat(i.shape));var o={data:r,indices:a,segmentIds:i};return ie.a.runKernel(oe.Kc,o)}});var Jr=Object(j.b)({sparseSegmentSum_:function(e,t,n){var r=Object(O.a)(e,"data","sparseSegmentSum"),a=Object(O.a)(t,"indices","sparseSegmentSum"),i=Object(O.a)(n,"segmentIds","sparseSegmentSum");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 ".concat(a.shape));if(1!==i.rank)throw new Error("Segment ids should be Tensor1D but received shape\n ".concat(i.shape));var o={data:r,indices:a,segmentIds:i};return ie.a.runKernel(oe.Lc,o)}});var ea=Object(j.b)({stringNGrams_:function(e,t,n,r,a,i,o,s){var c=Object(O.a)(e,"data","stringNGrams","string");if("string"!==c.dtype)throw new Error("Data must be of datatype string");if(1!==c.shape.length)throw new Error("Data must be a vector, saw: ".concat(c.shape));var u=Object(O.a)(t,"dataSplits","stringNGrams");if("int32"!==u.dtype)throw new Error("Data splits must be of datatype int32");var l={separator:n,nGramWidths:r,leftPad:a,rightPad:i,padWidth:o,preserveShortSequences:s},d={data:c,dataSplits:u},f=ie.a.runKernel(oe.Tc,d,l);return{nGrams:f[0],nGramsSplits:f[1]}}});var ta=Object(j.b)({stringSplit_:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=Object(O.a)(e,"input","stringSplit","string"),a=Object(O.a)(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error("Input should be Tensor1D but received shape ".concat(r.shape));if(0!==a.rank)throw new Error("Delimiter should be a scalar but received shape ".concat(a.shape));var i={skipEmpty:n},o={input:r,delimiter:a},s=ie.a.runKernel(oe.Uc,o,i);return{indices:s[0],values:s[1],shape:s[2]}}});var na=Object(j.b)({stringToHashBucketFast_:function(e,t){var n=Object(O.a)(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 ie.a.runKernel(oe.Vc,a,r)}}),ra={fft:rn.a,ifft:an.a,rfft:sn.a,irfft:on.a},aa={hammingWindow:lr,hannWindow:dr,frame:fr,stft:pr},ia={flipLeftRight:br,resizeNearestNeighbor:Tr.a,resizeBilinear:Cr.a,rotateWithOffset:mr,cropAndResize:hr,nonMaxSuppression:gr,nonMaxSuppressionAsync:xr,nonMaxSuppressionWithScore:kr,nonMaxSuppressionWithScoreAsync:jr,nonMaxSuppressionPadded:Sr,nonMaxSuppressionPaddedAsync:Ir,threshold:Ar,transform:Rr},oa={bandPart:Fr,gramSchmidt:Dr,qr:zr},sa={absoluteDifference:Br,computeWeightedLoss:Pr,cosineDistance:Wr,hingeLoss:Ur,huberLoss:Vr,logLoss:Hr,meanSquaredError:Gr,sigmoidCrossEntropy:Kr,softmaxCrossEntropy:Yr},ca={sparseFillEmptyRows:$r,sparseReshape:Qr,sparseSegmentMean:Zr,sparseSegmentSum:Jr},ua={stringNGrams:ea,stringSplit:ta,stringToHashBucketFast:na}},function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return h})),n.d(t,"c",(function(){return m}));var r=n(6),a=n(5),i=n.n(a),o=n(12),s=n(7),c=n(11),u=n(15),l="tfjsflags",d=function(){function e(t){Object(s.a)(this,e),this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=f,this.populateURLFlags()}return Object(c.a)(e,[{key:"setPlatform",value:function(e,t){null!=this.platform&&console.warn("Platform ".concat(this.platformName," has already been set. ")+"Overwriting the platform with ".concat(t,".")),this.platformName=e,this.platform=t}},{key:"registerFlag",value:function(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){var r=this.urlFlags[e];console.warn("Setting feature override from URL ".concat(e,": ").concat(r,".")),this.set(e,r)}}},{key:"getAsync",value:function(){var e=Object(o.a)(i.a.mark((function e(t){return i.a.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)}}()},{key:"get",value:function(e){if(e in this.flags)return this.flags[e];var t=this.evaluateFlag(e);if(Object(u.x)(t))throw new Error("Flag ".concat(e," cannot be synchronously evaluated. ")+"Please use getAsync() instead.");return this.flags[e]=t,this.flags[e]}},{key:"getNumber",value:function(e){return this.get(e)}},{key:"getBool",value:function(e){return this.get(e)}},{key:"getFlags",value:function(){return this.flags}},{key:"features",get:function(){return this.flags}},{key:"set",value:function(e,t){if(null==this.flagRegistry[e])throw new Error("Cannot set flag ".concat(e," as it has not been registered."));this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}},{key:"evaluateFlag",value:function(e){if(null==this.flagRegistry[e])throw new Error("Cannot evaluate flag '".concat(e,"': no evaluation function found."));return this.flagRegistry[e].evaluationFn()}},{key:"setFlags",value:function(e){this.flags=Object.assign({},e)}},{key:"reset",value:function(){this.flags={},this.urlFlags={},this.populateURLFlags()}},{key:"populateURLFlags",value:function(){var e=this;if("undefined"!==typeof this.global&&"undefined"!==typeof this.global.location&&"undefined"!==typeof this.global.location.search){var t=this.getQueryParams(this.global.location.search);if(l in t)t.tfjsflags.split(",").forEach((function(t){var n=t.split(":"),a=Object(r.a)(n,2),i=a[0],o=a[1];e.urlFlags[i]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if("".concat(+t)===t)return+t;throw new Error("Could not parse value flag value ".concat(t," for flag ").concat(e,"."))}(i,o)}))}}}]),e}();function f(e){var t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a2&&void 0!==arguments[2]&&arguments[2],c=arguments.length>3&&void 0!==arguments[3]&&arguments[3],u=Object(s.a)(e,"a","matMul"),l=Object(s.a)(t,"b","matMul"),d=Object(o.makeTypesMatch)(u,l),f=Object(r.a)(d,2),p={a:u=f[0],b:l=f[1]},h={transposeA:n,transposeB:c};return a.a.runKernel(i.s,p,h)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(312);function a(e){if("string"!==typeof e)throw new Error(Object(r.a)(7));return e.charAt(0).toUpperCase()+e.slice(1)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({slice_:function(e,t,n){var o=Object(i.a)(e,"x","slice","string_or_numeric");if(0===o.rank)throw new Error("Slicing scalar is not possible");var s={x:o},c={begin:t,size:n};return r.a.runKernel(a.Ec,s,c)}})},function(e,t,n){"use strict";n.d(t,"c",(function(){return s})),n.d(t,"e",(function(){return c})),n.d(t,"h",(function(){return u})),n.d(t,"b",(function(){return l})),n.d(t,"d",(function(){return d})),n.d(t,"g",(function(){return f})),n.d(t,"f",(function(){return p})),n.d(t,"a",(function(){return h}));var r=n(9),a=n(38),i=n(10),o=n(39);function s(){return r.a}function c(){return r.a.memory()}function u(e,t){return r.a.tidy(e,t)}function l(e){Object(o.getTensorsInContainer)(e).forEach((function(e){return e.dispose()}))}function d(e){return r.a.keep(e)}function f(e){return r.a.setBackend(e)}function p(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return r.a.registerBackend(e,t,n)}function h(){return r.a.backend}Object(i.e)((function(e){Object(a.b)().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({neg_:function(e){var t={x:Object(i.a)(e,"x","neg")};return r.a.runKernel(a.Wb,t)}})},,function(e,t,n){"use strict";n.d(t,"d",(function(){return s})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return l})),n.d(t,"a",(function(){return d})),n.d(t,"e",(function(){return f}));var r=n(312);function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Math.min(Math.max(t,e),n)}function i(e){if(e.type)return e;if("#"===e.charAt(0))return i(function(e){e=e.substr(1);var t=new RegExp(".{1,".concat(e.length>=6?2:1,"}"),"g"),n=e.match(t);return n&&1===n[0].length&&(n=n.map((function(e){return e+e}))),n?"rgb".concat(4===n.length?"a":"","(").concat(n.map((function(e,t){return t<3?parseInt(e,16):Math.round(parseInt(e,16)/255*1e3)/1e3})).join(", "),")"):""}(e));var t=e.indexOf("("),n=e.substring(0,t);if(-1===["rgb","rgba","hsl","hsla"].indexOf(n))throw new Error(Object(r.a)(3,e));var a=e.substring(t+1,e.length-1).split(",");return{type:n,values:a=a.map((function(e){return parseFloat(e)}))}}function o(e){var t=e.type,n=e.values;return-1!==t.indexOf("rgb")?n=n.map((function(e,t){return t<3?parseInt(e,10):e})):-1!==t.indexOf("hsl")&&(n[1]="".concat(n[1],"%"),n[2]="".concat(n[2],"%")),"".concat(t,"(").concat(n.join(", "),")")}function s(e,t){var n=c(e),r=c(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function c(e){var t="hsl"===(e=i(e)).type?i(function(e){var t=(e=i(e)).values,n=t[0],r=t[1]/100,a=t[2]/100,s=r*Math.min(a,1-a),c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(e+n/30)%12;return a-s*Math.max(Math.min(t-3,9-t,1),-1)},u="rgb",l=[Math.round(255*c(0)),Math.round(255*c(8)),Math.round(255*c(4))];return"hsla"===e.type&&(u+="a",l.push(t[3])),o({type:u,values:l})}(e)).values:e.values;return t=t.map((function(e){return(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)})),Number((.2126*t[0]+.7152*t[1]+.0722*t[2]).toFixed(3))}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.15;return c(e)>.5?d(e,t):f(e,t)}function l(e,t){return e=i(e),t=a(t),"rgb"!==e.type&&"hsl"!==e.type||(e.type+="a"),e.values[3]=t,o(e)}function d(e,t){if(e=i(e),t=a(t),-1!==e.type.indexOf("hsl"))e.values[2]*=1-t;else if(-1!==e.type.indexOf("rgb"))for(var n=0;n<3;n+=1)e.values[n]*=1-t;return o(e)}function f(e,t){if(e=i(e),t=a(t),-1!==e.type.indexOf("hsl"))e.values[2]+=(100-e.values[2])*t;else if(-1!==e.type.indexOf("rgb"))for(var n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*t;return o(e)}},function(e,t,n){"use strict";n.d(t,"d",(function(){return i})),n.d(t,"e",(function(){return o})),n.d(t,"f",(function(){return s})),n.d(t,"a",(function(){return c})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return l})),n.d(t,"i",(function(){return v})),n.d(t,"h",(function(){return g})),n.d(t,"g",(function(){return y}));var r=n(6),a=n(21);function i(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"NHWC",o=arguments.length>5?arguments[5]:void 0,s=e[3],u=[].concat(Object(a.a)(t),[s]),l=y(i);return c(e,u,n,o,r,null,null,l)}function o(e,t,n,a,i,o){var s,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"channelsLast",l=d(t),f=Object(r.a)(l,2),p=f[0],h=f[1];if("channelsLast"===u)s=[p,h,e[3],e[3]];else{if("channelsFirst"!==u)throw new Error("Unknown dataFormat ".concat(u));s=[p,h,e[1],e[1]]}return c(e,s,n,a,i,o,!1,u)}function s(e,t,n,a,i,o){var s,c,l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"NDHWC",d=f(t),p=Object(r.a)(d,3),h=p[0],b=p[1],m=p[2];if("NDHWC"===l)c="channelsLast",s=[h,b,m,e[4],e[4]];else{if("NCDHW"!==l)throw new Error("Unknown dataFormat ".concat(l));c="channelsFirst",s=[h,b,m,e[1],e[1]]}return u(e,s,n,a,i,!1,c,o)}function c(e,t,n,a,i,o){var s=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"channelsLast",u=-1,l=-1,f=-1,b=-1;if("channelsLast"===c){var m=Object(r.a)(e,4);u=m[0],l=m[1],f=m[2],b=m[3]}else{if("channelsFirst"!==c)throw new Error("Unknown dataFormat ".concat(c));var v=Object(r.a)(e,4);u=v[0],b=v[1],l=v[2],f=v[3]}var g,y=Object(r.a)(t,4),O=y[0],x=y[1],k=y[3],w=d(n),j=Object(r.a)(w,2),S=j[0],N=j[1],I=d(a),C=Object(r.a)(I,2),T=C[0],E=C[1],A=p(O,T),R=p(x,E),F=h(i,l,f,S,N,A,R,o,c),D=F.padInfo,_=F.outHeight,M=F.outWidth,z=s?k*b:k;return"channelsFirst"===c?g=[u,z,_,M]:"channelsLast"===c&&(g=[u,_,M,z]),{batchSize:u,dataFormat:c,inHeight:l,inWidth:f,inChannels:b,outHeight:_,outWidth:M,outChannels:z,padInfo:D,strideHeight:S,strideWidth:N,filterHeight:O,filterWidth:x,effectiveFilterHeight:A,effectiveFilterWidth:R,dilationHeight:T,dilationWidth:E,inShape:e,outShape:g,filterShape:t}}function u(e,t,n,a,i){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"channelsLast",c=arguments.length>7?arguments[7]:void 0,u=-1,l=-1,d=-1,h=-1,m=-1;if("channelsLast"===s){var v=Object(r.a)(e,5);u=v[0],l=v[1],d=v[2],h=v[3],m=v[4]}else{if("channelsFirst"!==s)throw new Error("Unknown dataFormat ".concat(s));var g=Object(r.a)(e,5);u=g[0],m=g[1],l=g[2],d=g[3],h=g[4]}var y,O=Object(r.a)(t,5),x=O[0],k=O[1],w=O[2],j=O[4],S=f(n),N=Object(r.a)(S,3),I=N[0],C=N[1],T=N[2],E=f(a),A=Object(r.a)(E,3),R=A[0],F=A[1],D=A[2],_=p(x,R),M=p(k,F),z=p(w,D),L=b(i,l,d,h,I,C,T,_,M,z,c),P=L.padInfo,B=L.outDepth,W=L.outHeight,U=L.outWidth,V=o?j*m:j;return"channelsFirst"===s?y=[u,V,B,W,U]:"channelsLast"===s&&(y=[u,B,W,U,V]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:d,inWidth:h,inChannels:m,outDepth:B,outHeight:W,outWidth:U,outChannels:V,padInfo:P,strideDepth:I,strideHeight:C,strideWidth:T,filterDepth:x,filterHeight:k,filterWidth:w,effectiveFilterDepth:_,effectiveFilterHeight:M,effectiveFilterWidth:z,dilationDepth:R,dilationHeight:F,dilationWidth:D,inShape:e,outShape:y,filterShape:t}}function l(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,a=p(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function d(e){return"number"===typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function f(e){return"number"===typeof e?[e,e,e]:e}function p(e,t){return t<=1?e:e+(e-1)*(t-1)}function h(e,t,n,r,a,i,o,s,c){var u,d,f;if("number"===typeof e){u={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};var p=function(e,t,n,r,a){null==r&&(r=l(e,t,n));var i=e[0],o=e[1];return[m((i-t+2*r)/n+1,a),m((o-t+2*r)/n+1,a)]}([t,n],i,r,e,s);d=p[0],f=p[1]}else if("same"===e){d=Math.ceil(t/r),f=Math.ceil(n/a);var h=Math.max(0,(d-1)*r+i-t),b=Math.max(0,(f-1)*a+o-n),v=Math.floor(h/2),g=h-v,y=Math.floor(b/2);u={top:v,bottom:g,left:y,right:b-y,type:"SAME"}}else if("valid"===e)u={top:0,bottom:0,left:0,right:0,type:"VALID"},d=Math.ceil((t-i+1)/r),f=Math.ceil((n-o+1)/a);else{if("object"!==typeof e)throw Error("Unknown padding parameter: ".concat(e));var O="channelsLast"===c?e[1][0]:e[2][0],x="channelsLast"===c?e[1][1]:e[2][1],k="channelsLast"===c?e[2][0]:e[3][0],w="channelsLast"===c?e[2][1]:e[3][1];u={top:O,bottom:x,left:k,right:w,type:0===O&&0===x&&0===k&&0===w?"VALID":"EXPLICIT"},d=m((t-i+O+x)/r+1,s),f=m((n-o+k+w)/a+1,s)}return{padInfo:u,outHeight:d,outWidth:f}}function b(e,t,n,r,a,i,o,s,c,u,d){var f,p,h,b;if("number"===typeof e){f={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};var v=function(e,t,n,r,a,i){null==a&&(a=l(e,t,r));var o=e[0],s=e[1],c=e[2];return[m((o-t+2*a)/r+1,i),m((s-t+2*a)/r+1,i),m((c-t+2*a)/r+1,i),n]}([t,n,r,1],s,1,a,e,d);p=v[0],h=v[1],b=v[2]}else if("same"===e){var g=((p=Math.ceil(t/a))-1)*a+s-t,y=((h=Math.ceil(n/i))-1)*i+c-n,O=((b=Math.ceil(r/o))-1)*o+u-r,x=Math.floor(g/2),k=g-x,w=Math.floor(y/2),j=y-w,S=Math.floor(O/2);f={top:w,bottom:j,left:S,right:O-S,front:x,back:k,type:"SAME"}}else{if("valid"!==e)throw Error("Unknown padding parameter: ".concat(e));f={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},p=Math.ceil((t-s+1)/a),h=Math.ceil((n-c+1)/i),b=Math.ceil((r-u+1)/o)}return{padInfo:f,outDepth:p,outHeight:h,outWidth:b}}function m(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 ".concat(t))}}function v(e){var t=d(e),n=Object(r.a)(t,3),a=n[0],i=n[1],o=n[2];return 1===a&&1===i&&1===o}function g(e,t){return v(e)||v(t)}function y(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error("Unknown dataFormat ".concat(e))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(92),c=n(8);var u=Object(c.b)({concat_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Object(o.b)(e.length>=1,(function(){return"Pass at least one tensor to concat"}));var n=Object(i.b)(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 ".concat(e.dtype,". "))})),1===n.length)return Object(s.a)(n[0]);var c=n,u={axis:t};return r.a.runKernel(a.B,c,u)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(4),a=n(130);function i(e,t){return r.useMemo((function(){return null==e&&null==t?null:function(n){Object(a.a)(e,n),Object(a.a)(t,n)}}),[e,t])}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),a=n(3),i=n(2),o=n(125),s=n(34),c=n(8);var u=Object(c.b)({where_:function(e,t,n){var c=Object(i.a)(t,"a","where"),u=Object(i.a)(n,"b","where"),l=Object(i.a)(e,"condition","where","bool"),d=Object(s.a)(Object(s.a)(l.shape,c.shape),u.shape),f={condition:Object(o.a)(l,d),t:Object(o.a)(c,d),e:Object(o.a)(u,d)};return r.a.runKernel(a.yc,f)}})},function(e,t,n){"use strict";(function(e){n.d(t,"f",(function(){return f})),n.d(t,"e",(function(){return h})),n.d(t,"a",(function(){return g})),n.d(t,"b",(function(){return y})),n.d(t,"d",(function(){return O})),n.d(t,"c",(function(){return x})),n.d(t,"i",(function(){return k})),n.d(t,"g",(function(){return w})),n.d(t,"h",(function(){return S}));var r=n(6),a=n(5),i=n.n(a),o=n(20),s=n(12),c=n(81),u=n(105),l=n(15),d=n(183);function f(e,t){return p.apply(this,arguments)}function p(){return(p=Object(s.a)(i.a.mark((function e(t,n){var r,a,o,c,u,l;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=[],a=[],o=Array.isArray(t)?t.map((function(e){return e.name})):Object.keys(t),c=function(e){var c=o[e],u=Array.isArray(t)?t[e].tensor:t[c];if("float32"!==u.dtype&&"int32"!==u.dtype&&"bool"!==u.dtype&&"string"!==u.dtype&&"complex64"!==u.dtype)throw new Error("Unsupported dtype in weight '".concat(c,"': ").concat(u.dtype));var l={name:c,shape:u.shape,dtype:u.dtype};if("string"===u.dtype){var d=new Promise(function(){var e=Object(s.a)(i.a.mark((function e(t){var n,r,a,o,s,c,l;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.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),o=0,s=0;s>10]+(1023&s)]+t[s>>10];i[o]=c}return new Float32Array(a)}}}).call(this,n(239).Buffer)},function(e,t,n){"use strict";!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=n(325)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i.Dd})),n.d(t,"d",(function(){return i.Zd})),n.d(t,"f",(function(){return i.lf})),n.d(t,"g",(function(){return i.pf})),n.d(t,"c",(function(){return i.Pd})),n.d(t,"e",(function(){return pd})),n.d(t,"b",(function(){return a}));var r={};n.r(r),n.d(r,"abs",(function(){return Cl.b})),n.d(r,"acos",(function(){return Cl.c})),n.d(r,"acosh",(function(){return Cl.d})),n.d(r,"add",(function(){return Cl.e})),n.d(r,"addN",(function(){return Cl.f})),n.d(r,"all",(function(){return Cl.g})),n.d(r,"any",(function(){return Cl.h})),n.d(r,"argMax",(function(){return Cl.i})),n.d(r,"argMin",(function(){return Cl.j})),n.d(r,"asin",(function(){return Cl.k})),n.d(r,"asinh",(function(){return Cl.l})),n.d(r,"atan",(function(){return Cl.m})),n.d(r,"atan2",(function(){return Cl.n})),n.d(r,"atanh",(function(){return Cl.o})),n.d(r,"avgPool",(function(){return Cl.p})),n.d(r,"avgPool3d",(function(){return Cl.q})),n.d(r,"basicLSTMCell",(function(){return Cl.r})),n.d(r,"batchToSpaceND",(function(){return Cl.w})),n.d(r,"batchNorm",(function(){return Cl.s})),n.d(r,"batchNorm2d",(function(){return Cl.t})),n.d(r,"batchNorm3d",(function(){return Cl.u})),n.d(r,"batchNorm4d",(function(){return Cl.v})),n.d(r,"bincount",(function(){return Cl.x})),n.d(r,"broadcastTo",(function(){return Cl.z})),n.d(r,"buffer",(function(){return Cl.A})),n.d(r,"cast",(function(){return Cl.B})),n.d(r,"ceil",(function(){return Cl.C})),n.d(r,"clipByValue",(function(){return Cl.D})),n.d(r,"clone",(function(){return Cl.E})),n.d(r,"complex",(function(){return Cl.F})),n.d(r,"concat",(function(){return Cl.G})),n.d(r,"concat1d",(function(){return Cl.H})),n.d(r,"concat2d",(function(){return Cl.I})),n.d(r,"concat3d",(function(){return Cl.J})),n.d(r,"concat4d",(function(){return Cl.K})),n.d(r,"conv1d",(function(){return Cl.L})),n.d(r,"conv2d",(function(){return Cl.M})),n.d(r,"conv2dTranspose",(function(){return Cl.N})),n.d(r,"conv3d",(function(){return Cl.O})),n.d(r,"conv3dTranspose",(function(){return Cl.P})),n.d(r,"cos",(function(){return Cl.Q})),n.d(r,"cosh",(function(){return Cl.R})),n.d(r,"cumsum",(function(){return Cl.T})),n.d(r,"denseBincount",(function(){return Cl.U})),n.d(r,"depthToSpace",(function(){return Cl.V})),n.d(r,"depthwiseConv2d",(function(){return Cl.W})),n.d(r,"diag",(function(){return Cl.X})),n.d(r,"dilation2d",(function(){return Cl.Y})),n.d(r,"div",(function(){return Cl.Z})),n.d(r,"divNoNan",(function(){return Cl.ab})),n.d(r,"dot",(function(){return Cl.bb})),n.d(r,"einsum",(function(){return Cl.db})),n.d(r,"elu",(function(){return Cl.eb})),n.d(r,"equal",(function(){return Cl.gb})),n.d(r,"erf",(function(){return Cl.hb})),n.d(r,"exp",(function(){return Cl.ib})),n.d(r,"expandDims",(function(){return Cl.jb})),n.d(r,"expm1",(function(){return Cl.kb})),n.d(r,"eye",(function(){return Cl.lb})),n.d(r,"fill",(function(){return Cl.nb})),n.d(r,"floor",(function(){return Cl.ob})),n.d(r,"floorDiv",(function(){return Cl.pb})),n.d(r,"gather",(function(){return Cl.rb})),n.d(r,"greater",(function(){return Cl.tb})),n.d(r,"greaterEqual",(function(){return Cl.ub})),n.d(r,"imag",(function(){return Cl.wb})),n.d(r,"isFinite",(function(){return Cl.Ab})),n.d(r,"isInf",(function(){return Cl.Bb})),n.d(r,"isNaN",(function(){return Cl.Cb})),n.d(r,"leakyRelu",(function(){return Cl.Db})),n.d(r,"less",(function(){return Cl.Eb})),n.d(r,"lessEqual",(function(){return Cl.Fb})),n.d(r,"linspace",(function(){return Cl.Hb})),n.d(r,"localResponseNormalization",(function(){return Cl.Ib})),n.d(r,"log",(function(){return Cl.Jb})),n.d(r,"log1p",(function(){return Cl.Kb})),n.d(r,"logSigmoid",(function(){return Cl.Lb})),n.d(r,"logSoftmax",(function(){return Cl.Mb})),n.d(r,"logSumExp",(function(){return Cl.Nb})),n.d(r,"logicalAnd",(function(){return Cl.Ob})),n.d(r,"logicalNot",(function(){return Cl.Pb})),n.d(r,"logicalOr",(function(){return Cl.Qb})),n.d(r,"logicalXor",(function(){return Cl.Rb})),n.d(r,"matMul",(function(){return Cl.Tb})),n.d(r,"max",(function(){return Cl.Ub})),n.d(r,"maxPool",(function(){return Cl.Vb})),n.d(r,"maxPool3d",(function(){return Cl.Wb})),n.d(r,"maxPoolWithArgmax",(function(){return Cl.Xb})),n.d(r,"maximum",(function(){return Cl.Yb})),n.d(r,"mean",(function(){return Cl.Zb})),n.d(r,"meshgrid",(function(){return Cl.ac})),n.d(r,"min",(function(){return Cl.bc})),n.d(r,"minimum",(function(){return Cl.cc})),n.d(r,"mirrorPad",(function(){return Cl.dc})),n.d(r,"mod",(function(){return Cl.ec})),n.d(r,"moments",(function(){return Cl.fc})),n.d(r,"mul",(function(){return Cl.hc})),n.d(r,"multiRNNCell",(function(){return Cl.ic})),n.d(r,"multinomial",(function(){return Cl.jc})),n.d(r,"neg",(function(){return Cl.kc})),n.d(r,"notEqual",(function(){return Cl.mc})),n.d(r,"oneHot",(function(){return Cl.nc})),n.d(r,"ones",(function(){return Cl.oc})),n.d(r,"onesLike",(function(){return Cl.pc})),n.d(r,"outerProduct",(function(){return Cl.rc})),n.d(r,"pad",(function(){return Cl.sc})),n.d(r,"pad1d",(function(){return Cl.tc})),n.d(r,"pad2d",(function(){return Cl.uc})),n.d(r,"pad3d",(function(){return Cl.vc})),n.d(r,"pad4d",(function(){return Cl.wc})),n.d(r,"pool",(function(){return Cl.xc})),n.d(r,"pow",(function(){return Cl.yc})),n.d(r,"prelu",(function(){return Cl.zc})),n.d(r,"print",(function(){return Cl.Ac})),n.d(r,"prod",(function(){return Cl.Bc})),n.d(r,"rand",(function(){return Cl.Cc})),n.d(r,"randomGamma",(function(){return Cl.Dc})),n.d(r,"randomNormal",(function(){return Cl.Ec})),n.d(r,"randomUniform",(function(){return Cl.Fc})),n.d(r,"range",(function(){return Cl.Gc})),n.d(r,"real",(function(){return Cl.Hc})),n.d(r,"reciprocal",(function(){return Cl.Ic})),n.d(r,"relu",(function(){return Cl.Jc})),n.d(r,"relu6",(function(){return Cl.Kc})),n.d(r,"reshape",(function(){return Cl.Lc})),n.d(r,"reverse",(function(){return Cl.Mc})),n.d(r,"reverse1d",(function(){return Cl.Nc})),n.d(r,"reverse2d",(function(){return Cl.Oc})),n.d(r,"reverse3d",(function(){return Cl.Pc})),n.d(r,"reverse4d",(function(){return Cl.Qc})),n.d(r,"round",(function(){return Cl.Sc})),n.d(r,"rsqrt",(function(){return Cl.Tc})),n.d(r,"scalar",(function(){return Cl.Uc})),n.d(r,"selu",(function(){return Cl.Wc})),n.d(r,"separableConv2d",(function(){return Cl.Xc})),n.d(r,"setdiff1dAsync",(function(){return Cl.Yc})),n.d(r,"sigmoid",(function(){return Cl.Zc})),n.d(r,"sign",(function(){return Cl.ad})),n.d(r,"sin",(function(){return Cl.cd})),n.d(r,"sinh",(function(){return Cl.dd})),n.d(r,"slice",(function(){return Cl.ed})),n.d(r,"slice1d",(function(){return Cl.fd})),n.d(r,"slice2d",(function(){return Cl.gd})),n.d(r,"slice3d",(function(){return Cl.hd})),n.d(r,"slice4d",(function(){return Cl.id})),n.d(r,"softmax",(function(){return Cl.jd})),n.d(r,"softplus",(function(){return Cl.kd})),n.d(r,"spaceToBatchND",(function(){return Cl.ld})),n.d(r,"fft",(function(){return Cl.mb})),n.d(r,"ifft",(function(){return Cl.vb})),n.d(r,"irfft",(function(){return Cl.zb})),n.d(r,"rfft",(function(){return Cl.Rc})),n.d(r,"split",(function(){return Cl.pd})),n.d(r,"sqrt",(function(){return Cl.qd})),n.d(r,"square",(function(){return Cl.rd})),n.d(r,"squaredDifference",(function(){return Cl.sd})),n.d(r,"squeeze",(function(){return Cl.td})),n.d(r,"stack",(function(){return Cl.ud})),n.d(r,"step",(function(){return Cl.vd})),n.d(r,"stridedSlice",(function(){return Cl.wd})),n.d(r,"sub",(function(){return Cl.yd})),n.d(r,"sum",(function(){return Cl.zd})),n.d(r,"tan",(function(){return Cl.Ad})),n.d(r,"tanh",(function(){return Cl.Bd})),n.d(r,"tensor",(function(){return Cl.Cd})),n.d(r,"tensor1d",(function(){return Cl.Dd})),n.d(r,"tensor2d",(function(){return Cl.Ed})),n.d(r,"tensor3d",(function(){return Cl.Fd})),n.d(r,"tensor4d",(function(){return Cl.Gd})),n.d(r,"tensor5d",(function(){return Cl.Hd})),n.d(r,"tensor6d",(function(){return Cl.Id})),n.d(r,"tile",(function(){return Cl.Jd})),n.d(r,"topk",(function(){return Cl.Kd})),n.d(r,"truncatedNormal",(function(){return Cl.Md})),n.d(r,"unique",(function(){return Cl.Nd})),n.d(r,"unsortedSegmentSum",(function(){return Cl.Od})),n.d(r,"unstack",(function(){return Cl.Pd})),n.d(r,"variable",(function(){return Cl.Qd})),n.d(r,"where",(function(){return Cl.Rd})),n.d(r,"whereAsync",(function(){return Cl.Sd})),n.d(r,"zeros",(function(){return Cl.Td})),n.d(r,"zerosLike",(function(){return Cl.Ud})),n.d(r,"booleanMaskAsync",(function(){return Cl.y})),n.d(r,"transpose",(function(){return Cl.Ld})),n.d(r,"norm",(function(){return Cl.lc})),n.d(r,"movingAverage",(function(){return Cl.gc})),n.d(r,"scatterND",(function(){return Cl.Vc})),n.d(r,"sparseToDense",(function(){return Cl.nd})),n.d(r,"gatherND",(function(){return Cl.sb})),n.d(r,"dropout",(function(){return Cl.cb})),n.d(r,"enclosingPowerOfTwo",(function(){return Cl.fb})),n.d(r,"cosineWindow",(function(){return Cl.S})),n.d(r,"inTopKAsync",(function(){return Cl.yb})),n.d(r,"op",(function(){return Cl.qc})),n.d(r,"OP_SCOPE_SUFFIX",(function(){return Cl.a})),n.d(r,"image",(function(){return Cl.xb})),n.d(r,"linalg",(function(){return Cl.Gb})),n.d(r,"losses",(function(){return Cl.Sb})),n.d(r,"spectral",(function(){return Cl.od})),n.d(r,"fused",(function(){return Cl.qb})),n.d(r,"signal",(function(){return Cl.bd})),n.d(r,"sparse",(function(){return Cl.md})),n.d(r,"string",(function(){return Cl.xd}));var a={};n.r(a),n.d(a,"array",(function(){return Od})),n.d(a,"Dataset",(function(){return gd})),n.d(a,"zip",(function(){return xd})),n.d(a,"CSVDataset",(function(){return Ed})),n.d(a,"TextLineDataset",(function(){return wd})),n.d(a,"csv",(function(){return Wd})),n.d(a,"func",(function(){return Ud})),n.d(a,"generator",(function(){return Vd})),n.d(a,"microphone",(function(){return qd})),n.d(a,"webcam",(function(){return Hd})),n.d(a,"FileDataSource",(function(){return Pd})),n.d(a,"URLDataSource",(function(){return Bd})),n.d(a,"version_data",(function(){return Xd}));var i=n(0),o=n(6),s=n(3),c=n(24),u=n(18),l=n(102),d={kernelName:s.a,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(e,Object(l.a)(Object(c.a)(n,"float32"),-1))}}}},f=n(31),p=n(45),h=n(33),b=n(58),m=n(40),v=n(29),g={kernelName:s.b,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){var t=Object(m.a)(Object(c.a)(n,"float32")),r=Object(b.a)(Object(v.a)(Object(h.a)(1),t));return Object(p.a)(Object(f.a)(e,r))}}}},y={kernelName:s.c,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){var t=Object(b.a)(Object(v.a)(Object(m.a)(Object(c.a)(n,"float32")),1));return Object(f.a)(e,t)}}}},O=n(34),x=n(13),k=n(32),w={kernelName:s.d,inputsToSave:["a","b"],gradFunc:function(e,t){var n=Object(o.a)(t,2),r=n[0],a=n[1],i=O.a(r.shape,a.shape);return{a:function(){var t=e,n=O.c(r.shape,i);return n.length>0&&(t=Object(k.a)(t,n)),Object(x.a)(t,r.shape)},b:function(){var t=e,n=O.c(a.shape,i);return n.length>0&&(t=Object(k.a)(t,n)),Object(x.a)(t,a.shape)}}}},j={kernelName:s.e,saveAllInputs:!0,gradFunc:function(e,t){var n={};return t.forEach((function(t,r){n[r]=function(){return e.clone()}})),n}},S=n(36),N={kernelName:s.h,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(S.a)(n)}}}},I={kernelName:s.i,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(S.a)(n)}}}},C={kernelName:s.j,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(f.a)(e,Object(b.a)(Object(v.a)(Object(h.a)(1),Object(m.a)(Object(c.a)(n,"float32")))))}}}},T=n(27),E={kernelName:s.k,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){var t=Object(b.a)(Object(T.a)(Object(h.a)(1),Object(m.a)(Object(c.a)(n,"float32"))));return Object(f.a)(e,t)}}}},A={kernelName:s.m,inputsToSave:["a","b"],gradFunc:function(e,t){var n=Object(o.a)(t,2),r=n[0],a=n[1],i=Object(O.a)(r.shape,a.shape);return{a:function(){var t=Object(T.a)(Object(m.a)(r),Object(m.a)(a)),n=Object(u.a)(e,Object(f.a)(a,t)),o=Object(O.c)(r.shape,i);return o.length>0&&(n=Object(k.a)(n,o)),Object(x.a)(n,r.shape)},b:function(){var t=Object(T.a)(Object(m.a)(r),Object(m.a)(a)),n=Object(p.a)(Object(u.a)(e,Object(f.a)(r,t))),o=Object(O.c)(a.shape,i);return o.length>0&&(n=Object(k.a)(n,o)),Object(x.a)(n,a.shape)}}}},R={kernelName:s.l,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(f.a)(e,Object(T.a)(Object(m.a)(Object(c.a)(n,"float32")),1))}}}},F={kernelName:s.n,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(f.a)(e,Object(v.a)(Object(h.a)(1),Object(m.a)(Object(c.a)(n,"float32"))))}}}},D=n(9),_=n(2),M=n(15),z=n(8);var L=Object(z.b)({avgPool3dGrad_:function(e,t,n,r,a,i){var o=Object(_.a)(e,"dy","avgPool3dGrad"),c=Object(_.a)(t,"input","avgPool3dGrad"),u=o,l=c,d=!1;4===c.rank&&(d=!0,u=Object(x.a)(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),l=Object(x.a)(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),M.b(5===u.rank,(function(){return"Error in avgPool3dGrad: dy must be rank 5 but got rank "+"".concat(u.rank,".")})),M.b(5===l.rank,(function(){return"Error in avgPool3dGrad: input must be rank 5 but got rank "+"".concat(l.rank,".")})),null!=i&&M.b(M.v(a),(function(){return"Error in avgPool3dGrad: pad must be an integer when "+"using, dimRoundingMode ".concat(i," but got pad ").concat(a,".")}));var f={dy:u,input:l},p={filterSize:n,strides:r,pad:a,dimRoundingMode:i},h=D.a.runKernel(s.q,f,p);return d?Object(x.a)(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),P={kernelName:s.p,inputsToSave:["x"],gradFunc:function(e,t,n){var r=Object(o.a)(t,1)[0],a=n.filterSize,i=n.strides,s=n.pad,c=n.dimRoundingMode;return{x:function(){return L(e,r,a,i,s,c)}}}};var B=Object(z.b)({avgPoolGrad_:function(e,t,n,r,a){var i=Object(_.a)(e,"dy","avgPoolGrad"),o=Object(_.a)(t,"input","avgPoolGrad");M.b(o.rank===i.rank,(function(){return"Rank of input (".concat(o.rank,") does not match rank of dy (").concat(i.rank,")")}));var c=o,u=i,l=!1;3===o.rank&&(l=!0,c=Object(x.a)(o,[1,o.shape[0],o.shape[1],o.shape[2]]),u=Object(x.a)(i,[1,i.shape[0],i.shape[1],i.shape[2]])),M.b(4===u.rank,(function(){return"Error in avgPoolGrad: dy must be rank 4 but got rank "+"".concat(u.rank,".")})),M.b(4===c.rank,(function(){return"Error in avgPoolGrad: input must be rank 4 but got rank "+"".concat(c.rank,".")}));var d={dy:u,input:c},f={filterSize:n,strides:r,pad:a},p=D.a.runKernel(s.r,d,f);return l?Object(x.a)(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),W={kernelName:s.o,inputsToSave:["x"],gradFunc:function(e,t,n){var r=Object(o.a)(t,1)[0],a=n.filterSize,i=n.strides,s=n.pad;return{x:function(){return B(e,r,a,i,s)}}}},U=n(41),V={kernelName:s.s,inputsToSave:["a","b"],gradFunc:function(e,t,n){var r=Object(o.a)(t,2),a=r[0],i=r[1],s=n.transposeA,c=n.transposeB;return s||c?!s&&c?{a:function(){return Object(U.a)(e,i,!1,!1)},b:function(){return Object(U.a)(e,a,!0,!1)}}:s&&!c?{a:function(){return Object(U.a)(i,e,!1,!0)},b:function(){return Object(U.a)(a,e,!1,!1)}}:{a:function(){return Object(U.a)(i,e,!0,!0)},b:function(){return Object(U.a)(e,a,!0,!0)}}:{a:function(){return Object(U.a)(e,i,!1,!0)},b:function(){return Object(U.a)(a,e,!0,!1)}}}},H=n(122),G={kernelName:s.t,gradFunc:function(e,t,n){var r=n.blockShape,a=n.crops;return{x:function(){return Object(H.a)(e,r,a)}}}},q={kernelName:s.v,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(): [".concat(a,"] cannot be broadcast to [").concat(i,"]."));for(var c=[],u=0;u1&&c.push(u);return{x:function(){return Object(k.a)(e,c,!0)}}}},K={kernelName:s.w,gradFunc:function(e){return{x:function(){return e.clone()}}}},X={kernelName:s.x,gradFunc:function(e){return{x:function(){return Object(S.a)(e)}}}},Y=n(91),$=n(76),Q=n(82),Z=n(51),J={kernelName:s.y,inputsToSave:["x"],gradFunc:function(e,t,n){var r=Object(o.a)(t,1)[0],a=n.clipValueMin,i=n.clipValueMax;return{x:function(){return Object(Z.a)(Object(Q.a)(Object(Y.a)(r,a),Object($.a)(r,i)),e,Object(S.a)(e))}}}},ee={kernelName:s.A,inputsToSave:["x"],gradFunc:d.gradFunc},te=n(83),ne={kernelName:s.B,saveAllInputs:!0,gradFunc:function(e,t,n){var r=t.map((function(e){return e.shape})),a=n.axis,i=Object(M.I)(a,t[0].shape)[0],o=r.map((function(e){return e[i]}));return Object(te.a)(e,o,i).map((function(e){return function(){return e}}))}},re=n(167),ae=n(165),ie=n(48),oe={kernelName:s.C,inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=Object(o.a)(t,2),a=r[0],i=r[1],s=n.dilations,c=n.strides,u=n.pad,l=n.dataFormat;return M.b(ie.i(s),(function(){return"Error in gradient of conv2D: dilation rates greater than 1 "+"are not yet supported in gradients. Got dilations '".concat(s,"'")})),{x:function(){return Object(ae.a)(a.shape,e,i,c,u,l)},filter:function(){return Object(re.a)(a,e,i.shape,c,u,l)}}}},se=n(90),ce={kernelName:s.E,inputsToSave:["dy","filter"],gradFunc:function(e,t,n){var r=Object(o.a)(t,2),a=r[0],i=r[1],s=n.strides,c=n.pad,u=n.dataFormat,l=n.dimRoundingMode;return{dy:function(){return Object(se.a)(e,i,s,c,u,1,l)},filter:function(){return Object(re.a)(e,a,i.shape,s,c,u,l)}}}};var ue=Object(z.b)({conv3DBackpropFilter_:function(e,t,n,r,a){var i=e;4===e.rank&&(i=Object(x.a)(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));var o=t;4===o.rank&&(o=Object(x.a)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),M.b(5===i.rank,(function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+"".concat(i.shape,".")})),M.b(5===o.rank,(function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+"".concat(o.shape,".")})),M.b(5===n.length,(function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+"".concat(n,".")})),M.b(i.shape[4]===n[3],(function(){return"Error in conv3dDerFilter: depth of input ".concat(i.shape[4],") must ")+"match input depth in filter (".concat(n[3],".")})),M.b(o.shape[4]===n[4],(function(){return"Error in conv3dDerFilter: depth of dy (".concat(o.shape[4],") must ")+"match output depth for filter (".concat(n[4],").")}));var c={x:i,dy:o},u={strides:r,pad:a,filterShape:n};return D.a.runKernel(s.G,c,u)}}),le=n(229),de={kernelName:s.F,inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=n.dilations,a=n.strides,i=n.pad;M.b(Object(ie.i)(r),(function(){return"Error in gradient of conv3D: dilation rates greater than 1 are "+"not yet supported in gradients. Got dilations '".concat(r,"'")}));var s=Object(o.a)(t,2),c=s[0],u=s[1];return{x:function(){return Object(le.a)(c.shape,e,u,a,i)},filter:function(){return ue(c,e,u.shape,a,i)}}}},fe=n(217),pe={kernelName:s.I,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(Object(p.a)(Object(fe.a)(Object(c.a)(n,"float32"))),e)}}}},he=n(218),be={kernelName:s.J,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(Object(he.a)(Object(c.a)(n,"float32")),e)}}}},me=n(60),ve=n(145),ge=n(78),ye={kernelName:s.L,inputsToSave:["x"],gradFunc:function(e,t,n){var r=Object(o.a)(t,1)[0],a=n.axis,i=n.exclusive,s=n.reverse;return{x:function(){var t=Object(me.f)([a],r.rank),n=Object(ve.a)(e,a,i,!s);return null!=t&&(n=Object(ge.a)(n,t)),n}}}},Oe=n(234),xe=n(233),ke={kernelName:s.O,inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=n.dilations,a=n.strides,i=n.pad,s=n.dimRoundingMode,c=null==r?[1,1]:r;M.b(ie.i(c),(function(){return"Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations "+"'".concat(c,"'")}));var u=Object(o.a)(t,2),l=u[0],d=u[1];return M.b(4===l.rank,(function(){return"Error in gradient of depthwiseConv2dNative: input must be "+"rank 4, but got rank ".concat(l.rank,".")})),M.b(4===d.rank,(function(){return"Error in gradient of depthwiseConv2dNative: filter must be "+"rank 4, but got rank ".concat(d.rank,".")})),M.b(l.shape[3]===d.shape[2],(function(){return"Error in gradient of depthwiseConv2d: number of input "+"channels (".concat(l.shape[3],") must match the inChannels dimension ")+"in filter ".concat(d.shape[2],".")})),M.b(ie.h(a,c),(function(){return"Error in gradient of depthwiseConv2d: Either strides or "+"dilations must be 1. Got strides ".concat(a," and dilations ")+"'".concat(c,"'.")})),null!=s&&M.b(M.v(i),(function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+"dimRoundingMode ".concat(s," but got pad ").concat(i,".")})),{x:function(){return Object(xe.a)(l.shape,e,d,a,i,r,s)},filter:function(){return Object(Oe.a)(l,e,d.shape,a,i,r,s)}}}},we={kernelName:s.S,inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=Object(o.a)(t,2),a=r[0],i=r[1],c={x:a,filter:i,dy:e},u={x:a,filter:i,dy:e};return{x:function(){return D.a.runKernel(s.U,c,n)},filter:function(){return D.a.runKernel(s.T,u,n)}}}},je={kernelName:s.W,outputsToSave:[!0],gradFunc:function(e,t){var n={dy:e,y:Object(o.a)(t,1)[0]};return{x:function(){return D.a.runKernel(s.X,n)}}}},Se=n(61),Ne={kernelName:s.Z,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0],r=Object(u.a)(Object(Se.a)(Object(p.a)(Object(m.a)(n))),2/Math.sqrt(Math.PI));return{x:function(){return Object(u.a)(e,r)}}}},Ie={kernelName:s.ab,outputsToSave:[!0],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(e,n)}}}},Ce={kernelName:s.bb,inputsToSave:["input"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{input:function(){return Object(x.a)(e,n.shape)}}}},Te={kernelName:s.cb,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(e,Object(Se.a)(n))}}}},Ee={kernelName:s.gb,gradFunc:function(e){return{x:function(){return Object(S.a)(e)}}}},Ae={kernelName:s.hb,inputsToSave:["a","b"],gradFunc:function(e,t){var n=Object(o.a)(t,2),r=n[0],a=n[1],i=Object(O.a)(r.shape,a.shape);return{a:function(){var t=Object(f.a)(e,Object(c.a)(a,"float32")),n=Object(O.c)(r.shape,i);return n.length>0?Object(x.a)(Object(k.a)(t,n),r.shape):t},b:function(){var t=Object(u.a)(e,Object(c.a)(r,"float32")),n=Object(O.c)(a.shape,i);n.length>0&&(t=Object(x.a)(Object(k.a)(t,n),a.shape));var o=Object(m.a)(a);return Object(p.a)(Object(f.a)(t,Object(c.a)(o,"float32")))}}}},Re=n(214),Fe=n(106),De={kernelName:s.jb,inputsToSave:["x","mean","variance","scale"],gradFunc:function(e,t,n){var r=n.varianceEpsilon,a=Object(o.a)(t,4),i=a[0],s=a[1],c=a[2],l=a[3],d=null==l?Object(h.a)(1):l,f=Object(O.c)(s.shape,i.shape),p=[];if(1===s.rank){for(var b=0;b3&&void 0!==arguments[3]?arguments[3]:5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.5,c={x:e,y:t,dy:n},u={depthRadius:r,bias:a,alpha:i,beta:o};return D.a.runKernel(s.xb,c,u)}}),$e={kernelName:s.wb,inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=Object(o.a)(t,2),a=r[0],i=r[1],s=n.depthRadius,c=n.bias,u=n.alpha,l=n.beta;return{x:function(){return Ye(a,i,e,s,c,u,l)}}}},Qe=n(117);function Ze(e,t,n,r){return t.rank0?Object(x.a)(Object(k.a)(e,t),r.shape):e},b:function(){var t=Object(u.a)(e,Object(p.a)(Object(ft.a)(Object(f.a)(r,a)))),n=Object(O.c)(a.shape,i);return n.length>0?Object(x.a)(Object(k.a)(t,n),a.shape):t}}}},ht={kernelName:s.Vb,inputsToSave:["a","b"],gradFunc:function(e,t){var n=Object(o.a)(t,2),r=n[0],a=n[1],i=Object(O.a)(r.shape,a.shape);return{a:function(){var t=Object(u.a)(e,Object(c.a)(a,"float32")),n=Object(O.c)(r.shape,i);return n.length>0?Object(x.a)(Object(k.a)(t,n),r.shape):t},b:function(){var t=Object(u.a)(e,Object(c.a)(r,"float32")),n=Object(O.c)(a.shape,i);return n.length>0?Object(x.a)(Object(k.a)(t,n),a.shape):t}}}},bt={kernelName:s.Wb,gradFunc:function(e){return{x:function(){return Object(p.a)(e)}}}},mt=n(100),vt={kernelName:s.bc,inputsToSave:["indices"],gradFunc:function(e,t){var n=t[0];return{indices:function(){return Object(mt.a)(n.shape,"float32")}}}},gt={kernelName:s.cc,gradFunc:function(e){return{x:function(){return Object(S.a)(e)}}}},yt=n(103),Ot={kernelName:s.dc,saveAllInputs:!0,gradFunc:function(e,t,n){var r=n.axis;return Object(yt.a)(e,r).map((function(e){return function(){return e}}))}},xt={kernelName:s.ec,inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.paddings.map((function(e){return e[0]}));return{x:function(){return Object(lt.a)(e,a,r.shape)}}}},kt=n(97),wt=n(73),jt={kernelName:s.fc,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:function(e,t){var n=Object(o.a)(t,3),r=n[0],a=n[1],i=n[2],s=r,l=a,d=O.a(s.shape,l.shape);return{a:function(){var t=Object(c.a)(l,"float32"),n=Object(u.a)(e,Object(u.a)(t,Object(wt.a)(s,Object(v.a)(t,Object(h.a)(1))))),r=O.c(s.shape,d);return r.length>0&&(n=Object(k.a)(n,r)),Object(x.a)(n,s.shape)},b:function(){var t=Object(He.a)(s,0),n=Object(Z.a)(t,Object(kt.a)(s),Object(S.a)(s)),r=Object(u.a)(e,Object(u.a)(i,n)),a=O.c(l.shape,d);return a.length>0&&(r=Object(k.a)(r,a)),Object(x.a)(r,l.shape)}}}},St={kernelName:s.gc,inputsToSave:["x","alpha"],gradFunc:function(e,t){var n=Object(o.a)(t,2),r=n[0],a=n[1],i=Object(He.a)(r,0);return{x:function(){return Object(Z.a)(i,e,Object(u.a)(e,a))},alpha:function(){var t=Object(Z.a)(i,Object(S.a)(e),Object(u.a)(e,r)),n=Object(O.c)(a.shape,e.shape);return n.length>0&&(t=Object(k.a)(t,n)),Object(x.a)(t,a.shape)}}}},Nt={kernelName:s.kc,inputsToSave:["a","b"],gradFunc:function(e,t){var n=Object(o.a)(t,2),r=n[0],a=n[1],i=O.a(r.shape,a.shape);return{a:function(){var t=Object(f.a)(e,Object(c.a)(a,"float32")),n=O.c(r.shape,i);return n.length>0?Object(x.a)(Object(k.a)(t,n),r.shape):t},b:function(){var t=Object(u.a)(e,Object(c.a)(r,"float32")),n=O.c(a.shape,i);n.length>0&&(t=Object(x.a)(Object(k.a)(t,n),a.shape));var o=Object(m.a)(a);return Object(p.a)(Object(f.a)(t,Object(c.a)(o,"float32")))}}}},It={kernelName:s.lc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(f.a)(e,Object(p.a)(Object(m.a)(n)))}}}},Ct={kernelName:s.nc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0],r=Object(u.a)(Object($.a)(n,6),Object(l.a)(n));return{x:function(){return Object(u.a)(e,Object(c.a)(r,"float32"))}}}},Tt={kernelName:s.mc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(e,Object(c.a)(Object(l.a)(n),"float32"))}}}},Et={kernelName:s.oc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(x.a)(e,n.shape)}}}},At={kernelName:s.pc,inputsToSave:["images"],gradFunc:function(e,t,n){var r={dy:e,images:Object(o.a)(t,1)[0]};return{images:function(){return D.a.runKernel(s.qc,r,n)}}}},Rt={kernelName:s.rc,inputsToSave:["images"],gradFunc:function(e,t,n){var r={dy:e,images:Object(o.a)(t,1)[0]};return{images:function(){return D.a.runKernel(s.sc,r,n)}}}},Ft=n(69),Dt={kernelName:s.tc,gradFunc:function(e,t,n){var r=n.dims,a=Object(M.I)(r,e.shape);return{x:function(){return Object(Ft.a)(e,a)}}}},_t={kernelName:s.vc,gradFunc:function(e){return{x:function(){return Object(S.a)(e)}}}},Mt={kernelName:s.wc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(p.a)(Object(f.a)(e,Object(u.a)(Object(wt.a)(n,1.5),2)))}}}},zt=n(120),Lt={kernelName:s.yc,inputsToSave:["condition"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{condition:function(){return Object(c.a)(Object(S.a)(n),"float32")},t:function(){return Object(u.a)(e,Object(c.a)(n,e.dtype))},e:function(){return Object(u.a)(e,Object(c.a)(Object(zt.a)(n),e.dtype))}}}},Pt=n(180),Bt={kernelName:s.zc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){var t=Object(He.a)(n,Object(h.a)(0)),r=Object(h.a)(Pt.b),a=Object(h.a)(Pt.a),i=Object(u.a)(e,a),o=Object(u.a)(Object(u.a)(e,r),Object(Se.a)(Object(c.a)(n,"float32")));return Object(Z.a)(t,i,o)}}}},Wt={kernelName:s.Ac,outputsToSave:[!0],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(e,Object(u.a)(n,Object(v.a)(Object(h.a)(1),n)))}}}},Ut={kernelName:s.Bc,gradFunc:function(e){return{x:function(){return Object(S.a)(e)}}}},Vt=n(144),Ht={kernelName:s.Cc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(Object(Vt.a)(Object(c.a)(n,"float32")),e)}}}},Gt=n(198),qt={kernelName:s.Dc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(Object(Gt.a)(Object(c.a)(n,"float32")),e)}}}},Kt=n(77),Xt=n(142),Yt={kernelName:s.Ec,inputsToSave:["x"],gradFunc:function(e,t,n){for(var r=Object(o.a)(t,1)[0],a=n.begin,i=n.size,s=r.shape,c=Object(Xt.parseSliceParams)(r,a,i),u=Object(o.a)(c,2),l=u[0],d=u[1],f=[],p=0;p0&&(t=Object(k.a)(t,n)),Object(x.a)(t,r.shape)},b:function(){var t=e,n=O.c(a.shape,i);return n.length>0&&(t=Object(k.a)(t,n)),Object(x.a)(Object(p.a)(t),a.shape)}}}},un={kernelName:s.Xc,inputsToSave:["x"],gradFunc:function(e,t,n){var r=Object(o.a)(t,1)[0],a=r.shape.slice(),i=n.axis;Object(M.I)(i,r.shape).forEach((function(e){a[e]=1}));var s=Object(x.a)(e,a),c=Object(u.a)(s,Object(ot.a)(r.shape,"float32"));return{x:function(){return c}}}},ln={kernelName:s.Yc,inputsToSave:["x"],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(f.a)(e,Object(m.a)(Object(Vt.a)(n)))}}}},dn={kernelName:s.Zc,outputsToSave:[!0],gradFunc:function(e,t){var n=Object(o.a)(t,1)[0];return{x:function(){return Object(u.a)(Object(v.a)(Object(h.a)(1),Object(m.a)(n)),e)}}}},fn={kernelName:s.ad,inputsToSave:["x"],gradFunc:function(e,t,n){var r=Object(o.a)(t,1)[0],a=n.reps;return{x:function(){var t=Object(S.a)(r);if(1===r.rank)for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.throwIfDisposed(),Object(jr.a)(this,e,t,n)};var Sr=n(273);Object(Nn.d)().prototype.onesLike=function(){return this.throwIfDisposed(),Object(Sr.a)(this)},Object(Nn.d)().prototype.pad=function(e,t){return this.throwIfDisposed(),Object(Kt.a)(this,e,t)};var Nr=n(210);Object(Nn.d)().prototype.pool=function(e,t,n,r,a){return this.throwIfDisposed(),Object(Nr.a)(this,e,t,n,r,a)},Object(Nn.d)().prototype.pow=function(e){return this.throwIfDisposed(),Object(wt.a)(this,e)};var Ir=n(157);Object(Nn.d)().prototype.prelu=function(e){return this.throwIfDisposed(),Object(Ir.a)(this,e)};var Cr=n(211);Object(Nn.d)().prototype.prod=function(e,t){return this.throwIfDisposed(),Object(Cr.a)(this,e,t)};var Tr=n(274);Object(Nn.d)().prototype.reciprocal=function(){return this.throwIfDisposed(),Object(Tr.a)(this)};var Er=n(101);Object(Nn.d)().prototype.relu=function(){return this.throwIfDisposed(),Object(Er.a)(this)};var Ar=n(158);Object(Nn.d)().prototype.relu6=function(){return this.throwIfDisposed(),Object(Ar.a)(this)},Object(Nn.d)().prototype.reshapeAs=function(e){return this.throwIfDisposed(),Object(x.a)(this,e.shape)},Object(Nn.d)().prototype.reshape=function(e){return this.throwIfDisposed(),Object(x.a)(this,e)};var Rr=n(232);Object(Nn.d)().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),Object(Rr.a)(this,e,t,n)};var Fr=n(230);Object(Nn.d)().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),Object(Fr.a)(this,e,t,n)},Object(Nn.d)().prototype.reverse=function(e){return this.throwIfDisposed(),Object(Ft.a)(this,e)};var Dr=n(160);Object(Nn.d)().prototype.rfft=function(){return this.throwIfDisposed(),Object(Dr.a)(this)};var _r=n(213);Object(Nn.d)().prototype.round=function(){return this.throwIfDisposed(),Object(_r.a)(this)},Object(Nn.d)().prototype.rsqrt=function(){return this.throwIfDisposed(),Object(Re.a)(this)};var Mr=n(215);Object(Nn.d)().prototype.selu=function(){return this.throwIfDisposed(),Object(Mr.a)(this)};var zr=n(216);Object(Nn.d)().prototype.separableConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Object(zr.a)(this,e,t,n,r,a,i)},Object(Nn.d)().prototype.sigmoid=function(){return this.throwIfDisposed(),Object(Qt.a)(this)};var Lr=n(276);Object(Nn.d)().prototype.sign=function(){return this.throwIfDisposed(),Object(Lr.a)(this)},Object(Nn.d)().prototype.sin=function(){return this.throwIfDisposed(),Object(fe.a)(this)},Object(Nn.d)().prototype.sinh=function(){return this.throwIfDisposed(),Object(he.a)(this)},Object(Nn.d)().prototype.slice=function(e,t){return this.throwIfDisposed(),Object(lt.a)(this,e,t)};var Pr=n(277);Object(Nn.d)().prototype.softmax=function(e){return this.throwIfDisposed(),Object(Pr.a)(this,e)};var Br=n(205);Object(Nn.d)().prototype.softplus=function(){return this.throwIfDisposed(),Object(Br.a)(this)},Object(Nn.d)().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),Object(H.a)(this,e,t)},Object(Nn.d)().prototype.split=function(e,t){return this.throwIfDisposed(),Object(te.a)(this,e,t)},Object(Nn.d)().prototype.sqrt=function(){return this.throwIfDisposed(),Object(b.a)(this)},Object(Nn.d)().prototype.square=function(){return this.throwIfDisposed(),Object(m.a)(this)};var Wr=n(161);Object(Nn.d)().prototype.squaredDifference=function(e){return this.throwIfDisposed(),Object(Wr.a)(this,e)};var Ur=n(123);Object(Nn.d)().prototype.squeeze=function(e){return this.throwIfDisposed(),Object(Ur.a)(this,e)},Object(Nn.d)().prototype.stack=function(e,t){this.throwIfDisposed();var n=e instanceof Nn.a?[this,e]:[this].concat(Object(Vn.a)(e));return Object(hn.a)(n,t)},Object(Nn.d)().prototype.step=function(e){return this.throwIfDisposed(),Object(l.a)(this,e)};var Vr=n(278);Object(Nn.d)().prototype.stridedSlice=function(e,t,n,r,a,i,o,s){return this.throwIfDisposed(),Object(Vr.a)(this,e,t,n,r,a,i,o,s)},Object(Nn.d)().prototype.sub=function(e){return this.throwIfDisposed(),Object(v.a)(this,e)},Object(Nn.d)().prototype.sum=function(e,t){return this.throwIfDisposed(),Object(k.a)(this,e,t)};var Hr=n(279);Object(Nn.d)().prototype.tan=function(){return this.throwIfDisposed(),Object(Hr.a)(this)};var Gr=n(179);Object(Nn.d)().prototype.tanh=function(){return this.throwIfDisposed(),Object(Gr.a)(this)},Object(Nn.d)().prototype.tile=function(e){return this.throwIfDisposed(),Object(Fe.a)(this,e)},Object(Nn.d)().prototype.toBool=function(){return this.throwIfDisposed(),Object(c.a)(this,"bool")},Object(Nn.d)().prototype.toFloat=function(){return this.throwIfDisposed(),Object(c.a)(this,"float32")},Object(Nn.d)().prototype.toInt=function(){return this.throwIfDisposed(),Object(c.a)(this,"int32")};var qr=n(221);Object(Nn.d)().prototype.topk=function(e,t){return this.throwIfDisposed(),Object(qr.a)(this,e,t)},Object(Nn.d)().prototype.transpose=function(e){return this.throwIfDisposed(),Object(ge.a)(this,e)};var Kr=n(222);Object(Nn.d)().prototype.unique=function(e){return this.throwIfDisposed(),Object(Kr.a)(this,e)},Object(Nn.d)().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),Object(_e.a)(this,e,t)},Object(Nn.d)().prototype.unstack=function(e){return this.throwIfDisposed(),Object(yt.a)(this,e)},Object(Nn.d)().prototype.where=function(e,t){return this.throwIfDisposed(),Object(Z.a)(e,this,t)},Object(Nn.d)().prototype.zerosLike=function(){return this.throwIfDisposed(),Object(S.a)(this)};var Xr,Yr=n(7),$r=n(11),Qr=n(16),Zr=n(17);function Jr(){return null==Xr&&(Xr=Object(i.td)().epsilon()),Xr}var ea=n(20),ta=n(62),na=n(26),ra=n(164);var aa=n(228);function ia(e,t,n){return(ia=Object(aa.a)()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&Object(ra.a)(a,n.prototype),a}).apply(null,arguments)}function oa(e){var t="function"===typeof Map?new Map:void 0;return(oa=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("undefined"!==typeof t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return ia(e,arguments,Object(na.a)(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Object(ra.a)(r,e)})(e)}var sa=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),r=t.call(this,e),Object.setPrototypeOf(Object(ta.a)(r),n.prototype),r}return n}(oa(Error)),ca=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),r=t.call(this,e),Object.setPrototypeOf(Object(ta.a)(r),n.prototype),r}return n}(oa(Error)),ua=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),r=t.call(this,e),Object.setPrototypeOf(Object(ta.a)(r),n.prototype),r}return n}(oa(Error)),la=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),r=t.call(this,e),Object.setPrototypeOf(Object(ta.a)(r),n.prototype),r}return n}(oa(Error)),da=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),r=t.call(this,e),Object.setPrototypeOf(Object(ta.a)(r),n.prototype),r}return n}(oa(Error));Error;function fa(e,t){if(Array.isArray(e)){for(var n=[],r=0;r1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"object",a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if("string"===typeof e){var i,s=e;if(s in n)i=n[s];else if(s in ya)i=ya[s];else if(null==(i=t[s]))throw new ua("Unknown ".concat(r,": ").concat(e,". ")+"This may be due to one of the following reasons:\n"+"1. The ".concat(r," is defined in Python, in which ")+"case it needs to be ported to TensorFlow.js or your JavaScript code.\n"+"2. The custom ".concat(r," is defined in JavaScript, ")+"but is not registered properly with tf.serialization.registerClass().");return i}var c=e;if(null==c.className||null==c.config)throw new ua("".concat(r,": Improper config format: ")+"".concat(JSON.stringify(c),".\n")+"'className' and 'config' must set.");var u,l,d=c.className;if(d in n){var f=Object(o.a)(n[d],2);u=f[0],l=f[1]}else if(d in ya){var p=Object(o.a)(ya.className,2);u=p[0],l=p[1]}else if(d in t){var h=Object(o.a)(t[d],2);u=h[0],l=h[1]}if(null==u)throw new ua("Unknown ".concat(r,": ").concat(d,". ")+"This may be due to one of the following reasons:\n"+"1. The ".concat(r," is defined in Python, in which ")+"case it needs to be ported to TensorFlow.js or your JavaScript code.\n"+"2. The custom ".concat(r," is defined in JavaScript, ")+"but is not registered properly with tf.serialization.registerClass().");if(null!=l){for(var b={},m=0,v=Object.keys(ya);mt?1:0}(e,t)}function ja(e){if(null==e)return e;var t,n=[],r=Object(ea.a)(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;-1===n.indexOf(a)&&n.push(a)}}catch(i){r.e(i)}finally{r.f()}return n}function Sa(e){if(null==e)throw new ua("Invalid value in obj: ".concat(JSON.stringify(e)));for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function Na(e,t,n){if(null!=n&&e.indexOf(n)<0)throw new ua("".concat(n," is not a valid ").concat(t,". Valid values are ").concat(e," or null/undefined."))}function Ia(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return pa(n>=0),pa(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every((function(e){return typeof e===t}))}function Ca(e,t){Array.isArray(e)?(i.wf.assert(e.length>0,(function(){return"".concat(t," is unexpectedly an empty array.")})),e.forEach((function(e,n){return Ca(e,"element ".concat(n+1," of ").concat(t))}))):i.wf.assert(Number.isInteger(e)&&e>0,(function(){return"Expected ".concat(t," to be a positive integer, but got ")+"".concat(Ta(e),".")}))}function Ta(e){return null===e?"null":Array.isArray(e)?"["+e.map((function(e){return Ta(e)})).join(",")+"]":"string"===typeof e?'"'.concat(e,'"'):"".concat(e)}function Ea(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}function Aa(e,t){return Object(i.pf)((function(){return i.ef(i.if(i.ye(e,e),t,!0))}))}var Ra=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"getConfig",value:function(){return{}}}]),n}(i.Se.Serializable),Fa=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this)).defaultMaxValue=2,r.defaultAxis=0,r.maxValue=null!=e.maxValue?e.maxValue:r.defaultMaxValue,r.axis=null!=e.axis?e.axis:r.defaultAxis,r}return Object($r.a)(n,[{key:"apply",value:function(e){var t=this;return Object(i.pf)((function(){var n=Aa(e,t.axis),r=i.Bd(n,0,t.maxValue);return i.ye(e,i.Qd(r,i.nd(Jr(),n)))}))}},{key:"getConfig",value:function(){return{maxValue:this.maxValue,axis:this.axis}}}]),n}(Ra);Fa.className="MaxNorm",i.Se.registerClass(Fa);var Da=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this)).defaultAxis=0,r.axis=null!=e.axis?e.axis:r.defaultAxis,r}return Object($r.a)(n,[{key:"apply",value:function(e){var t=this;return Object(i.pf)((function(){return i.Qd(e,i.nd(Jr(),Aa(e,t.axis)))}))}},{key:"getConfig",value:function(){return{axis:this.axis}}}]),n}(Ra);Da.className="UnitNorm",i.Se.registerClass(Da);var _a=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return i.Me(e)}}]),n}(Ra);_a.className="NonNeg",i.Se.registerClass(_a);var Ma=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this)).defaultMinValue=0,r.defaultMaxValue=1,r.defaultRate=1,r.defaultAxis=0,r.minValue=null!=e.minValue?e.minValue:r.defaultMinValue,r.maxValue=null!=e.maxValue?e.maxValue:r.defaultMaxValue,r.rate=null!=e.rate?e.rate:r.defaultRate,r.axis=null!=e.axis?e.axis:r.defaultAxis,r}return Object($r.a)(n,[{key:"apply",value:function(e){var t=this;return Object(i.pf)((function(){var n=Aa(e,t.axis),r=i.nd(i.ye(t.rate,i.Bd(n,t.minValue,t.maxValue)),i.ye(1-t.rate,n));return i.ye(e,i.Qd(r,i.nd(Jr(),n)))}))}},{key:"getConfig",value:function(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}]),n}(Ra);Ma.className="MinMaxNorm",i.Se.registerClass(Ma);var za={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function La(e){return Oa(e)}function Pa(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ka(e,i.Se.SerializationMap.getMap().classNameMap,t,"constraint")}function Ba(e){return null==e?null:"string"===typeof e?Pa({className:e in za?za[e]:e,config:{}}):e instanceof Ra?e:Pa(e)}var Wa=["channelsFirst","channelsLast"],Ua=["nearest","bilinear"],Va=["valid","same","causal"],Ha=["max","avg"],Ga=["sum","mul","concat","ave"],qa=new Map;function Ka(e){Na(Wa,"DataFormat",e)}function Xa(e){Na(Va,"PaddingMode",e)}function Ya(e){Na(Ha,"PoolMode",e)}var $a=[];function Qa(e,t){$a.push(e);try{var n=t();return $a.pop(),n}catch(r){throw $a.pop(),r}}function Za(e){if(!ti(e))throw new Error("Not a valid tensor name: '"+e+"'");return(0===$a.length?"":$a.join("/")+"/")+e}function Ja(e){if(!ti(e))throw new Error("Not a valid tensor name: '"+e+"'");qa.has(e)||qa.set(e,0);var t=qa.get(e);if(qa.set(e,qa.get(e)+1),t>0){var n="".concat(e,"_").concat(t);return qa.set(n,1),n}return e}var ei=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function ti(e){return!!e.match(ei)}function ni(e,t,n){null==t&&(t=0),null==n&&(n=e.length);for(var r=1,a=t;at&&(t=r)}return t}function ii(e,t){if(t1&&void 0!==arguments[1]?arguments[1]:-1,n=e.shape.slice();return t<0&&(t=n.length+t+1),n.splice(t,0,1),i.Ne(e,n)}function ci(e){var t=[ni(e.shape)];return i.Ne(e,t)}function ui(e,t,n){return Object(i.pf)((function(){switch(e.rank){case 1:return i.We(e,t,n);case 2:return i.Xe(e,[t,0],[n,e.shape[1]]);case 3:return i.Ye(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return i.Ze(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return i.Ve(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return i.Ve(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 ua("sliceAlongFirstAxis() received an unsupported tensor rank: "+"".concat(e.rank))}}))}function li(e,t,n){return Object(i.pf)((function(){switch(e.rank){case 1:return i.We(e,t,n);case 2:return i.Xe(e,[0,t],[e.shape[0],n]);case 3:return i.Ye(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return i.Ze(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new ua("sliceAlongLastAxis() received an unsupported tensor rank: "+"".concat(e.rank))}}))}function di(e,t,n,r){return Object(i.pf)((function(){switch(e.rank){case 1:return i.We(e,t,n);case 2:switch(r){case 1:return ui(e,t,n);case 2:return li(e,t,n);default:throw new ua("The axis is not within the rank of the tensor "+"".concat(r))}case 3:switch(r){case 1:return ui(e,t,n);case 2:return i.Ye(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return li(e,t,n);default:throw new ua("The axis is not within the rank of the tensor "+"".concat(r))}case 4:switch(r){case 1:return ui(e,t,n);case 2:return i.Ze(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return i.Ze(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return li(e,t,n);default:throw new ua("The axis is not within the rank of the tensor "+"".concat(r))}default:throw new ua("sliceAlongLastAxis() received an unsupported tensor rank: "+"".concat(e.rank))}}))}function fi(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return n<0&&(n=0!==(t=e[0].rank)?t:0),n===e[0].rank&&(n=-1),i.Dd(e,n)}function pi(e,t){switch(e.rank){case 1:return i.Ed([e,t]);case 2:return i.Fd([e,t],0);case 3:return i.Gd([e,t],0);case 4:return i.Hd([e,t],0);default:throw new ua("concatAlongFirstAxis() received an unsupported "+"tensor rank: ".concat(e.rank))}}function hi(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new ua("The length of input n (".concat(t.length,") does not match ")+"the number of dimensions in input x (".concat(e.rank,")"));return i.qf(e,t)}function bi(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;return i.Ie(e,t,n,r,a)}function mi(e,t,n,r){if(e.rank<2||t.rank<2)throw new la("dot requires both inputs to be rank >= 2"+" but got x shape = ".concat(e.shape," and y shape = ").concat(t.shape));if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new la("If rank y >= 3, then the second last dim"+" of y must equal the last dim of x but got x shape = ".concat(e.shape," and ")+" y shape = ".concat(t.shape));if(2===e.rank&&2===t.rank){return i.be.matMul({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?yi(e.rank,r,"channelsLast"):null,activation:n})}var a=e.shape.slice(),o=a.pop();e=i.Ne(e,[-1,o]);var s=t.shape.slice(),c=s.pop(),u=s.pop(),l=[].concat(Object(Vn.a)(s),[c]),d=Array.from({length:t.rank},(function(e,n){return 0===n?t.rank-2:n<=t.rank-2?n-1:n}));t=i.Ne(i.sf(t,d),[u,-1]);var f=[].concat(Object(Vn.a)(a),Object(Vn.a)(l));return i.Ne(i.be.matMul({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?yi(e.rank,r,"channelsLast"):null,activation:n}),f)}function vi(e,t,n){return Object(i.pf)((function(){return t=Array.isArray(t)?Object(i.mf)(t,"int32"):i.Ad(t,"int32"),i.ce(e,t,n)}))}function gi(e){return i.ye(e,e)}function yi(e,t,n){var r=t.shape;if(1!==t.rank&&t.rank!==e)throw new ua("Unexpected bias dimensions: ".concat(t.rank)+"; expected it to be 1 or ".concat(e));if(5===e){if("channelsFirst"===n)return 1===r.length?i.Ne(t,[1,r[0],1,1,1]):i.Ne(t,[1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?i.Ne(t,[1,1,1,1,r[0]]):i.Ne(t,[1].concat(r))}else if(4===e){if("channelsFirst"===n)return 1===r.length?i.Ne(t,[1,r[0],1,1]):i.Ne(t,[1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?i.Ne(t,[1,1,1,r[0]]):i.Ne(t,[1].concat(r))}else if(3===e){if("channelsFirst"===n)return 1===r.length?i.Ne(t,[1,r[0],1]):i.Ne(t,[1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?i.Ne(t,[1,1,r[0]]):i.Ne(t,[1].concat(r))}else if(e<3)return t;throw new ua("Unsupported input rank by biasAdd: ".concat(t.rank))}function Oi(e,t,n){return Object(i.pf)((function(){return null==n&&(n="channelsLast"),Ka(n),i.nd(e,yi(e.rank,t,n))}))}function xi(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(1!==t)throw new la("Support for alpha values other than 1 (".concat(t,") is not implemented ")+"yet.");return i.Sd(e)}function ki(e,t,n,r){return Object(i.pf)((function(){return i.Rd(e,t,n,r)}))}function wi(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return n?e():t()}var ji=["fanIn","fanOut","fanAvg"],Si=["normal","uniform","truncatedNormal"];var Ni=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"fromConfigUsesCustomObjects",value:function(){return!1}},{key:"getConfig",value:function(){return{}}}]),n}(i.Se.Serializable),Ii=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e,t){return Object(i.Bf)(e,t)}}]),n}(Ni);Ii.className="Zeros",i.Se.registerClass(Ii);var Ci=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e,t){return Object(i.De)(e,t)}}]),n}(Ni);Ci.className="Ones",i.Se.registerClass(Ci);var Ti=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),r=t.call(this),"object"!==typeof e)throw new ua("Expected argument of type ConstantConfig but got ".concat(e));if(void 0===e.value)throw new ua("config must have value set but got ".concat(e));return r.value=e.value,r}return Object($r.a)(n,[{key:"apply",value:function(e,t){var n=this;return Object(i.pf)((function(){return Object(i.ye)(Object(i.Pe)(n.value),Object(i.De)(e,t))}))}},{key:"getConfig",value:function(){return{value:this.value}}}]),n}(Ni);Ti.className="Constant",i.Se.registerClass(Ti);var Ei=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this)).DEFAULT_MINVAL=-.05,r.DEFAULT_MAXVAL=.05,r.minval=e.minval||r.DEFAULT_MINVAL,r.maxval=e.maxval||r.DEFAULT_MAXVAL,r.seed=e.seed,r}return Object($r.a)(n,[{key:"apply",value:function(e,t){return Object(i.Je)(e,this.minval,this.maxval,t)}},{key:"getConfig",value:function(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}]),n}(Ni);Ei.className="RandomUniform",i.Se.registerClass(Ei);var Ai=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this)).DEFAULT_MEAN=0,r.DEFAULT_STDDEV=.05,r.mean=e.mean||r.DEFAULT_MEAN,r.stddev=e.stddev||r.DEFAULT_STDDEV,r.seed=e.seed,r}return Object($r.a)(n,[{key:"apply",value:function(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new la("randomNormal does not support dType ".concat(t,"."));return bi(e,this.mean,this.stddev,t,this.seed)}},{key:"getConfig",value:function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}]),n}(Ni);Ai.className="RandomNormal",i.Se.registerClass(Ai);var Ri=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this)).DEFAULT_MEAN=0,r.DEFAULT_STDDEV=.05,r.mean=e.mean||r.DEFAULT_MEAN,r.stddev=e.stddev||r.DEFAULT_STDDEV,r.seed=e.seed,r}return Object($r.a)(n,[{key:"apply",value:function(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new la("truncatedNormal does not support dType ".concat(t,"."));return Object(i.tf)(e,this.mean,this.stddev,t,this.seed)}},{key:"getConfig",value:function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}]),n}(Ni);Ri.className="TruncatedNormal",i.Se.registerClass(Ri);var Fi=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this)).gain=null!=e.gain?e.gain:1,r}return Object($r.a)(n,[{key:"apply",value:function(e,t){var n=this;return Object(i.pf)((function(){if(2!==e.length||e[0]!==e[1])throw new ua("Identity matrix initializer can only be used for 2D square matrices.");return Object(i.ye)(n.gain,Object(i.Yd)(e[0]))}))}},{key:"getConfig",value:function(){return{gain:this.gain}}}]),n}(Ni);Fi.className="Identity",i.Se.registerClass(Fi);var Di=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r,a;if(Object(Yr.a)(this,n),r=t.call(this),e.scale<0)throw new ua("scale must be a positive float. Got: ".concat(e.scale));return r.scale=null==e.scale?1:e.scale,r.mode=null==e.mode?"fanIn":e.mode,a=r.mode,Na(ji,"FanMode",a),r.distribution=null==e.distribution?"normal":e.distribution,function(e){Na(Si,"Distribution",e)}(r.distribution),r.seed=e.seed,r}return Object($r.a)(n,[{key:"apply",value:function(e,t){var n=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"channelsLast";if(Ka(r),2===e.length)t=e[0],n=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===r){var a=ni(e,2);t=e[1]*a,n=e[0]*a}else if("channelsLast"===r){var i=ni(e,0,e.length-2);t=e[e.length-2]*i,n=e[e.length-1]*i}}else{var o=ni(e);t=Math.sqrt(o),n=Math.sqrt(o)}return[t,n]}(e),r=n[0],a=n[1],o=this.scale;if("fanIn"===this.mode?o/=Math.max(1,r):"fanOut"===this.mode?o/=Math.max(1,a):o/=Math.max(1,(r+a)/2),"normal"===this.distribution){var s=Math.sqrt(o);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new la("".concat(this.getClassName()," does not support dType ").concat(t,"."));return Object(i.tf)(e,0,s,t,this.seed)}var c=Math.sqrt(3*o);return Object(i.Je)(e,-c,c,t)}},{key:"getConfig",value:function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}]),n}(Ni);Di.className="VarianceScaling",i.Se.registerClass(Di);var _i=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}return Object($r.a)(n,[{key:"getClassName",value:function(){return Di.className}}]),n}(Di);_i.className="GlorotUniform",i.Se.registerClass(_i);var Mi=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}return Object($r.a)(n,[{key:"getClassName",value:function(){return Di.className}}]),n}(Di);Mi.className="GlorotNormal",i.Se.registerClass(Mi);var zi=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}return Object($r.a)(n,[{key:"getClassName",value:function(){return Di.className}}]),n}(Di);zi.className="HeNormal",i.Se.registerClass(zi);var Li=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,{scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}return Object($r.a)(n,[{key:"getClassName",value:function(){return Di.className}}]),n}(Di);Li.className="HeUniform",i.Se.registerClass(Li);var Pi=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}return Object($r.a)(n,[{key:"getClassName",value:function(){return Di.className}}]),n}(Di);Pi.className="LeCunNormal",i.Se.registerClass(Pi);var Bi=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,{scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}return Object($r.a)(n,[{key:"getClassName",value:function(){return Di.className}}]),n}(Di);Bi.className="LeCunNormal",i.Se.registerClass(Bi);var Wi=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),(r=t.call(this)).DEFAULT_GAIN=1,r.gain=null==e.gain?r.DEFAULT_GAIN:e.gain,r.seed=e.seed,null!=r.seed)throw new la("Random seed is not implemented for Orthogonal Initializer yet.");return r}return Object($r.a)(n,[{key:"apply",value:function(e,t){var n=this;return Object(i.pf)((function(){if(e.length<2)throw new la("Shape must be at least 2D.");e[0]*e[1]>2e3&&console.warn("Orthogonal initializer is being called on a matrix with more "+"than 2000 (".concat(e[0]*e[1],") elements: ")+"Slowness may result.");var t=bi(e[0]>e[1]?[e[1],e[0]]:e,0,1,"float32"),r=i.ke.gramSchmidt(t);return e[0]>e[1]&&(r=Object(i.sf)(r)),Object(i.ye)(n.gain,r)}))}},{key:"getConfig",value:function(){return{gain:this.gain,seed:this.seed}}}]),n}(Ni);Wi.className="Orthogonal",i.Se.registerClass(Wi);var Ui={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 Vi(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ka(e,i.Se.SerializationMap.getMap().classNameMap,t,"initializer")}function Hi(e){return Oa(e)}function Gi(e){if("string"===typeof e){var t=e in Ui?Ui[e]:e;if("GlorotNormal"===t)return new Mi;if("GlorotUniform"===t)return new _i;if("HeNormal"===t)return new zi;if("HeUniform"===t)return new Li;if("LeCunNormal"===t)return new Pi;if("LeCunUniform"===t)return new Bi;var n={};return n.className=t,n.config={},Vi(n)}return e instanceof Ni?e:Vi(e)}var qi=0;function Ki(){return qi++}var Xi={};function Yi(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e in Xi||(Xi[e]=0),Xi[e]+=1,e+Xi[e].toString()}function $i(e){return Array.isArray(e)&&Array.isArray(e[0])}function Qi(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function Zi(e){var t;if(Array.isArray(e)){if(1!==e.length)throw new ua("Expected Tensor length to be 1; got ".concat(e.length));t=e[0]}else t=e;return t}function Ji(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(1===e.length)return(e=e)[0];throw new ua("Expected exactly 1 Shape; got ".concat(e.length))}return e}function eo(e){var t,n=0,r=Object(ea.a)(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;0===a.shape.length?n+=1:n+=a.shape.reduce((function(e,t){return e*t}))}}catch(i){r.e(i)}finally{r.f()}return n}var to="Variable",no=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"float32",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:to,a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;Object(Yr.a)(this,e),this.dtype=null==n?"float32":n,this.shape=t.shape,this.id=Ki(),r=null==r?to:r,this.originalName=Za(r),this.name=Ja(this.originalName),this.trainable_=a,this.constraint=o,this.val=i.xf(t,this.trainable_,this.name,this.dtype)}return Object($r.a)(e,[{key:"read",value:function(){return this.assertNotDisposed(),this.val}},{key:"write",value: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}},{key:"dispose",value:function(){this.assertNotDisposed(),this.val.dispose()}},{key:"assertNotDisposed",value:function(){if(this.val.isDisposed)throw new Error("LayersVariable ".concat(this.name," is already disposed."))}},{key:"trainable",get:function(){return this.trainable_},set:function(e){this.trainable_=e,this.val.trainable=e}}]),e}();function ro(e){return e.map((function(e){return e.read()}))}function ao(e){e.forEach((function(e){e[0].write(e[1])}))}var io=function e(t){Object(Yr.a)(this,e),this.dtype=t.dtype,this.shape=t.shape,null!=t.shape?this.ndim=t.shape.length:this.ndim=t.ndim,this.maxNDim=t.maxNDim,this.minNDim=t.minNDim,this.axes=t.axes||{}},oo=function e(t,n,r,a,i,o,s){Object(Yr.a)(this,e),this.dtype=t,this.shape=n,this.sourceLayer=r,this.inputs=a,this.callArgs=i,this.outputTensorIndex=s,this.id=Ki(),null!=o&&(this.originalName=Za(o),this.name=Ja(this.originalName)),this.rank=n.length},so=0,co=function(){function e(t,n){Object(Yr.a)(this,e),this.callArgs=n,this.id=so++,this.outboundLayer=t.outboundLayer,this.inboundLayers=t.inboundLayers,this.nodeIndices=t.nodeIndices,this.tensorIndices=t.tensorIndices,this.inputTensors=t.inputTensors,this.outputTensors=t.outputTensors,this.inputMasks=t.inputMasks,this.outputMasks=t.outputMasks,this.inputShapes=t.inputShapes,this.outputShapes=t.outputShapes;var r,a=Object(ea.a)(t.inboundLayers);try{for(a.s();!(r=a.n()).done;){var i=r.value;null!=i&&i.outboundNodes.push(this)}}catch(o){a.e(o)}finally{a.f()}t.outboundLayer.inboundNodes.push(this)}return Object($r.a)(e,[{key:"getConfig",value:function(){var e,t=[],n=Object(ea.a)(this.inboundLayers);try{for(n.s();!(e=n.n()).done;){var r=e.value;null!=r?t.push(r.name):t.push(null)}}catch(a){n.e(a)}finally{n.f()}return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:t,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}]),e}(),uo=0,lo=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(Yr.a)(this,n),(e=t.call(this))._callHook=null,e._addedWeightNames=[],e._stateful=!1,e.id=uo++,e.activityRegularizer=null,e.inputSpec=null,e.supportsMasking=!1,e._trainableWeights=[],e._nonTrainableWeights=[],e._losses=[],e._updates=[],e._built=!1,e.inboundNodes=[],e.outboundNodes=[];var a=r.name;if(!a){var i=e.getClassName();a=va(i)+"_"+Yi(i)}if(e.name=a,e.trainable_=null==r.trainable||r.trainable,null!=r.inputShape||null!=r.batchInputShape){var o;if(null!=r.batchInputShape)o=r.batchInputShape;else if(null!=r.inputShape){var s=null;null!=r.batchSize&&(s=r.batchSize),o=[s].concat(r.inputShape)}e.batchInputShape=o;var c=r.dtype;null==c&&(c=r.inputDType),null==c&&(c="float32"),e.dtype=c}return null!=r.weights?e.initialWeights=r.weights:e.initialWeights=null,e._refCount=null,e.fastWeightInitDuringBuild=!1,e}return Object($r.a)(n,[{key:"getNodeAtIndex",value:function(e,t){if(0===this.inboundNodes.length)throw new ca("The layer has never been called "+"and thus has no defined ".concat(t,"."));if(this.inboundNodes.length<=e)throw new ua("Asked to get ".concat(t," at node ").concat(e,", ")+"but the layer has only ".concat(this.inboundNodes.length," inbound nodes."));return this.inboundNodes[e]}},{key:"getInputAt",value:function(e){return ba(this.getNodeAtIndex(e,"input").inputTensors)}},{key:"getOutputAt",value:function(e){return ba(this.getNodeAtIndex(e,"output").outputTensors)}},{key:"input",get:function(){if(this.inboundNodes.length>1)throw new sa("Layer ".concat(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 sa("Layer ".concat(this.name)+" is not connected, no input to return.");return ba(this.getNodeAtIndex(0,"input").inputTensors)}},{key:"output",get:function(){if(0===this.inboundNodes.length)throw new sa("Layer ".concat(this.name)+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new sa("Layer ".concat(this.name)+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return ba(this.getNodeAtIndex(0,"output").outputTensors)}},{key:"losses",get:function(){return this._losses}},{key:"calculateLosses",value:function(){return this.losses.map((function(e){return e()}))}},{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:"resetStates",value:function(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}},{key:"assertInputCompatibility",value:function(e){if(e=ma(e),null!=this.inputSpec&&0!==this.inputSpec.length){var t=ma(this.inputSpec);if(e.length!==t.length)throw new ua("Layer ".concat(this.name," expects ").concat(t.length," inputs, ")+"but it received ".concat(e.length," input tensors. ")+"Input received: ".concat(e));for(var n=0;n=0?o[c]:o[o.length+c];if(null!=u&&-1===[u,null].indexOf(l))throw new ua("Input ".concat(n," is incompatible with layer ")+"".concat(this.name,": expected axis ").concat(c," of input shape to ")+"have value ".concat(u," but got shape ").concat(o,"."))}}if(null!=a.shape)for(var d=0;d0&&Array.isArray(g[0])?g.map((function(r,a){return new oo(y,r,n,ma(e),t,n.name,a)})):new oo(y,g,n,ma(e),t,n.name),n.addInboundNode(e,m,null,null,v,g,t),n._refCount++,null!=n.activityRegularizer)throw new la("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return m}))}},{key:"warnOnIncompatibleInputShape",value:function(e){if(null!=this.batchInputShape)if(e.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+"".concat(JSON.stringify(e),") does not match that of the ")+"batchInputShape (".concat(JSON.stringify(this.batchInputShape),") ")+"of the layer ".concat(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 "+"(".concat(JSON.stringify(e),") does not ")+"match the expectation of layer ".concat(this.name,": ")+"".concat(JSON.stringify(this.batchInputShape)))}}},{key:"outputShape",get:function(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new sa("The layer ".concat(this.name," has never been called and thus has no ")+"defined output shape.");var e,t=[],n=Object(ea.a)(this.inboundNodes);try{for(n.s();!(e=n.n()).done;){var r=e.value,a=JSON.stringify(r.outputShapes);-1===t.indexOf(a)&&t.push(a)}}catch(o){n.e(o)}finally{n.f()}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 sa("The layer ".concat(this.name," has multiple inbound nodes with different ")+'output shapes. Hence the notion of "output shape" is ill-defined for the layer.')}},{key:"countParams",value:function(){if(!this.built)throw new ca("You tried to call countParams() on ".concat(this.name,", ")+"but the layer is not built yet. Build it first by calling build(batchInputShape).");return eo(this.weights)}},{key:"build",value:function(e){this.built=!0}},{key:"getWeights",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return ro(e?this.trainableWeights:this.weights)}},{key:"setWeights",value:function(e){var t=this;Object(i.pf)((function(){var n=t.weights;if(n.length!==e.length)throw new ua('You called setWeights(weights) on layer "'.concat(t.name,'" ')+"with a weight list of length ".concat(e.length,", ")+"but the layer was expecting ".concat(n.length," weights. ")+"Provided weights: ".concat(e,"..."));if(0!==n.length){for(var r=[],a=ro(n),o=0;o6&&void 0!==arguments[6]?arguments[6]:null,s=ma(e);t=ma(t),n=ma(n),r=ma(r),a=Qi(a),i=Qi(i);var c,u=[],l=[],d=[],f=Object(ea.a)(s);try{for(f.s();!(c=f.n()).done;){var p=c.value;u.push(p.sourceLayer),l.push(p.nodeIndex),d.push(p.tensorIndex)}}catch(b){f.e(b)}finally{f.f()}new co({outboundLayer:this,inboundLayers:u,nodeIndices:l,tensorIndices:d,inputTensors:s,outputTensors:t,inputMasks:n,outputMasks:r,inputShapes:a,outputShapes:i},o);for(var h=0;h0)&&(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;i0)){e.next=12;break}return e.next=9,Promise.all(n);case 9:for(u=e.sent,l=0;l1&&void 0!==arguments[1]?arguments[1]:10;Object(Yr.a)(this,e),null==t&&(t=[]),this.callbacks=t,this.queueLength=n}return Object($r.a)(e,[{key:"append",value:function(e){this.callbacks.push(e)}},{key:"setParams",value:function(e){var t,n=Object(ea.a)(this.callbacks);try{for(n.s();!(t=n.n()).done;){t.value.setParams(e)}}catch(r){n.e(r)}finally{n.f()}}},{key:"setModel",value:function(e){var t,n=Object(ea.a)(this.callbacks);try{for(n.s();!(t=n.n()).done;){t.value.setModel(e)}}catch(r){n.e(r)}finally{n.f()}}},{key:"onEpochBegin",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r,a,i;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=Object(ea.a)(this.callbacks),e.prev=2,r.s();case 4:if((a=r.n()).done){e.next=10;break}return i=a.value,e.next=8,i.onEpochBegin(t,n);case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),r.e(e.t0);case 15:return e.prev=15,r.f(),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[2,12,15,18]])})));return function(t,n){return e.apply(this,arguments)}}()},{key:"onEpochEnd",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r,a,i;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=Object(ea.a)(this.callbacks),e.prev=2,r.s();case 4:if((a=r.n()).done){e.next=10;break}return i=a.value,e.next=8,i.onEpochEnd(t,n);case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),r.e(e.t0);case 15:return e.prev=15,r.f(),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[2,12,15,18]])})));return function(t,n){return e.apply(this,arguments)}}()},{key:"onBatchBegin",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r,a,i;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=Object(ea.a)(this.callbacks),e.prev=2,r.s();case 4:if((a=r.n()).done){e.next=10;break}return i=a.value,e.next=8,i.onBatchBegin(t,n);case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),r.e(e.t0);case 15:return e.prev=15,r.f(),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[2,12,15,18]])})));return function(t,n){return e.apply(this,arguments)}}()},{key:"onBatchEnd",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r,a,i;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=Object(ea.a)(this.callbacks),e.prev=2,r.s();case 4:if((a=r.n()).done){e.next=10;break}return i=a.value,e.next=8,i.onBatchEnd(t,n);case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),r.e(e.t0);case 15:return e.prev=15,r.f(),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[2,12,15,18]])})));return function(t,n){return e.apply(this,arguments)}}()},{key:"onTrainBegin",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){var n,r,a;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==t&&(t={}),n=Object(ea.a)(this.callbacks),e.prev=2,n.s();case 4:if((r=n.n()).done){e.next=10;break}return a=r.value,e.next=8,a.onTrainBegin(t);case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),n.e(e.t0);case 15:return e.prev=15,n.f(),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[2,12,15,18]])})));return function(t){return e.apply(this,arguments)}}()},{key:"onTrainEnd",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){var n,r,a;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==t&&(t={}),n=Object(ea.a)(this.callbacks),e.prev=2,n.s();case 4:if((r=n.n()).done){e.next=10;break}return a=r.value,e.next=8,a.onTrainEnd(t);case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),n.e(e.t0);case 15:return e.prev=15,n.f(),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[2,12,15,18]])})));return function(t){return e.apply(this,arguments)}}()}]),e}(),jo=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.call(this)}return Object($r.a)(n,[{key:"onEpochBegin",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){return vo.a.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)}}()},{key:"onBatchEnd",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r,a,o,s=this;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(o 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)s.totals.hasOwnProperty(e)||(s.totals[e]=0),s.totals[e]=s.totals[e]+t*r;else{var a;e in s.totals?a=s.totals[e]:s.totals[e]=0;var o=Object(i.pf)((function(){return Object(i.nd)(s.totals[e],Object(i.ye)(t,r))}));s.totals[e]=o,null!=a&&a.dispose()}},n)a(o);case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"onEpochEnd",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r,a,o,s=this;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n){e.next=19;break}r=Object(ea.a)(this.params.metrics),e.prev=2,o=function(){var e=a.value;if(null==s.totals[e])return"continue";"number"===typeof s.totals[e]?n[e]=s.totals[e]/s.seen:Object(i.pf)((function(){var t=Object(i.ye)(Object(i.Qd)(1,s.seen),s.totals[e]);n[e]=t,s.totals[e].dispose(),Object(i.he)(n[e])}))},r.s();case 5:if((a=r.n()).done){e.next=11;break}if("continue"!==o()){e.next=9;break}return e.abrupt("continue",9);case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(2),r.e(e.t0);case 16:return e.prev=16,r.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[2,13,16,19]])})));return function(t,n){return e.apply(this,arguments)}}()}]),n}(ko),So=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"onTrainBegin",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){return vo.a.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)}}()},{key:"onEpochEnd",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r;return vo.a.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)}}()},{key:"syncData",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t,n,r,a,i,o,s,c,u;return vo.a.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=0&&Number.isInteger(t),(function(){return"Verbosity level is expected to be an integer >= 0, "+"but got ".concat(t)})),e.checkForDuplicate(n),null==e.constructors[t]&&(e.constructors[t]=[]),e.constructors[t].push(n)}},{key:"checkForDuplicate",value:function(t){for(var n in e.constructors){e.constructors[+n].forEach((function(e){if(e===t)throw new ua("Duplicate callback constructor.")}))}}},{key:"clear",value:function(){e.constructors={}}},{key:"createCallbacks",value:function(t){var n=[];for(var r in e.constructors){var a=+r;t>=a&&n.push.apply(n,Object(Vn.a)(e.constructors[a]))}return n.map((function(e){return new e}))}}]),e}();function To(e,t,n,r,a,i,o,s,c){var u=new So,l=[new jo].concat(Object(Vn.a)(Co.createCallbacks(t)));null!=e&&l.push.apply(l,Object(Vn.a)(e)),l.push(u);var d=new wo(l);return d.setParams({epochs:n,initialEpoch:r,samples:a,steps:i,batchSize:o,verbose:t,doValidation:s,metrics:c}),{callbackList:d,history:u}}Co.constructors={};var Eo=n(28);function Ao(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return ka(e,i.Se.SerializationMap.getMap().classNameMap,t,"layer",n)}function Ro(e,t){return Object(i.pf)((function(){"float32"!==e.dtype&&(e=i.Ad(e,"float32"));var n=i.if(gi(e),t,!0),r=i.Zd(n.shape,Jr()),a=i.ef(i.te(n,r));return i.Qd(e,a)}))}function Fo(e,t){return Object(i.pf)((function(){return i.ue(gi(i.hf(t,e)),-1)}))}function Do(e,t){return Object(i.pf)((function(){return i.ue(i.md(i.hf(t,e)),-1)}))}function _o(e,t){return Object(i.pf)((function(){var n=i.hf(e,t),r=i.Bd(i.md(e),Jr(),Number.MAX_VALUE),a=i.md(i.Qd(n,r));return i.ye(100,i.ue(a,-1))}))}function Mo(e,t){return Object(i.pf)((function(){var n=i.Bd(t,Jr(),Number.MAX_VALUE),r=i.le(i.nd(1,n)),a=i.Bd(e,Jr(),Number.MAX_VALUE),o=i.le(i.nd(1,a));return i.ue(gi(i.hf(r,o)),-1)}))}function zo(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Object(i.pf)((function(){if(n)t=i.bf(t);else{var r=i.if(t,t.shape.length-1,!0);t=i.Qd(t,r)}return t=i.Bd(t,Jr(),1-Jr()),i.ze(i.if(i.ye(i.Ad(e,"float32"),i.le(t)),t.shape.length-1))}))}function Lo(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Object(i.pf)((function(){var r=i.Ad(i.ae(ci(e)),"int32"),a=(t=i.Bd(t,Jr(),1-Jr())).shape;return zo(i.Ne(i.Ce(r,a[a.length-1]),a),t,n)}))}function Po(e,t){return Object(i.pf)((function(){var n;return n=i.Bd(t,Jr(),1-Jr()),n=i.le(i.Qd(n,i.hf(1,n))),i.ue(function(e,t){if(!i.wf.arraysEqual(e.shape,t.shape))throw new ua("logits and labels must have the same shape, but got shapes "+"".concat(JSON.stringify(e.shape)," and ").concat(JSON.stringify(t.shape)));return Object(i.pf)((function(){var n=i.Me(t),r=i.ze(i.md(t));return i.nd(i.hf(n,i.ye(t,e)),i.me(i.Wd(r)))}))}(e,n),-1)}))}function Bo(e,t){return Object(i.pf)((function(){var n=i.Bd(e,Jr(),1),r=i.Bd(t,Jr(),1);return i.if(i.ye(e,i.le(i.Qd(n,r))),-1)}))}function Wo(e,t){return Object(i.pf)((function(){var n=Ro(e,-1),r=Ro(t,-1),a=i.ye(n,r);return i.ze(i.if(a,-1))}))}var Uo={meanSquaredError:Fo,meanAbsoluteError:Do,meanAbsolutePercentageError:_o,meanSquaredLogarithmicError:Mo,squaredHinge:function(e,t){return Object(i.pf)((function(){var n=i.te(0,i.hf(1,i.ye(e,t)));return i.ue(gi(n),-1)}))},hinge:function(e,t){return Object(i.pf)((function(){var n=i.te(0,i.hf(1,i.ye(e,t)));return i.ue(n,-1)}))},categoricalHinge:function(e,t){return Object(i.pf)((function(){var n=i.if(i.ye(e,t),-1),r=i.qe(i.ye(i.hf(1,e),t),-1);return i.te(0,i.nd(1,i.hf(r,n)))}))},logcosh:function(e,t){return Object(i.pf)((function(){var n=Math.log(2),r=i.hf(t,e),a=i.hf(i.nd(r,i.cf(i.ye(-2,r))),n);return i.ue(a,-1)}))},categoricalCrossentropy:zo,sparseCategoricalCrossentropy:Lo,binaryCrossentropy:Po,kullbackLeiblerDivergence:Bo,poisson:function(e,t){return Object(i.pf)((function(){var n=i.le(i.nd(Jr(),t));return i.ue(i.hf(t,i.ye(e,n)),-1)}))},cosineProximity:Wo};function Vo(e){if("string"===typeof e){if(e in Uo)return Uo[e];var t="Unknown loss ".concat(e);throw e.toLowerCase().includes("softmaxcrossentropy")&&(t="Unknown loss ".concat(e,". ")+'Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'),new ua(t)}return e}function Ho(e,t){return Object(i.pf)((function(){var n=i.ye(.5,i.Ee(t)),r=oi(i.de(t,n),e.dtype);return i.ue(i.Vd(e,r),-1)}))}function Go(e,t){return Object(i.pf)((function(){return oi(i.Vd(i.qd(e,-1),i.qd(t,-1)),"float32")}))}function qo(e,t){return Object(i.pf)((function(){return i.Ad(i.if(i.oe(i.Vd(e,1),i.Vd(t,1))),"float32")}))}function Ko(e,t){return Object(i.pf)((function(){var n=qo(e,t),r=function(e,t){return Object(i.pf)((function(){return i.Ad(i.if(i.oe(i.Vd(e,0),i.Vd(t,1))),"float32")}))}(e,t),a=i.nd(n,r);return i.Ad(i.Af(i.de(a,0),i.Qd(n,a),0),"float32")}))}function Xo(e,t){return Po(e,t)}function Yo(e,t){return e.rank===t.rank&&(e=i.ff(e,[e.rank-1])),(t=i.qd(t,-1)).dtype!==e.dtype&&(t=i.Ad(t,e.dtype)),i.Ad(i.Vd(e,t),"float32")}var $o=zo,Qo=Lo,Zo={binaryAccuracy:Ho,categoricalAccuracy:Go,precision:Ko,categoricalCrossentropy:$o,sparseCategoricalCrossentropy:Qo,mse:Fo,MSE:Fo,mae:Do,MAE:Do,mape:_o,MAPE:_o,cosine:Wo};function Jo(e){if("string"===typeof e&&e in Zo)return Zo[e];if("string"!==typeof e&&null!=e)return e;throw new ua("Unknown metric ".concat(e))}function es(e){if(pa(null!==e,"Unknown LossOrMetricFn ".concat(e)),"string"===typeof e)return e;for(var t,n=0,r=Object.keys(Uo);n2&&void 0!==arguments[2]&&arguments[2];if(null==e||"object"!==typeof e||Object.getPrototypeOf(e)!==Object.prototype||!rs(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>ts&&console.warn('User-defined metadata of model "'.concat(t,'" is too large in ')+"size (length=".concat(r.length," when serialized). It is not ")+"recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= "+"".concat(ts,"."))}}function rs(e){if(null===e)return!0;if("object"===typeof e){if(Object.getPrototypeOf(e)===Object.prototype){for(var t=0,n=Object.keys(e);t3&&void 0!==arguments[3]?arguments[3]:console.log,i=os(e),o=["Layer (type)","Output shape","Param #"];if(i?(t=t||65,n=n||[.45,.85,1]):(t=t||98,n=n||[.33,.55,.67,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"),r=[],e.nodesByDepth){var c;(c=r).push.apply(c,Object(Vn.a)(e.nodesByDepth[s]))}a("_".repeat(t)),ss(o,n,a),a("=".repeat(t));for(var u=e.layers,l=0;l1||1===s.length&&s[0].inboundLayers.length>1){t=!1;break}r.push.apply(r,Object(Vn.a)(s))}if(t){var c,u=Object(ea.a)(e.layers);try{for(u.s();!(c=u.n()).done;){var l,d=c.value,f=!1,p=Object(ea.a)(d.inboundNodes);try{for(p.s();!(l=p.n()).done;){var h=l.value;if(-1!==r.indexOf(h)){if(f){t=!1;break}f=!0}}}catch(b){p.e(b)}finally{p.f()}if(!t)break}}catch(b){u.e(b)}finally{u.f()}}return t}function ss(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:console.log,r="",a=0;a0&&(r=r.slice(0,r.length-1)+" "),r=(r+=e[a]).slice(0,t[a]),r+=" ".repeat(t[a]-r.length);n(r)}function cs(e,t,n){var r;try{r=JSON.stringify(e.outputShape)}catch(o){r="multiple"}var a=e.name,i=e.getClassName();ss(["".concat(a," (").concat(i,")"),r,e.countParams().toString()],t,n)}function us(e,t,n,r){var a;try{a=JSON.stringify(e.outputShape)}catch(v){a="multiple"}var i,o=[],s=Object(ea.a)(e.inboundNodes);try{for(s.s();!(i=s.n()).done;){var c=i.value;if(!(null!=n&&n.length>0&&-1===n.indexOf(c)))for(var u=0;u0,(function(){return"Expected at least one fetch, got none"}));var n=[],r={};if(1===e.length){var a=ys(e[0],t);n=a.sorted,r=a.recipientMap}else{var o,s=new Set,c=Object(ea.a)(e);try{for(c.s();!(o=c.n()).done;){var u,l=ys(o.value,t),d=l.sorted,f=l.recipientMap,p=Object(ea.a)(d);try{for(p.s();!(u=p.n()).done;){var h=u.value;s.has(h.name)||(n.push(h),s.add(h.name))}}catch(L){p.e(L)}finally{p.f()}var b=function(e){null==r[e]&&(r[e]=new Set),f[e].forEach((function(t){return r[e].add(t)}))};for(var m in f)b(m)}}catch(L){c.e(L)}finally{c.f()}}return{sorted:n,recipientCounts:gs(r)}}(c,t);h=v.sorted,b=v.recipientCounts,bs[m]=h,ms[m]=b}h=bs[m],b={},o||Object.assign(b,ms[m]);for(var g=new hs(t),y=0;yr.maxNumTensors&&(r.maxNumTensors=O),O0;){var l=c[c.length-1];if(r.has(l.name))c.pop();else{var d=u[u.length-1]===c.length-1;if(0===l.inputs.length||d)c.pop(),a.push(l),r.add(l.name),d&&u.pop();else{u.push(c.length-1);var f,p=Object(ea.a)(l.inputs);try{for(p.s();!(f=p.n()).done;){var h=f.value;null==i[h.name]&&(i[h.name]=new Set),i[h.name].add(l.name),r.has(h.name)||c.push(h)}}catch(b){p.e(b)}finally{p.f()}}}}return{sorted:a,recipientMap:i}}function Os(e){var t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{for(var n=null,r=0;r0&&"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 (".concat(r,") outputs, ")+"so ".concat(n," must be either an array with ")+"".concat(r," elements or an object with ").concat(t," keys. ")+"Provided ".concat(n," not understood: ").concat(JSON.stringify(e)))}function ks(e,t){return xs(e,t,"classWeight")}function ws(e,t,n,r){return js.apply(this,arguments)}function js(){return(js=Object(go.a)(vo.a.mark((function e(t,n,r,a){var o,s,c;return vo.a.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 o=Object(i.pf)((function(){if(1===t.shape.length)return Object(i.Cd)(t);if(2===t.shape.length){if(t.shape[1]>1){return Object(i.qd)(t,1)}if(1===t.shape[1])return Object(i.Ne)(t,[t.shape[0]]);throw new Error("Encountered unexpected last-dimension size (".concat(t.shape[1],") ")+"during handling of class weights. The size is expected to be >= 1.")}throw new Error("Unexpected rank of target (y) tensor (".concat(t.rank,") during ")+"handling of class weights. The rank is expected to be 1 or 2.")})),e.t0=Array,e.next=7,o.data();case 7:return e.t1=e.sent,s=e.t0.from.call(e.t0,e.t1),Object(i.Pd)(o),c=[],s.forEach((function(e){if(null==r[e])throw new Error("classWeight must contain all classes in the training data. "+"The class ".concat(e," exists in the data but not in ")+"classWeight");c.push(r[e])})),e.abrupt("return",Object(i.mf)(c,"float32"));case 15:return e.abrupt("return",null);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ss(e,t){return Object(i.ye)(e,t)}function Ns(e,t){var n,r,a=t;n=a.xs,r=a.ys,i.wf.assert(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 "+"".concat(t)}));var o=Is("input",e.inputNames,n),s=Is("output",e.outputNames,r),c=o[0].shape[0];i.wf.assert(o.length===e.inputs.length,(function(){return"LayersModel has ".concat(e.inputs.length," inputs, but the dataset ")+"provides ".concat(o.length," inputs. (Expected input keys: ")+"".concat(JSON.stringify(e.inputNames),")")})),i.wf.assert(s.length===e.outputs.length,(function(){return"LayersModel has ".concat(e.outputs.length," outputs, but the dataset ")+"provides ".concat(s.length," outputs. (Expected output keys: ")+"".concat(JSON.stringify(e.outputNames),")")}));for(var u=function(t){i.wf.assert(o[t].shape[0]===c,(function(){return"Batch size mismatch: input "+"".concat(e.inputNames[t]," has ").concat(o[t].shape[0],"; ")+"expected ".concat(c," based on input ").concat(e.inputNames[0],".")}))},l=0;l0&&Number.isInteger(r.epochs),(function(){return"For fitDataset(), config.epochs is expected to be a positive "+"integer, but got ".concat(r.epochs)})),i.wf.assert(!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 ".concat(r.batchesPerEpoch)})),i.wf.assert(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,(o=null!=r.validationData)&&(Rs(r.validationData)?i.wf.assert(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 ".concat(r.validationBatches)})):(u=Cs(r.validationData),s=u.xs,c=u.ys)),l=t.makeTrainFunction(),d=t.getDedupedMetricsNames(),f=o?d.slice().concat(d.map((function(e){return"val_"+e}))):d.slice(),p=Io(r.callbacks,r.yieldEvery),h=null==r.verbose?1:r.verbose,b=To(p,h,r.epochs,null,null,As(n,r),null,o,f),m=b.callbackList,v=b.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.batchesPerEpoch:w.done)){e.next=87;break}if(!o){e.next=86;break}if(M=void 0,!Rs(r.validationData)){e.next=84;break}return e.t2=ma,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=ma(t.evaluate(s,c,{batchSize:null==r.validationBatchSize?32:r.validationBatchSize,verbose:0}));case 85:for(z=0;z0)){e.next=6;break}throw new la("Verbose mode is not implemented yet.");case 6:if(i.wf.assert(!a||r.batches>0&&Number.isInteger(r.batches),(function(){return"Test loop expects `batches` to be a positive integer, but "+"received ".concat(JSON.stringify(r.batches))})),!Fs(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:c=e.t0,u=0,l=0,d=vo.a.mark((function e(){var n;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.next();case 2:if(n=e.sent,s=i.pf((function(){return n.value&&function(){var e=Ns(t,n.value),r=e.xs,a=e.ys,c=r.concat(a),d=i.pf((function(){return o(c)}));if(i.Pd(c),0===l)for(var f=0;f0&&i.Pd(n)},b=0;b0&&Number.isInteger(e),(function(){return"batchSize is required to be a positive integer, but got ".concat(e)}))}function zs(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((function(e){return ui(e,t,n-t)})):ui(e,t,n-t)}function Ls(e,t){return i.pf((function(){return null==e?null:Array.isArray(e)?e.map((function(e){return Ls(e,t)})):vi(e,"int32"===t.dtype?t:i.Ad(t,"int32"))}))}function Ps(e,t){for(var n=[],r=0,a=null;r=e&&(a=e),n.push([r,a]),r=a;return n}function Bs(e,t,n,r,a,i,o,s,c,u,l,d,f,p,h){return Ws.apply(this,arguments)}function Ws(){return(Ws=Object(go.a)(vo.a.mark((function e(t,n,r,a,o,s,c,u,l,d,f,p,h,b,m){var v,g,y,O,x,k,w,j;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==o&&(o=32),null==s&&(s=1),null==f&&(f=!0),null==h&&(h=0),v=!1,null!=l&&null!=d&&(v=!0),null==m){e.next=10;break}if(v=!0,null!=b){e.next=10;break}throw new ua("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");case 10:return null!=(g=t.checkNumSamples(r,o,b,"steps_per_epoch"))&&(y=ii(0,g)),null==c&&(c=1),O=To(u,c,s,h,g,b,o,v,p),x=O.callbackList,k=O.history,x.setModel(t),t.history=k,e.next=18,x.onTrainBegin();case 18:t.stopTraining_=!1,w=vo.a.mark((function e(s){var c;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,x.onEpochBegin(s);case 2:if(c={},null==b){e.next=7;break}throw new la("stepsPerEpoch mode is not implemented yet.");case 7:return e.delegateYield(vo.a.mark((function e(){var s,u,p,h;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("batch"!==f){e.next=4;break}throw new la("batch shuffling is not implemneted yet");case 4:f&&i.wf.shuffle(y);case 5:s=Object(i.mf)(y),u=Ps(g,o),p=vo.a.mark((function e(f){var p;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return p={},e.next=3,x.onBatchBegin(f,p);case 3:return i.pf((function(){var e=u[f][0],h=u[f][1],b=ui(s,e,h-e);p.batch=f,p.size=h-e;for(var m=Ls(r,b),g=n(m),y=0;y3&&void 0!==T[3]?T[3]:{},!t.isTraining){e.next=3;break}throw new Error("Cannot start training because another fit() call is ongoing.");case 3:return t.isTraining=!0,e.prev=4,Ms(p=null==a.batchSize?32:a.batchSize),h=!1,e.next=10,t.standardizeUserData(n,r,a.sampleWeight,a.classWeight,h,p);case 10:if(b=e.sent,o=b[0],s=b[1],f=b[2],m=!1,!(null!=a.validationData&&a.validationData.length>0)){e.next=36;break}if(m=!0,2!==a.validationData.length){e.next=22;break}c=a.validationData[0],u=a.validationData[1],e.next=27;break;case 22:if(3!==a.validationData.length){e.next=26;break}throw new la("validationData including sample weights is not supported yet.");case 26:throw new ua("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+"".concat(a.validationData," is invalid."));case 27:return g=!0,e.next=30,t.standardizeUserData(c,u,null,null,g,p);case 30:y=e.sent,l=y[0],d=y[1],v=l.concat(d),e.next=37;break;case 36:null!=a.validationSplit&&a.validationSplit>0&&a.validationSplit<1?(m=!0,O=Math.floor(o[0].shape[0]*(1-a.validationSplit)),x=o[0].shape[0],l=zs(o,O,x),o=zs(o,0,O),d=zs(s,O,x),s=zs(s,0,O),v=l.concat(d)):null!=a.validationSteps&&(m=!0);case 37:return k=o.concat(s).concat(f),t.checkTrainableWeightsConsistency(),w=t.makeTrainFunction(),j=t.getDedupedMetricsNames(),m?(t.makeTestFunction(),S=t.testFunction,N=j.slice().concat(j.map((function(e){return"val_"+e})))):(S=null,v=[],N=j.slice()),I=Io(a.callbacks,a.yieldEvery),e.next=45,Bs(t,w,k,j,p,a.epochs,a.verbose,I,S,v,a.shuffle,N,a.initialEpoch,null,null);case 45:return C=e.sent,e.abrupt("return",C);case 47:return e.prev=47,t.isTraining=!1,Gs(o,n),Gs(s,r),Gs(l,c),Gs(d,u),null!=f&&i.Pd(f),e.finish(47);case 55:case"end":return e.stop()}}),e,null,[[4,,47,55]])})))).apply(this,arguments)}function Hs(e){var t=[];e instanceof i.bd&&(e=[e]);for(var n=0;n3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"";if(null==t||0===t.length){if(null!=e){var o=!1;if(qs(e)&&e.length>0)o=!0;else if(Ks(e)){for(var s in e)if(e.hasOwnProperty(s)){o=!0;break}}else o=!0;if(o)throw new ua("Error when checking model ".concat(i," expected no data, ")+"but got ".concat(e))}return[]}if(null==e)return t.map((function(e){return null}));if(Ks(e)){e=e,r=[];var c,u=Object(ea.a)(t);try{for(u.s();!(c=u.n()).done;){var l=c.value;if(null==e[l])throw new ua('No data provided for "'.concat(l,'". Need data for each key in: ')+"".concat(t));r.push(e[l])}}catch(m){u.e(m)}finally{u.f()}}else if(qs(e)){if((e=e).length!==t.length)throw new ua("Error when checking model ".concat(i,": the Array of ")+"Tensors that you are passing to your model is not the size the "+"model expected. Expected to see ".concat(t.length," Tensor(s), but ")+"instead got the following list of Tensor(s): ".concat(e));r=e}else{if(e=e,t.length>1)throw new ua("The model ".concat(i," expects ").concat(t.length," Tensor(s), ")+"but only received one Tensor. Found: Tensor with shape ".concat(e.shape));r=[e]}if(r=Hs(r),null!=n)for(var d=0;d=0&&h!==b)throw new ua("Error when checking ".concat(i,": expected ").concat(t[d]," ")+"to have shape [".concat(n[d],"], but got array with shape ")+"[".concat(f.shape,"]."))}}return r}function Ys(e,t,n){var r=ja(e.map((function(e){return e.shape[0]})));r.sort();var a=ja(t.map((function(e){return e.shape[0]})));if(a.sort(),r.length>1)throw new ua("All input Tensors (x) should have the same number of samples. Got array shapes: "+"".concat(JSON.stringify(e.map((function(e){return e.shape})))));if(a.length>1)throw new ua("All target Tensors (y) should have the same number of samples. Got array shapes: "+"".concat(JSON.stringify(t.map((function(e){return e.shape})))));if(r.length>0&&a.length>0&&!i.wf.arraysEqual(r,a))throw new ua("Input Tensors should have the same number of samples as target "+"Tensors. Found ".concat(r[0]," input sample(s) and ").concat(a[0]," target ")+"sample(s).")}function $s(e,t,n){for(var r=[Fo,Po,zo],a=0;a3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"";if(Array.isArray(e)){if(e.length!==t.length)throw new ua("Error when checking model ".concat(i,": the Array of ")+"Tensors that you are passing to your model is not the size the "+"the model expected. Expected to see ".concat(t.length," Tensor(s),")+" but instead got ".concat(e.length," Tensors(s)."));r=e}else{if(t.length>1)throw new ua("The model expects ".concat(t.length," ").concat(i," Tensors, ")+"but only received one Tensor. Found: array with shape "+"".concat(JSON.stringify(e.shape),"."));r=[e]}if(null!=n)for(var o=0;o2&&void 0!==arguments[2]?arguments[2]:console.log;if(!this.built)throw new ua("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).");as(this,e,t,n)}},{key:"compile",value: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 i.rf.adagrad(.01)},Adadelta:function(){return i.rf.adadelta(1,.95,Jr())},Adam:function(){return i.rf.adam(.001,.9,.999,Jr())},Adamax:function(){return i.rf.adamax(.002,.9,.999,Jr(),0)},RMSProp:function(){return i.rf.rmsprop(.001,.9,0,Jr())},SGD:function(){return i.rf.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 ua("Unknown Optimizer ".concat(e))}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof i.dc))throw new ua("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 ua("When passing an Array as loss, it should have one entry per "+"model output. The model has ".concat(this.outputs.length," output(s), ")+"but you passed loss=".concat(e.loss,"."));var r=e.loss;n=r.map((function(e){return Vo(e)}))}else{var a=Vo(e.loss);this.outputs.forEach((function(e){n.push(a)}))}else{for(var o in e.loss=e.loss,e.loss)if(-1===this.outputNames.indexOf(o))throw new ua('Unknown entry in loss dictionary: "'.concat(o,'". ')+"Only expected the following keys: ".concat(this.outputNames));var s,c=Object(ea.a)(this.outputNames);try{for(c.s();!(s=c.n()).done;){var u=s.value;null==e.loss[u]&&console.warn('Output "'.concat(u,'" is missing from loss dictionary. We assume ')+"this was done on purpose, and we will not be expecting data "+"to be passed to ".concat(u," during training")),n.push(Vo(e.loss[u]))}}catch(m){c.e(m)}finally{c.f()}}this.lossFunctions=n,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(var l=0;l1&&(t.metricsTensors.push([n,e]),t.metricsNames.push(t.outputNames[e]+"_loss"))}}));var h=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: ".concat(e));n=e}if(Array.isArray(n))return t.map((function(e){return n}));var r,a=[],i=Object(ea.a)(t);try{for(i.s();!(r=i.n()).done;){var o=r.value,s=n.hasOwnProperty(o)?n[o]:[];Array.isArray(s)||(s=[s]),a.push(s)}}catch(m){i.e(m)}finally{i.f()}return a}(e.metrics,this.outputNames),b=function(e,n,r){t.outputNames.length>1&&(n=t.outputNames[e]+"_"+n),t.metricsNames.push(n),t.metricsTensors.push([r,e])};Qa("metric",(function(){for(var e=function(e){if(-1!==p.indexOf(e))return"continue";!function(n){var r,a,i,o,s=Object(ea.a)(n);try{for(s.s();!(o=s.n()).done;){var c=o.value;if("string"===typeof c&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(c)){var u=t.internalOutputShapes[e];1===u[u.length-1]||t.lossFunctions[e]===Po?-1!==["accuracy","acc"].indexOf(c)?a=Ho:-1!==["crossentropy","ce"].indexOf(c)&&(a=Xo):t.lossFunctions[e]===Lo?-1!==["accuracy","acc"].indexOf(c)?a=Yo:-1!==["crossentropy","ce"].indexOf(c)&&(a=Qo):-1!==["accuracy","acc"].indexOf(c)?a=Go:-1!==["crossentropy","ce"].indexOf(c)&&(a=$o);var l=void 0;-1!==["accuracy","acc"].indexOf(c)?l="acc":-1!==["crossentropy","ce"].indexOf(c)&&(l="ce"),i=a,r=""+l}else{var d=Jo(c);i=d,r=""+es(c)}var f=void 0;Qa(r,(function(){f=i})),b(e,r,f)}}catch(m){s.e(m)}finally{s.f()}}(h[e])},n=0;n2&&void 0!==arguments[2]?arguments[2]:{},r=null==n.batchSize?32:n.batchSize;Ms(r);var a=!0,i=this.standardizeUserDataXY(e,t,a,r);try{var o=i[0].concat(i[1]);this.makeTestFunction();var s=this.testFunction,c=this.testLoop(s,o,r,n.verbose,n.steps);return ba(c)}finally{Gs(i[0],e),Gs(i[1],t)}}},{key:"evaluateDataset",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.makeTestFunction(),e.abrupt("return",Ds(this,t,n));case 2:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"checkNumSamples",value:function(e,t,n){var r,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"steps";if(null!=n){if(r=null,null!=t)throw new ua("If ".concat(a," is set, batchSize must be null or undefined.")+"Got batchSize = ".concat(t))}else{if(null==e)throw new ua("Either the input data should have a defined shape, or "+"".concat(a," shoud be specified."));r=Array.isArray(e)?e[0].shape[0]:e.shape[0]}return r}},{key:"execute",value:function(e,t){if(Array.isArray(t)&&0===t.length)throw new ua("`outputs` is an empty Array, which is not allowed.");var n=Array.isArray(t),r=n?t:[t],a=this.retrieveSymbolicTensors(r),o=new hs;if(e instanceof i.bd&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new ua("The number of inputs provided (".concat(e.length,") ")+"does not match the number of inputs of this model "+"(".concat(this.inputs.length,")."));for(var s=0;s0){var l=[];throw n.forEach((function(t,n){null==t&&l.push(e[n])})),new ua("Cannot find SymbolicTensors for output name(s): "+"".concat(JSON.stringify(l)))}return n}},{key:"predictLoop",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return i.pf((function(){var a=t.checkNumSamples(e);if(r)throw new la("Verbose predictLoop() is not implemented yet.");for(var o=Ps(a,n),s=t.outputs.map((function(e){return[]})),c=function(n){i.pf((function(){var r=o[n][0],a=o[n][1],i=zs(e,r,a),s=[];if(Array.isArray(i))for(var c=0;c1&&void 0!==arguments[1]?arguments[1]:{},n=Hs(e);Qs(n,this.inputNames,this.feedInputShapes,!1);try{var r=null==t.batchSize?32:t.batchSize;return Ms(r),this.predictLoop(n,r)}finally{Gs(n,e)}}},{key:"predictOnBatch",value:function(e){Qs(e,this.inputNames,this.feedInputShapes,!0);var t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}},{key:"standardizeUserDataXY",value:function(e,t){var n=arguments.length>3?arguments[3]:void 0;if(null==this.optimizer_)throw new ca("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");for(var r=[],a=0;a0&&e[0].shape[0]%n!==0)throw new ua("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+"".concat(n,". Found: ").concat(e[0].shape[0]," sample(s)."));return[e,t]}},{key:"standardizeUserData",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n,r,a){var i,s,c,u,l,d,f,p,h,b=arguments;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!(b.length>4&&void 0!==b[4])||b[4],s=b.length>5?b[5]:void 0,c=this.standardizeUserDataXY(t,n,i,s),u=Object(o.a)(c,2),l=u[0],d=u[1],null==r){e.next=5;break}throw new Error("sample weight is not supported yet.");case 5:if(f=null,null==a){e.next=19;break}p=ks(a,this.outputNames),f=[],h=0;case 10:if(!(h3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0;return i.pf((function(){var s=r.checkNumSamples(t,n,o,"steps"),c=[];if(a>0)throw new la("Verbose mode is not implemented yet.");if(null!=o)throw new la("steps mode in testLoop() is not implemented yet");for(var u=Ps(s,n),l=Object(i.mf)(ii(0,s)),d=0;d1){var i=ha(e.slice(0,n),r);a+="_".concat(i)}t.push(a)}return t}},{key:"makeTrainFunction",value: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),o=t.slice(e.inputs.length+e.outputs.length,e.inputs.length+2*e.outputs.length),s=[],c=e.collectedTrainableWeights.map((function(e){return e.read()}));return[e.optimizer_.minimize((function(){for(var t=[],c=0;c1&&b2&&void 0!==a[2]?a[2]:{},e.abrupt("return",Us(this,t,n,r));case 2:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"fitDataset",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Ts(this,t,n));case 1:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"trainOnBatch",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r,a,o,s,c,u,l,d,f,p;return vo.a.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],o=r[1],s=this.makeTrainFunction(),c=s(a.concat(o)),u=[],l=Object(ea.a)(c),e.prev=9,l.s();case 11:if((d=l.n()).done){e.next=19;break}return f=d.value,e.next=15,f.data();case 15:p=e.sent,u.push(p[0]);case 17:e.next=11;break;case 19:e.next=24;break;case 21:e.prev=21,e.t0=e.catch(9),l.e(e.t0);case 24:return e.prev=24,l.f(),e.finish(24);case 27:return i.Pd(c),e.abrupt("return",ba(u));case 29:case"end":return e.stop()}}),e,this,[[9,21,24,27]])})));return function(t,n){return e.apply(this,arguments)}}()},{key:"getNamedWeights",value:function(e){for(var t=[],n=null!=e&&e.trainableOnly,r=n?this.trainableWeights:this.weights,a=this.getWeights(n),i=0;i1)){e.next=8;break}throw new ua("Found more than one (".concat(r.length,") save handlers for ")+"URL '".concat(t,"'"));case 8:t=r[0];case 9:if(null!=t.save){e.next=11;break}throw new ua("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");case 11:return e.next=13,i.ge.encodeWeights(this.getNamedWeights(n));case 13:if(a=e.sent,!1,null,o=this.toJSON(null,false),s={modelTopology:o,format:"layers-model",generatedBy:"TensorFlow.js tfjs-layers v".concat(ps),convertedBy:null},!(null!=n&&n.includeOptimizer)||null==this.optimizer){e.next=34;break}return s.trainingConfig=this.getTrainingConfig(),u="optimizer",e.t0=i.ge,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,d=l.data,f=l.specs,(c=a.specs).push.apply(c,Object(Vn.a)(f)),a.data=i.ge.concatenateArrayBuffers([a.data,d]);case 34:return null!=this.userDefinedMetadata&&(!0,ns(this.userDefinedMetadata,this.name,true),s.userDefinedMetadata=this.userDefinedMetadata),s.weightData=a.data,s.weightSpecs=a.specs,e.abrupt("return",t.save(s));case 38:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"setUserDefinedMetadata",value:function(e){ns(e,this.name),this.userDefinedMetadata=e}},{key:"getUserDefinedMetadata",value:function(){return this.userDefinedMetadata}}]),n}(function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),(r=t.call(this,{})).containerNodes=new Set,r.name=e.name,null==r.name){var a=r.getClassName().toLowerCase();r.name=Yi(a)}if(r.supportsMasking=!1,r.trainable_=!0,Array.isArray(e.inputs)?r.inputs=e.inputs.slice():r.inputs=[e.inputs],Array.isArray(e.outputs)?r.outputs=e.outputs.slice():r.outputs=[e.outputs],ja(r.inputs).length!==r.inputs.length)throw new ua("The list of inputs passed to the model is redundant. All inputs should only appear once. Found: "+"".concat(r.inputs.map((function(e){return e.name}))));ja(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: "+"".concat(r.outputs.map((function(e){return e.name})))),r.inputLayers=[],r.inputLayersNodeIndices=[],r.inputLayersTensorIndices=[],r.outputLayers=[],r.outputLayersNodeIndices=[],r.outputLayersTensorIndices=[],r.layers=[],r.internalContainerRefs=[];var i,o=Object(ea.a)(r.outputs);try{for(o.s();!(i=o.n()).done;){var s=i.value,c=s.sourceLayer,u=s.nodeIndex,l=s.tensorIndex;r.outputLayers.push(c),r.outputLayersNodeIndices.push(u),r.outputLayersTensorIndices.push(l)}}catch(ke){o.e(ke)}finally{o.f()}var d,f=Object(ea.a)(r.inputs);try{for(f.s();!(d=f.n()).done;){var p=d.value,h=p.sourceLayer,b=p.nodeIndex,m=p.tensorIndex;pa(0===b,"input layer has >1 nodes"),pa(0===m,"input layer has >1 tensors"),r.inputLayers.push(h),r.inputLayersNodeIndices.push(b),r.inputLayersTensorIndices.push(m)}}catch(ke){f.e(ke)}finally{f.f()}r.inputNames=[],r.outputNames=[],r.feedInputShapes=[],r.feedInputNames=[],r.feedOutputNames=[];for(var v=0;v=0;)i.splice(i.indexOf(u),1);C.push(u)}},E=[],A=[],R=Object(ea.a)(r.outputs);try{for(R.s();!(k=R.n()).done;){T(k.value,E,A)}}catch(ke){R.e(ke)}finally{R.f()}var F,D=C.slice().reverse(),_=Object(ea.a)(D);try{for(_.s();!(F=_.n()).done;){var M=F.value;j[M.id]=M,M.id in w||(w[M.id]=0);var z=w[M.id],L=null==S[M.outboundLayer.id]?0:S[M.outboundLayer.id];z=Math.max(z,L),S[M.outboundLayer.id]=z,N[M.outboundLayer.id]=M.outboundLayer,w[M.id]=z;for(var P=0;Pr?1:0}));var ee,te=Object(ea.a)(J);try{for(te.s();!(ee=te.n()).done;){var ne=ee.value;ne instanceof n&&r.internalContainerRefs.push(ne),r.layers.push(ne)}}catch(ke){te.e(ke)}finally{te.f()}}}catch(ke){Z.e(ke)}finally{Z.f()}r.layersByDepth=K,$=Object.keys(H).map((function(e){return parseInt(e,10)})).sort(wa);var re,ae=r.inputs.slice(),ie=[],oe=Object(ea.a)($);try{for(oe.s();!(re=oe.n()).done;){var se,ce=re.value,ue=Object(ea.a)(H[ce]);try{for(ue.s();!(se=ue.n()).done;){var le=se.value,de=le.outboundLayer;if(null!=de){var fe,pe=Object(ea.a)(le.inputTensors);try{for(pe.s();!(fe=pe.n()).done;){var he=fe.value;if(-1===ae.indexOf(he))throw new ca("Graph disconnected: cannot obtain value for tensor ".concat(he)+' at layer "'.concat(de.name,'". ')+"The following previous layers were accessed without "+"issue: ".concat(ie))}}catch(ke){pe.e(ke)}finally{pe.f()}var be,me=Object(ea.a)(le.outputTensors);try{for(me.s();!(be=me.n()).done;){var ve=be.value;ae.push(ve)}}catch(ke){me.e(ke)}finally{me.f()}ie.push(de.name)}}}catch(ke){ue.e(ke)}finally{ue.f()}}}catch(ke){oe.e(ke)}finally{oe.f()}r.nodesByDepth=H;var ge,ye=r.layers.map((function(e){return e.name})),Oe=Object(ea.a)(ye);try{var xe=function(){var e=ge.value,t=ye.filter((function(t){return t===e})).length;if(1!==t)throw new ca('The name "'.concat(e,'" is used ').concat(t," times ")+"in the model. All layer names should be unique. Layer names: "+JSON.stringify(ye))};for(Oe.s();!(ge=Oe.n()).done;)xe()}catch(ke){Oe.e(ke)}finally{Oe.f()}return r.outboundNodes=[],r.inboundNodes=[],new co({outboundLayer:Object(ta.a)(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}return Object($r.a)(n,[{key:"assertNotDisposed",value:function(){if(0===this._refCount)throw new Error("Container '".concat(this.name,"' is already disposed."))}},{key:"dispose",value:function(){this.assertNotDisposed();var e={refCountAfterDispose:null,numDisposedVariables:0};if(0===--this._refCount){var t,n=Object(ea.a)(this.layers);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.numDisposedVariables+=r.dispose().numDisposedVariables}}catch(s){n.e(s)}finally{n.f()}var a,i=Object(ea.a)(this.internalContainerRefs);try{for(i.s();!(a=i.n()).done;){var o=a.value;e.numDisposedVariables+=o.dispose().numDisposedVariables}}catch(s){i.e(s)}finally{i.f()}}return e.refCountAfterDispose=this._refCount,e}},{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 ua("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[];var e,t=[],n=Object(ea.a)(this.layers);try{for(n.s();!(e=n.n()).done;){var r=e.value;t=t.concat(r.trainableWeights)}}catch(a){n.e(a)}finally{n.f()}return t}},{key:"nonTrainableWeights",get:function(){var e,t=[],n=Object(ea.a)(this.layers);try{for(n.s();!(e=n.n()).done;){var r=e.value;t.push.apply(t,Object(Vn.a)(r.nonTrainableWeights))}}catch(c){n.e(c)}finally{n.f()}if(!this.trainable){var a,i=[],o=Object(ea.a)(this.layers);try{for(o.s();!(a=o.n()).done;){var s=a.value;i.push.apply(i,Object(Vn.a)(s.trainableWeights))}}catch(c){o.e(c)}finally{o.f()}return i.concat(t)}return t}},{key:"weights",get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)}},{key:"loadWeights",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r={},a=0,i=Object(ea.a)(this.layers);try{for(i.s();!(t=i.n()).done;){var o,s=t.value,c=Object(ea.a)(s.weights);try{for(c.s();!(o=c.n()).done;){var u=o.value;if(null!=r[u.originalName])throw new ua("Duplicate weight name: ".concat(u.originalName));r[u.originalName]=u,a++}}catch(v){c.e(v)}finally{c.f()}}}catch(v){i.e(v)}finally{i.f()}var l=[];for(var d in e){var f=d;if(null==r[d]){var p=d.split("/"),h=p.slice(0,-2).concat([p[p.length-1]]);f=h.join("/")}if(null!=r[f])l.push([r[f],e[d]]);else if(n)throw new ua("Provided weight data has no target variable: ".concat(d));delete r[f]}if(n){var b=[];for(var m in r)b.push(m);if(b.length>0)throw new ua("".concat(b.length," of ").concat(a," weights are not set: ")+"".concat(b))}ao(l)}},{key:"updatedConfig",value:function(){var e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion="tfjs-layers ".concat(ps),t.backend="TensorFlow.js",t}},{key:"toJSON",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=fs(this.updatedConfig());return t?JSON.stringify(n):n}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){e=ma(e);for(var r=new hs,a=0;a1){var s,c=Object(ea.a)(o);try{for(c.s();!(s=c.n()).done;){var u,l=s.value,d=this.nodesByDepth[l],f=Object(ea.a)(d);try{for(f.s();!(u=f.n()).done;){var p=u.value,h=p.outboundLayer;if(-1===this.inputLayers.map((function(e){return e.id})).indexOf(h.id)){for(var b=[],m=0;m0){for(var h=[],b=0;b3&&void 0!==arguments[3]&&arguments[3],r={},a={};function i(e,t){e.name in a?a[e.name].push(t):a[e.name]=[t]}function o(e,t){var n,a,o=[],s=Object(ea.a)(t);try{for(s.s();!(a=s.n()).done;){var c=a.value,u=c[0],l=c[1],d=c[2];if(n=null==c[3]?{}:c[3],!(u in r))return void i(e,t);var f=r[u];if(f.inboundNodes.length<=l)return void i(e,t);var p=f.inboundNodes[l];o.push(p.outputTensors[d])}}catch(h){s.e(h)}finally{s.f()}o.length>0&&e.apply(ba(o),n)}function s(e){var a=e.name,o=Ao(e,null!=t.customObjects?t.customObjects:{});o.setFastWeightInitDuringBuild(n),r[a]=o,e.inboundNodes.forEach((function(e){if(!(e instanceof Array))throw new ua("Corrupted configuration, expected array for nodeData: ".concat(e));i(o,e)}))}var c,u=t.name,l=t.layers,d=Object(ea.a)(l);try{for(d.s();!(c=d.n()).done;){var f=c.value;s(f)}}catch(W){d.e(W)}finally{d.f()}for(;!Sa(a);){var p,h=Object(ea.a)(l);try{for(h.s();!(p=h.n()).done;){var b=p.value,m=r[b.name];if(m.name in a){var v=a[m.name];delete a[m.name];var g,y=Object(ea.a)(v);try{for(y.s();!(g=y.n()).done;){var O=g.value;o(m,O)}}catch(W){y.e(W)}finally{y.f()}}}}catch(W){h.e(W)}finally{h.f()}}var x,k=[],w=[],j=t.inputLayers,S=Object(ea.a)(j);try{for(S.s();!(x=S.n()).done;){var N=x.value,I=N[0],C=N[1],T=N[2];pa(I in r);var E=r[I],A=E.inboundNodes[C].outputTensors;k.push(A[T])}}catch(W){S.e(W)}finally{S.f()}var R,F=t.outputLayers,D=Object(ea.a)(F);try{for(D.s();!(R=D.n()).done;){var _=R.value,M=_[0],z=_[1],L=_[2];pa(M in r);var P=r[M],B=P.inboundNodes[z].outputTensors;w.push(B[L])}}catch(W){D.e(W)}finally{D.f()}return new e({inputs:k,outputs:w,name:u})}}]),n}(lo));Zs.className="Model",i.Se.registerClass(Zs);var Js=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return n}(Zs);Js.className="Functional",i.Se.registerClass(Js);var ec=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),e=e||{},(r=t.call(this,{inputs:[],outputs:[]})).trainable=!0,r.built=!1,r.name=null!=e.name?e.name:Yi("sequential_"),null!=e.layers){var a,i=Object(ea.a)(e.layers);try{for(i.s();!(a=i.n()).done;){var o=a.value;r.add(o)}}catch(s){i.e(s)}finally{i.f()}}return r}return Object($r.a)(n,[{key:"checkShape",value:function(e){if(e.inboundNodes[0].outputTensors[0].shape.some((function(e){return e<0})))throw new ua("Negative dimension size caused by adding layer "+"".concat(e.name," with input shape [")+"".concat(e.inboundNodes[0].inputTensors[0].shape,"]"))}},{key:"add",value:function(e){var t,r=e instanceof n||e instanceof Zs;if(r){if(1!==(t=e).outputs.length)throw new ua("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==t.inputs.length)throw new ua("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 ua("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");var a=ho({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(a)}if(r)this.outputs=t.outputs,this.inputs=t.inputs;else{if(1!==e.inboundNodes.length)throw new ua("A layer added to a Sequential model must not already be "+"connected somewhere else. LayersModel received layer ".concat(e.name," ")+"which has ".concat(e.inboundNodes.length," pre-existing inbound ")+"connections.");if(1!==e.inboundNodes[0].outputTensors.length)throw new ua("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=fo(this.outputs[0])}this.inboundNodes=[],new co({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:fa(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}},{key:"pop",value: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]}}},{key:"call",value:function(e,t){return null==this.model&&this.build(),this.model.call(e,t)}},{key:"build",value:function(e){if(Ji(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 Zs({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}},{key:"countParams",value:function(){return this.built||this.build(),Object(Eo.a)(Object(na.a)(n.prototype),"countParams",this).call(this)}},{key:"summary",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:console.log;this.built||this.build(),Object(Eo.a)(Object(na.a)(n.prototype),"summary",this).call(this,e,t,r)}},{key:"setWeights",value:function(e){null==this.model&&this.build(),this.model.setWeights(e)}},{key:"evaluate",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.built)throw new ca("The model needs to be compiled before being used.");return this.model.evaluate(e,t,n)}},{key:"evaluateDataset",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.built){e.next=2;break}throw new ca("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)}}()},{key:"predict",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return null==this.model&&this.build(),this.model.predict(e,t)}},{key:"predictOnBatch",value:function(e){return null==this.model&&this.build(),this.model.predictOnBatch(e)}},{key:"compile",value: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}},{key:"optimizer",get:function(){return null==this.model?void 0:this.model.optimizer},set:function(e){this.model.optimizer=e}},{key:"fit",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r,a=arguments;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.length>2&&void 0!==a[2]?a[2]:{},this.built){e.next=3;break}throw new ca("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){return e.apply(this,arguments)}}()},{key:"fitDataset",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.built){e.next=2;break}throw new ca("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)}}()},{key:"trainOnBatch",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){return vo.a.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)}}()},{key:"stopTraining",get:function(){if(null==this.model)throw new ua("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 ua("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}},{key:"getConfig",value:function(){var e,t=[],n=Object(ea.a)(this.layers);try{for(n.s();!(e=n.n()).done;){var r=e.value,a={};a.className=r.getClassName(),a.config=r.getConfig(),t.push(a)}}catch(i){n.e(i)}finally{n.f()}return{name:this.name,layers:t}}}],[{key:"fromConfig",value:function(e,t){var r,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o={};if(t instanceof Array){if(null==t[0].className||"Merge"===t[0].className)throw new ua("Legacy serialization format not supported yet.");r=t}else i.wf.assert(null!=t.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."})),r=t.layers,delete t.layers,o=t;var s=new e(o);if(!(s instanceof n))throw new la("Sequential.fromConfig called on non-Sequential input: ".concat(s));var c,u=Object(ea.a)(r);try{for(u.s();!(c=u.n()).done;){var l=c.value,d=void 0,f=Ao(l,d,a);a&&f.setFastWeightInitDuringBuild(!0),s.add(f)}}catch(p){u.e(p)}finally{u.f()}return s}}]),n}(Zs);ec.className="Sequential",i.Se.registerClass(ec);var tc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"getConfig",value:function(){return{}}}]),n}(i.Se.Serializable),nc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return xi(e,t)}}]),n}(tc);nc.className="elu",i.Se.registerClass(nc);var rc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return i.Qe(e)}}]),n}(tc);rc.className="selu",i.Se.registerClass(rc);var ac=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return i.Me(e)}}]),n}(tc);ac.className="relu",i.Se.registerClass(ac);var ic=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return Object(i.pf)((function(){return i.we(6,i.Me(e))}))}}]),n}(tc);ic.className="relu6",i.Se.registerClass(ic);var oc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return e}}]),n}(tc);oc.className="linear",i.Se.registerClass(oc);var sc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return i.Ue(e)}}]),n}(tc);sc.className="sigmoid",i.Se.registerClass(sc);var cc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return function(e){return Object(i.pf)((function(){var t=i.nd(.5,i.ye(.2,e));return i.Bd(t,0,1)}))}(e)}}]),n}(tc);cc.className="hardSigmoid",i.Se.registerClass(cc);var uc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return i.cf(e)}}]),n}(tc);uc.className="softplus",i.Se.registerClass(uc);var lc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return function(e){return Object(i.pf)((function(){return i.Qd(e,i.nd(i.md(e),1))}))}(e)}}]),n}(tc);lc.className="softsign",i.Se.registerClass(lc);var dc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return i.kf(e)}}]),n}(tc);dc.className="tanh",i.Se.registerClass(dc);var fc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return i.bf(e,t)}}]),n}(tc);fc.className="softmax",i.Se.registerClass(fc);var pc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return i.ne(e,t)}}]),n}(tc);pc.className="logSoftmax",i.Se.registerClass(pc);var hc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Object(i.pf)((function(){return i.ye(i.Ue(i.ye(e,t)),e)}))}}]),n}(tc);hc.className="swish",i.Se.registerClass(hc);var bc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"apply",value:function(e){return Object(i.pf)((function(){return i.ye(e,i.kf(i.cf(e)))}))}}]),n}(tc);function mc(e){return e.getClassName()}function vc(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ka(e,i.Se.SerializationMap.getMap().classNameMap,t,"activation")}function gc(e){if(null==e){var t={className:"linear",config:{}};return vc(t)}if("string"===typeof e){var n={};return n.className=e,n.config={},vc(n)}return e instanceof tc?e:vc(e)}function yc(e){if(null!=e&&"object"!==typeof e)throw new Error("Argument to L1L2 regularizer's constructor is expected to be an "+"object, but received: ".concat(e))}bc.className="mish",i.Se.registerClass(bc);var Oc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return n}(i.Se.Serializable),xc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),r=t.call(this),yc(e),r.l1=null==e||null==e.l1?.01:e.l1,r.l2=null==e||null==e.l2?.01:e.l2,r.hasL1=0!==r.l1,r.hasL2=0!==r.l2,r}return Object($r.a)(n,[{key:"apply",value:function(e){var t=this;return Object(i.pf)((function(){var n=Object(i.Bf)([1]);return t.hasL1&&(n=Object(i.nd)(n,Object(i.if)(i.ye(t.l1,Object(i.md)(e))))),t.hasL2&&(n=Object(i.nd)(n,Object(i.if)(i.ye(t.l2,gi(e))))),i.Ne(n,[])}))}},{key:"getConfig",value:function(){return{l1:this.l1,l2:this.l2}}}],[{key:"fromConfig",value:function(e,t){return new e({l1:t.l1,l2:t.l2})}}]),n}(Oc);xc.className="L1L2",i.Se.registerClass(xc);var kc={l1l2:"L1L2"};function wc(e){return Oa(e)}function jc(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ka(e,i.Se.SerializationMap.getMap().classNameMap,t,"regularizer")}function Sc(e){return null==e?null:"string"===typeof e?jc({className:e in kc?kc[e]:e,config:{}}):e instanceof Oc?e:jc(e)}var Nc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,null==e?{}:e)).supportsMasking=!0,null!=e&&(r.maxValue=e.maxValue),r}return Object($r.a)(n,[{key:"call",value:function(e,t){e=Zi(e);var n=Object(i.Me)(e);return null!=this.maxValue&&(n=Object(i.Bd)(n,0,this.maxValue)),n}},{key:"computeOutputShape",value:function(e){return e}},{key:"getConfig",value:function(){var e={maxValue:this.maxValue},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(lo);Nc.className="ReLU",i.Se.registerClass(Nc);var Ic=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,null==e?{}:e)).DEFAULT_ALPHA=.3,null==e&&(e={}),r.alpha=null==e.alpha?r.DEFAULT_ALPHA:e.alpha,r}return Object($r.a)(n,[{key:"call",value:function(e,t){var n=Zi(e);return Object(i.je)(n,this.alpha)}},{key:"computeOutputShape",value:function(e){return e}},{key:"getConfig",value:function(){var e={alpha:this.alpha},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(lo);Ic.className="LeakyReLU",i.Se.registerClass(Ic);var Cc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),(r=t.call(this,null==e?{}:e)).DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),r.supportsMasking=!0,r.alphaInitializer=Gi(e.alphaInitializer||r.DEFAULT_ALPHA_INITIALIZER),r.alphaRegularizer=Sc(e.alphaRegularizer),r.alphaConstraint=Ba(e.alphaConstraint),null==e.sharedAxes)r.sharedAxes=null;else if(Array.isArray(e.sharedAxes))r.sharedAxes=e.sharedAxes;else{if("number"!==typeof e.sharedAxes)throw new ua("Expected sharedAxes to be a number or an array of numbers, "+"but got ".concat(e.sharedAxes));r.sharedAxes=[e.sharedAxes]}return r}return Object($r.a)(n,[{key:"build",value:function(e){var t=(e=Ji(e)).slice(1);if(null!=this.sharedAxes){var n,r=Object(ea.a)(this.sharedAxes);try{for(r.s();!(n=r.n()).done;){t[n.value-1]=1}}catch(o){r.e(o)}finally{r.f()}}this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);var a={};if(null!=this.sharedAxes)for(var i=1;i4&&void 0!==arguments[4]?arguments[4]:1;if(null==e)return e;var i,o=t+(t-1)*(a-1);return i="same"===n?e:e-o+1,Math.floor((i+r-1)/r)}function _c(e,t,n,r){if(null==e)return null;if("valid"===r)e=e*t+ai([n-t,0]);else{if("same"!==r)throw new ua("Unsupport padding mode: ".concat(r,"."));e*=t}return e}function Mc(e,t){return Object(i.pf)((function(){return Ka(t),"channelsFirst"===t?i.sf(e,[0,2,3,1]):e}))}function zc(e,t){return Object(i.pf)((function(){return Ka(t),"channelsFirst"===t?i.sf(e,[0,2,3,4,1]):e}))}function Lc(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"valid",o=arguments.length>5?arguments[5]:void 0,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1;return Object(i.pf)((function(){if(null==o&&(o="channelsLast"),Ka(o),3!==e.shape.length)throw new ua("The input of a conv1dWithBias operation should be 3, but is "+"".concat(e.shape.length," instead."));if(3!==t.shape.length)throw new ua("The kernel for a conv1dWithBias operation should be 3, but is "+"".concat(t.shape.length," instead"));if(null!=n&&1!==n.shape.length)throw new ua("The bias for a conv1dWithBias operation should be 1, but is "+"".concat(t.shape.length," instead"));if("channelsFirst"===o&&(e=i.sf(e,[0,2,1])),"causal"===a)throw new la("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");var c=i.Id(e,t,r,"same"===a?"same":"valid","NWC",s);return null!=n&&(c=Oi(c,n)),c}))}function Pc(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1,1],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"valid",o=arguments.length>5?arguments[5]:void 0,s=arguments.length>6?arguments[6]:void 0,c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null;return Object(i.pf)((function(){if(null==o&&(o="channelsLast"),Ka(o),3!==e.rank&&4!==e.rank)throw new ua("conv2dWithBiasActivation expects input to be of rank 3 or 4, "+"but received ".concat(e.rank,"."));if(3!==t.rank&&4!==t.rank)throw new ua("conv2dWithBiasActivation expects kernel to be of rank 3 or 4, "+"but received ".concat(e.rank,"."));var u=Mc(e,o);if("causal"===a)throw new la("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=i.be.conv2d({x:u,filter:t,strides:r,pad:"same"===a?"same":"valid",dilations:s,dataFormat:"NHWC",bias:n,activation:c}),"channelsFirst"===o&&(u=i.sf(u,[0,3,1,2])),u}))}function Bc(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1,1,1],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"valid",o=arguments.length>5?arguments[5]:void 0,s=arguments.length>6?arguments[6]:void 0;return Object(i.pf)((function(){if(null==o&&(o="channelsLast"),Ka(o),4!==e.rank&&5!==e.rank)throw new ua("conv3dWithBias expects input to be of rank 4 or 5, but received "+"".concat(e.rank,"."));if(4!==t.rank&&5!==t.rank)throw new ua("conv3dWithBias expects kernel to be of rank 4 or 5, but received "+"".concat(e.rank,"."));var c=zc(e,o);if("causal"===a)throw new la("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return c=i.Ld(c,t,r,"same"===a?"same":"valid","NDHWC",s),null!=n&&(c=Oi(c,n)),"channelsFirst"===o&&(c=i.sf(c,[0,4,1,2,3])),c}))}var Wc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e,r){var a;if(Object(Yr.a)(this,n),(a=t.call(this,r)).bias=null,a.DEFAULT_KERNEL_INITIALIZER="glorotNormal",a.DEFAULT_BIAS_INITIALIZER="zeros",n.verifyArgs(r),a.rank=e,Ca(a.rank,"rank"),1!==a.rank&&2!==a.rank&&3!==a.rank)throw new la("Convolution layer for rank other than 1, 2, or 3 (".concat(a.rank,") is ")+"not implemented yet.");if(a.kernelSize=Fc(r.kernelSize,e,"kernelSize"),a.strides=Fc(null==r.strides?1:r.strides,e,"strides"),a.padding=null==r.padding?"valid":r.padding,Xa(a.padding),a.dataFormat=null==r.dataFormat?"channelsLast":r.dataFormat,Ka(a.dataFormat),a.activation=gc(r.activation),a.useBias=null==r.useBias||r.useBias,a.biasInitializer=Gi(r.biasInitializer||a.DEFAULT_BIAS_INITIALIZER),a.biasConstraint=Ba(r.biasConstraint),a.biasRegularizer=Sc(r.biasRegularizer),a.activityRegularizer=Sc(r.activityRegularizer),a.dilationRate=Fc(null==r.dilationRate?1:r.dilationRate,e,"dilationRate"),1===a.rank&&Array.isArray(a.dilationRate)&&1!==a.dilationRate.length)throw new ua("dilationRate must be a number or an array of a single number for 1D convolution, but received "+"".concat(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 ua("dilationRate must be a number or array of two numbers for 2D "+"convolution, but received ".concat(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 ua("dilationRate must be a number or array of three numbers for 3D "+"convolution, but received ".concat(JSON.stringify(a.dilationRate)));return a}return Object($r.a)(n,[{key:"getConfig",value:function(){var e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:mc(this.activation),useBias:this.useBias,biasInitializer:Hi(this.biasInitializer),biasRegularizer:wc(this.biasRegularizer),activityRegularizer:wc(this.activityRegularizer),biasConstraint:La(this.biasConstraint)},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}],[{key:"verifyArgs",value:function(e){if(pa("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!==typeof e.kernelSize&&!Ia(e.kernelSize,"number",1,3))throw new ua("BaseConv expects config.kernelSize to be number or number[] with "+"length 1, 2, or 3, but received ".concat(JSON.stringify(e.kernelSize),"."))}}]),n}(lo),Uc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e,r){var a;return Object(Yr.a)(this,n),(a=t.call(this,e,r)).kernel=null,n.verifyArgs(r),a.filters=r.filters,Ca(a.filters,"filters"),a.kernelInitializer=Gi(r.kernelInitializer||a.DEFAULT_KERNEL_INITIALIZER),a.kernelConstraint=Ba(r.kernelConstraint),a.kernelRegularizer=Sc(r.kernelRegularizer),a}return Object($r.a)(n,[{key:"build",value:function(e){e=Ji(e);var t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new ua("The channel dimension of the input should be defined. "+"Found ".concat(e[t]));var n=e[t],r=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",r,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:Object(Rc.a)({},t,n)}],this.built=!0}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){var t;e=Zi(e);var r=null==n.bias?null:n.bias.read(),a=Ea(n.activation.getClassName());if(null!=a&&2===n.rank)t=Pc(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate,a);else{if(1===n.rank)t=Lc(e,n.kernel.read(),r,n.strides[0],n.padding,n.dataFormat,n.dilationRate[0]);else if(2===n.rank)t=Pc(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate);else{if(3!==n.rank)throw new la("convolutions greater than 3D are not implemented yet.");t=Bc(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate)}null!=n.activation&&(t=n.activation.apply(t))}return t}))}},{key:"computeOutputShape",value:function(e){e=Ji(e);for(var t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2),r=0;r 0 "+"but got ".concat(JSON.stringify(e.filters)))}}]),n}(Wc),Vc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),r=t.call(this,2,e),n.verifyArgs(e),r}return Object($r.a)(n,[{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return delete e.rank,e}}],[{key:"verifyArgs",value:function(e){if("number"!==typeof e.kernelSize&&!Ia(e.kernelSize,"number",1,2))throw new ua("Conv2D expects config.kernelSize to be number or number[] with "+"length 1 or 2, but received ".concat(JSON.stringify(e.kernelSize),"."))}}]),n}(Uc);Vc.className="Conv2D",i.Se.registerClass(Vc);var Hc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),r=t.call(this,3,e),n.verifyArgs(e),r}return Object($r.a)(n,[{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return delete e.rank,e}}],[{key:"verifyArgs",value:function(e){if("number"!==typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new ua("Conv3D expects config.kernelSize to be number or"+" [number, number, number], but received ".concat(JSON.stringify(e.kernelSize),"."))}}]),n}(Uc);Hc.className="Conv3D",i.Se.registerClass(Hc);var Gc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),(r=t.call(this,e)).inputSpec=[new io({ndim:4})],"same"!==r.padding&&"valid"!==r.padding)throw new ua("Conv2DTranspose currently supports only padding modes 'same' "+"and 'valid', but received padding mode ".concat(r.padding));return r}return Object($r.a)(n,[{key:"build",value:function(e){if(4!==(e=Ji(e)).length)throw new ua("Input should have rank 4; Received input shape: "+JSON.stringify(e));var t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new ua("The channel dimension of the inputs should be defined. Found `None`.");var n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"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 io({ndim:4,axes:Object(Rc.a)({},t,n)})],this.built=!0}},{key:"call",value:function(e,t){var n=this;return i.pf((function(){var t=Zi(e);if(4!==t.shape.length)throw new ua("Conv2DTranspose.call() expects input tensor to be rank-4, but "+"received a tensor of rank-".concat(t.shape.length));var r,a,o=t.shape,s=o[0];"channelsFirst"===n.dataFormat?(r=2,a=3):(r=1,a=2);var c=o[r],u=o[a],l=n.kernelSize[0],d=n.kernelSize[1],f=n.strides[0],p=n.strides[1],h=[s,_c(c,f,l,n.padding),_c(u,p,d,n.padding),n.filters];"channelsLast"!==n.dataFormat&&(t=i.sf(t,[0,2,3,1]));var b=i.Kd(t,n.kernel.read(),h,n.strides,n.padding);return"channelsLast"!==n.dataFormat&&(b=i.sf(b,[0,3,1,2])),null!=n.bias&&(b=Oi(b,n.bias.read(),n.dataFormat)),null!=n.activation&&(b=n.activation.apply(b)),b}))}},{key:"computeOutputShape",value:function(e){var t,n,r,a=(e=Ji(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],c=this.strides[1];return a[t]=this.filters,a[n]=_c(a[n],s,i,this.padding),a[r]=_c(a[r],c,o,this.padding),a}},{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return delete e.dilationRate,e}}]),n}(Vc);Gc.className="Conv2DTranspose",i.Se.registerClass(Gc);var qc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),(r=t.call(this,e)).inputSpec=[new io({ndim:5})],"same"!==r.padding&&"valid"!==r.padding)throw new ua("Conv3DTranspose currently supports only padding modes 'same' "+"and 'valid', but received padding mode ".concat(r.padding));return r}return Object($r.a)(n,[{key:"build",value:function(e){if(5!==(e=Ji(e)).length)throw new ua("Input should have rank 5; Received input shape: "+JSON.stringify(e));var t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new ua("The channel dimension of the inputs should be defined. Found `None`.");var n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"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 io({ndim:5,axes:Object(Rc.a)({},t,n)})],this.built=!0}},{key:"call",value:function(e,t){var n=this;return i.pf((function(){var t=Zi(e);if(5!==t.shape.length)throw new ua("Conv3DTranspose.call() expects input tensor to be rank-4, but "+"received a tensor of rank-".concat(t.shape.length));var r,a,o,s=t.shape,c=s[0];"channelsFirst"===n.dataFormat?(o=2,r=3,a=4):(o=1,r=2,a=3);var u=s[o],l=s[r],d=s[a],f=n.kernelSize[0],p=n.kernelSize[1],h=n.kernelSize[2],b=n.strides[0],m=n.strides[1],v=n.strides[2],g=[c,_c(u,b,f,n.padding),_c(l,m,p,n.padding),_c(d,v,h,n.padding),n.filters];"channelsLast"!==n.dataFormat&&(t=i.sf(t,[0,2,3,4,1]));var y=i.Md(t,n.kernel.read(),g,n.strides,n.padding);return"channelsLast"!==n.dataFormat&&(y=i.sf(y,[0,4,1,2,3])),null!==n.bias&&(y=Oi(y,n.bias.read(),n.dataFormat)),null!==n.activation&&(y=n.activation.apply(y)),y}))}},{key:"computeOutputShape",value:function(e){var t,n,r,a,i=(e=Ji(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],c=this.kernelSize[2],u=this.strides[0],l=this.strides[1],d=this.strides[2];return i[t]=this.filters,i[n]=_c(i[n],u,o,this.padding),i[r]=_c(i[r],l,s,this.padding),i[a]=_c(i[a],d,c,this.padding),i}},{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return delete e.dilationRate,e}}]),n}(Hc);qc.className="Conv3DTranspose",i.Se.registerClass(qc);var Kc=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e,r){var a;if(Object(Yr.a)(this,n),(a=t.call(this,e,r)).DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",a.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",a.depthwiseKernel=null,a.pointwiseKernel=null,null==r.filters)throw new ua("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=r.kernelInitializer||null!=r.kernelRegularizer||null!=r.kernelConstraint)throw new ua("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=r.padding&&"same"!==r.padding&&"valid"!==r.padding)throw new ua("SeparableConv".concat(a.rank,"D supports only padding modes: ")+"'same' and 'valid', but received ".concat(JSON.stringify(r.padding)));return a.depthMultiplier=null==r.depthMultiplier?1:r.depthMultiplier,a.depthwiseInitializer=Gi(r.depthwiseInitializer||a.DEFAULT_DEPTHWISE_INITIALIZER),a.depthwiseRegularizer=Sc(r.depthwiseRegularizer),a.depthwiseConstraint=Ba(r.depthwiseConstraint),a.pointwiseInitializer=Gi(r.depthwiseInitializer||a.DEFAULT_POINTWISE_INITIALIZER),a.pointwiseRegularizer=Sc(r.pointwiseRegularizer),a.pointwiseConstraint=Ba(r.pointwiseConstraint),a}return Object($r.a)(n,[{key:"build",value:function(e){if((e=Ji(e)).length2&&void 0!==arguments[2]?arguments[2]:[1,1],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"valid",a=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0;return Object(i.pf)((function(){null==a&&(a="channelsLast"),Ka(a);var s=Mc(e,a);if(4!==e.rank)throw new ua("Input for depthwiseConv2d is required to be 4-D, but is instead "+"".concat(e.rank,"-D"));if(4!==t.rank)throw new ua("depthwiseKernel is required to be 4-D, but is instead "+"".concat(t.rank,"-D"));return s=i.Nd(s,t,n,"same"===r?"same":"valid","NHWC",o),"channelsFirst"===a&&(s=i.sf(s,[0,3,1,2])),s}))}(e=Zi(e),n.depthwiseKernel.read(),n.strides,n.padding,n.dataFormat,null);return n.useBias&&(t=Oi(t,n.bias.read(),n.dataFormat)),null!=n.activation&&(t=n.activation.apply(t)),t}))}},{key:"computeOutputShape",value:function(e){e=Ji(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=Dc(t,this.kernelSize[0],this.padding,this.strides[0]),i=Dc(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],r,a,i]:[e[0],a,i,r]}},{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Hi(this.depthwiseInitializer),e.depthwiseRegularizer=wc(this.depthwiseRegularizer),e.depthwiseConstraint=La(this.depthwiseRegularizer),e}}]),n}(Wc);function Jc(e,t,n,r){if(Array.isArray(e)){if(null!=t||null!=n)throw new ua("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 eu(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0,s=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=arguments.length>7&&void 0!==arguments[7]&&arguments[7];return i.pf((function(){var u=t.shape.length;if(u<3)throw new ua("Input should be at least 3D, but is ".concat(u,"D."));var l=[1,0].concat(ii(2,u));if(t=i.sf(t,l),null!=o)throw new la("The rnn() functoin of the deeplearn.js backend does not support constants yet.");s&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=a&&((a=i.Ad(i.Ad(a,"bool"),"float32")).rank===u-1&&(a=i.Xd(a,-1)),a=i.sf(a,l)),r&&(t=i.Oe(t,0),null!=a&&(a=i.Oe(a,0)));var d,f,p=[],h=n,b=t.shape[0],m=i.uf(t);null!=a&&(f=i.uf(a));for(var v,g=function(t){var n=m[t],r=i.pf((function(){return e(n,h)}));if(null==a)d=r[0],h=r[1];else{var o=i.pf((function(){var e=f[t],n=i.hf(i.Ee(e),e);return{output:i.nd(i.ye(r[0],e),i.ye(h[0],n)),newStates:h.map((function(t,a){return i.nd(i.ye(r[1][a],e),i.ye(t,n))}))}}));d=o.output,h=o.newStates}c&&p.push(d)},y=0;y1&&void 0!==arguments[1]&&arguments[1];Object(i.pf)((function(){if(!t.stateful)throw new sa("Cannot call resetStates() on an RNN Layer that is not stateful.");var r=t.inputSpec[0].shape[0];if(null==r)throw new ua("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==t.states_)Array.isArray(t.cell.stateSize)?t.states_=t.cell.stateSize.map((function(e){return i.Bf([r,e])})):t.states_=[i.Bf([r,t.cell.stateSize])];else if(null==e)i.Pd(t.states_),null!=t.keptStates&&(i.Pd(t.keptStates),t.keptStates=[]),Array.isArray(t.cell.stateSize)?t.states_=t.cell.stateSize.map((function(e){return i.Bf([r,e])})):t.states_[0]=i.Bf([r,t.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==t.states_.length)throw new ua("Layer ".concat(t.name," expects ").concat(t.states_.length," state(s), ")+"but it received ".concat(e.length," state value(s). Input ")+"received: ".concat(e));!0===n?t.keptStates.push(t.states_.slice()):i.Pd(t.states_);for(var a=0;a1?hi(n,[1,e]):n})):t.cell.stateSize>1?[hi(n,[1,t.cell.stateSize])]:[n]}))}},{key:"trainableWeights",get:function(){return this.trainable?this.cell.trainableWeights:[]}},{key:"nonTrainableWeights",get:function(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}},{key:"setFastWeightInitDuringBuild",value:function(e){Object(Eo.a)(Object(na.a)(n.prototype),"setFastWeightInitDuringBuild",this).call(this,e),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(e)}},{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(t.numConstants=this.numConstants);var r=this.cell.getConfig();return this.getClassName()===n.className&&(t.cell={className:this.cell.getClassName(),config:r}),Object.assign({},r,e,t)}}],[{key:"fromConfig",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.cell,a=Ao(r,n);return new e(Object.assign(t,{cell:a}))}}]),n}(lo);tu.className="RNN",i.Se.registerClass(tu);var nu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return n}(lo),ru=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,e)).DEFAULT_ACTIVATION="tanh",r.DEFAULT_KERNEL_INITIALIZER="glorotNormal",r.DEFAULT_RECURRENT_INITIALIZER="orthogonal",r.DEFAULT_BIAS_INITIALIZER="zeros",r.units=e.units,Ca(r.units,"units"),r.activation=gc(null==e.activation?r.DEFAULT_ACTIVATION:e.activation),r.useBias=null==e.useBias||e.useBias,r.kernelInitializer=Gi(e.kernelInitializer||r.DEFAULT_KERNEL_INITIALIZER),r.recurrentInitializer=Gi(e.recurrentInitializer||r.DEFAULT_RECURRENT_INITIALIZER),r.biasInitializer=Gi(e.biasInitializer||r.DEFAULT_BIAS_INITIALIZER),r.kernelRegularizer=Sc(e.kernelRegularizer),r.recurrentRegularizer=Sc(e.recurrentRegularizer),r.biasRegularizer=Sc(e.biasRegularizer),r.kernelConstraint=Ba(e.kernelConstraint),r.recurrentConstraint=Ba(e.recurrentConstraint),r.biasConstraint=Ba(e.biasConstraint),r.dropout=ri([1,ai([0,null==e.dropout?0:e.dropout])]),r.recurrentDropout=ri([1,ai([0,null==e.recurrentDropout?0:e.recurrentDropout])]),r.stateSize=r.units,r.dropoutMask=null,r.recurrentDropoutMask=null,r}return Object($r.a)(n,[{key:"build",value:function(e){e=Ji(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}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){if(2!==(e=e).length)throw new ua("SimpleRNNCell expects 2 input Tensors, got ".concat(e.length,"."));var r=e[1];e=e[0];var a,o=null!=t.training&&t.training;02&&void 0!==arguments[2]?arguments[2]:{},a=[],i=Object(ea.a)(t.cells);try{for(i.s();!(n=i.n()).done;){var o=n.value;a.push(Ao(o,r))}}catch(s){i.e(s)}finally{i.f()}return new e({cells:a})}}]),n}(nu);function lu(e){var t=e.ones,n=e.rate,r=e.training,a=void 0!==r&&r,o=e.count,s=void 0===o?1:o,c=function(){return ki(t(),n)},u=function(){return wi(c,t,a)};return!s||s<=1?i.he(u().clone()):Array(s).fill(void 0).map(u).map((function(e){return i.he(e.clone())}))}uu.className="StackedRNNCells",i.Se.registerClass(uu);var du=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);a1&&void 0!==arguments[1]&&arguments[1];i.pf((function(){if(!t.stateful)throw new sa("Cannot call resetStates() on an RNN Layer that is not stateful.");var r=t.inputSpec[0].shape,a=t.computeSingleOutputShape(r),o=[a[0]].concat(Object(Vn.a)(a.slice(2)));if(null==r[0])throw new ua("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==t.getStates())Array.isArray(t.cell.stateSize)?t.states_=t.cell.stateSize.map((function(){return i.Bf(o)})):t.states_=[i.Bf(o)];else if(null==e)i.Pd(t.states_),null!=t.keptStates&&(i.Pd(t.keptStates),t.keptStates=[]),Array.isArray(t.cell.stateSize)?t.states_=t.cell.stateSize.map((function(){return i.Bf(o)})):t.states_[0]=i.Bf(o);else{if(Array.isArray(e)||(e=[e]),e.length!==t.states_.length)throw new ua("Layer ".concat(t.name," expects ").concat(t.states_.length," state(s), ")+"but it received ".concat(e.length," state value(s). Input ")+"received: ".concat(e));n?t.keptStates.push(t.states_.slice()):i.Pd(t.states_);for(var s=0;s1){for(var a=[0],o=2;o1)throw new ua("Can not merge tensors with different batch sizes. "+"Got tensors with shapes: ".concat(JSON.stringify(e),"."));for(var i=null==e[0]?null:e[0].slice(1),o=1;o1){var O=ii(1,b).concat([0]);t.push(i.sf(h,O)),f=!0}else t.push(h)}}catch(I){p.e(I)}finally{p.f()}var x=n.mergeFunction(t),k=x.rank;if(f)if(null==k){var w=x.shape,j=w[w.length-1],S=[j].concat(w.slice(0,w.length-1));x=i.Ne(i.sf(i.Ne(x,[-1,j]),[1,0]),S)}else if(k>1){var N=[k-1].concat(ii(0,k-1));x=i.sf(x,N)}return x}return n.mergeFunction(e)}))}},{key:"computeOutputShape",value:function(e){var t;t=null==(e=e)[0]?null:e[0].slice(1);for(var n=1;n1)throw new ua("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}}},{key:"mergeFunction",value:function(e){var t=this;return Object(i.pf)((function(){return fi(e,t.axis)}))}},{key:"computeOutputShape",value:function(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new ua("A `Concatenate` layer should be called on a list of inputs.");var t,n=e,r=n[0].slice(),a=this.axis<0?r.length+this.axis:this.axis,i=Object(ea.a)(n.slice(1));try{for(i.s();!(t=i.n()).done;){var o=t.value;if(null==r[a]||null==o[a]){r[a]=null;break}r[a]+=o[a]}}catch(s){i.e(s)}finally{i.f()}return r}},{key:"computeMask",value:function(e,t){var n=this;if(null==t)return null;if(!Array.isArray(t))throw new ua("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new ua("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new ua("Mismatch in the length of mask (".concat(t.length,") ")+"and the legnth of inputs (".concat(e.length,")"));return i.pf((function(){var r=!0;if(t.forEach((function(e){null==e||(r=!1)})),r)return null;for(var a=[],o=0;o3||n.length>3)throw new la("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 ua("Dimension incompatibility: "+"".concat(t[r[0]]," !== ").concat(n[r[1]]))}},{key:"mergeFunction",value:function(e){if(2!==e.length)throw new ua("A `Dot` layer must be called on exactly 2 inputs, "+"but received ".concat(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 Ru(t,e[n].shape.length)})):[Ru(this.axes,n.shape.length),Ru(this.axes,r.shape.length)],this.normalize&&(n=Ro(n,t[0]),r=Ro(r,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new la("batchDot is not implemented for tensors of 4D or higher rank yet");if(i.wf.assert(e.shape.length>=2,(function(){return"batchDot requires the rank of x to be >= 2, "+"but got ".concat(e.shape.length)})),i.wf.assert(e.shape.length>=2,(function(){return"batchDot requires the rank of y to be >= 2, "+"but got ".concat(t.shape.length)})),"number"===typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new la("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 o=n;return i.pf((function(){var n,s;if(r>a){n=r-a;for(var c=[],u=0;ur){n=a-r;for(var l=[],d=0;d0){for(var h,b=[],m=h=r>a?r+a-3:r-1;m3||n.length>3)throw new la("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}},{key:"computeMask",value:function(e,t){return null}},{key:"getConfig",value:function(){var e={axes:this.axes,normalize:this.normalize},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(Su);Fu.className="Dot",i.Se.registerClass(Fu);var Du=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,e)).supportsMasking=!0,r.stddev=e.stddev,r}return Object($r.a)(n,[{key:"computeOutputShape",value:function(e){return e}},{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this),t={stddev:this.stddev};return Object.assign(t,e),t}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){n.invokeCallHook(e,t);var r=Zi(e);return wi((function(){return Object(i.nd)(bi(r.shape,0,n.stddev),r)}),(function(){return r}),t.training||!1)}))}}]),n}(lo);Du.className="GaussianNoise",i.Se.registerClass(Du);var _u=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,e)).supportsMasking=!0,r.rate=e.rate,r}return Object($r.a)(n,[{key:"computeOutputShape",value:function(e){return e}},{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this),t={rate:this.rate};return Object.assign(t,e),t}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){n.invokeCallHook(e,t);var r=Zi(e);if(n.rate>0&&n.rate<1){return wi((function(){var e=Math.sqrt(n.rate/(1-n.rate));return Object(i.ye)(r,bi(r.shape,1,e))}),(function(){return r}),t.training||!1)}return r}))}}]),n}(lo);_u.className="GaussianDropout",i.Se.registerClass(_u);var Mu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,e)).supportsMasking=!0,r.rate=e.rate,r.noiseShape=e.noiseShape,r}return Object($r.a)(n,[{key:"_getNoiseShape",value:function(e){return this.noiseShape||Zi(e).shape}},{key:"computeOutputShape",value:function(e){return e}},{key:"getConfig",value:function(){var e=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this),t={rate:this.rate};return Object.assign(t,e),t}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){if(n.rate<1&&n.rate>0){var r=n._getNoiseShape(e);return wi((function(){var t=Zi(e),a=-1.7580993408473766,o=Object(i.ee)(Object(i.Je)(r),n.rate);o=oi(o,"float32");var s=Math.pow((1-n.rate)*(1+n.rate*Math.pow(a,2)),-.5),c=-s*a*n.rate,u=Object(i.nd)(Object(i.ye)(t,o),Object(i.ye)(Object(i.nd)(o,-1),a));return Object(i.nd)(Object(i.ye)(u,s),c)}),(function(){return Zi(e)}),t.training||!1)}return e}))}}]),n}(lo);function zu(e,t,n,r,a){var o,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:.001;if(2===e.rank)o=i.vd(e,t,n,r,a,s);else if(3===e.rank)o=i.wd(e,t,n,r,a,s);else{if(4!==e.rank)throw new la("batchNormalization is not implemented for array of rank ".concat(e.rank," ")+"yet");o=i.xd(e,t,n,r,a,s)}return o}function Lu(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.001;return Object(i.pf)((function(){var o=i.xe(e,r),s=o.mean,c=o.variance;return[zu(e,s,c,n,t,a),s,c]}))}function Pu(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.001;return Object(i.pf)((function(){var o,s=i.xe(e,r),c=s.mean,u=s.variance,l=[],d=Object(ea.a)(ii(0,e.rank));try{for(d.s();!(o=d.n()).done;){var f=o.value;-1!==r.indexOf(f)?l.push(1):l.push(e.shape[f])}}catch(v){d.e(v)}finally{d.f()}var p=Object(i.Ne)(c,l),h=Object(i.Ne)(u,l),b=null==t?null:Object(i.Ne)(t,l),m=null==n?null:Object(i.Ne)(n,l);return[zu(e,p,h,m,b,a),c,u]}))}Mu.className="AlphaDropout",i.Se.registerClass(Mu);var Bu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),null==e&&(e={}),(r=t.call(this,e)).supportsMasking=!0,r.axis=null==e.axis?-1:e.axis,r.momentum=null==e.momentum?.99:e.momentum,r.epsilon=null==e.epsilon?.001:e.epsilon,r.center=null==e.center||e.center,r.scale=null==e.scale||e.scale,r.betaInitializer=Gi(e.betaInitializer||"zeros"),r.gammaInitializer=Gi(e.gammaInitializer||"ones"),r.movingMeanInitializer=Gi(e.movingMeanInitializer||"zeros"),r.movingVarianceInitializer=Gi(e.movingVarianceInitializer||"ones"),r.betaConstraint=Ba(e.betaConstraint),r.gammaConstraint=Ba(e.gammaConstraint),r.betaRegularizer=Sc(e.betaRegularizer),r.gammaRegularizer=Sc(e.gammaRegularizer),r}return Object($r.a)(n,[{key:"build",value:function(e){e=Ji(e);var t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(null==n)throw new ua("Axis ".concat(t," of input tensor should have a defined dimension but ")+"the layer received an input with shape "+"".concat(JSON.stringify(e),"."));this.inputSpec=[new io({ndim:e.length,axes:Object(Rc.a)({},t,n)})];var r=[n];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){var r=null!=t.training&&t.training,a=Zi(e),s=a.shape,c=s.length,u=ii(0,c),l=n.axis>=0?n.axis:n.axis+c;u.splice(l,1);var d=fa(1,c);d[l]=s[l];var f=u.slice();f.sort();var p=!i.wf.arraysEqual(f,ii(0,c).slice(0,c-1));if(!r)return function(){if(p){var e=Object(i.Ne)(n.movingMean.read(),d),t=Object(i.Ne)(n.movingVariance.read(),d),r=n.center?Object(i.Ne)(n.beta.read(),d):null,o=n.scale?Object(i.Ne)(n.gamma.read(),d):null;return zu(a,e,t,r,o,n.epsilon)}return zu(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=function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.001;return i.wf.arraysEqual(r.slice().sort(),ii(0,e.rank-1))?Lu(e,t,n,r,a):Pu(e,t,n,r,a)}(a,n.gamma.read(),n.beta.read(),u,n.epsilon),b=Object(o.a)(h,3),m=b[0],v=b[1],g=b[2],y=function(e,t,n){i.pf((function(){var r=1-n,a=e.read(),o=i.ye(i.hf(a,t),r);e.write(i.hf(a,o))}))};return y(n.movingMean,v,n.momentum),y(n.movingVariance,g,n.momentum),m}))}},{key:"getConfig",value:function(){var e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Hi(this.betaInitializer),gammaInitializer:Hi(this.gammaInitializer),movingMeanInitializer:Hi(this.movingMeanInitializer),movingVarianceInitializer:Hi(this.movingVarianceInitializer),betaRegularizer:wc(this.betaRegularizer),gammaRegularizer:wc(this.gammaRegularizer),betaConstraint:La(this.betaConstraint),gammaConstraint:La(this.gammaConstraint)},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(lo);Bu.className="BatchNormalization",i.Se.registerClass(Bu);var Wu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),null==e&&(e={}),(r=t.call(this,e)).axis=null==e.axis?-1:e.axis,"number"===typeof r.axis){if(!Number.isInteger(r.axis))throw new Error("Expected axis to be an integer, but received ".concat(r.axis))}else{if(!Array.isArray(r.axis))throw new Error("Expected axis to be an integer or an array of integers, "+"but received ".concat(JSON.stringify(r.axis)));var a,i=Object(ea.a)(r.axis);try{for(i.s();!(a=i.n()).done;){var o=a.value;if(!Number.isInteger(o))throw new Error("Expected axis to be an array of integers, "+"but received ".concat(JSON.stringify(r.axis)))}}catch(s){i.e(s)}finally{i.f()}}return r.epsilon=null==e.epsilon?.001:e.epsilon,r.center=null==e.center||e.center,r.scale=null==e.scale||e.scale,r.betaInitializer=Gi(e.betaInitializer||"zeros"),r.gammaInitializer=Gi(e.gammaInitializer||"ones"),r.betaRegularizer=Sc(e.betaRegularizer),r.gammaRegularizer=Sc(e.gammaRegularizer),r.supportsMasking=!0,r}return Object($r.a)(n,[{key:"build",value:function(e){var t=(e=Ji(e)).length;"number"===typeof this.axis&&(this.axis=[this.axis]);for(var n=0;n=t)throw new Error("Invalid axis: ".concat(i))}}catch(s){a.e(s)}finally{a.f()}if(this.axis.length!==ja(this.axis).length)throw new Error("Found duplicate axes in: ".concat(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}},{key:"call",value:function(e,t){var n=this,r=Zi(e),a=r.shape,o=a.length;return Object(i.pf)((function(){var e,t=Object(i.xe)(r,n.axis,!0),s=t.mean,c=t.variance,u=fa(1,o),l=Object(ea.a)(n.axis);try{for(l.s();!(e=l.n()).done;){var d=e.value;u[d]=a[d]}}catch(g){l.e(g)}finally{l.f()}for(var f=function(e){return null!=e&&e.shape.length!==o&&n.axis!==[o-1]?i.Ne(e,u):e},p=f(n.gamma.read()),h=f(n.beta.read()),b=[],m=[],v=0;v=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]])}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){return t=Zi(e),r=n.padding,a=n.dataFormat,Object(i.pf)((function(){if(4!==t.rank)throw new ua("temporalPadding expects input tensor to be 4-D, but received a "+"".concat(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 ua("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 ua("Unknown data format: ".concat(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]],i.Fe(t,e)}));var t,r,a}))}},{key:"getConfig",value:function(){var e={padding:this.padding,dataFormat:this.dataFormat},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(lo);function Vu(e,t,n,r,a,o){return Object(i.pf)((function(){var s;Ka(a),Ya(o),Xa(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==o&&(o="max"),e=Mc(e,a);var c="same"===r?"same":"valid";return s="max"===o?i.re(e,t,n,c):i.rd(e,t,n,c),"channelsFirst"===a&&(s=i.sf(s,[0,3,1,2])),s}))}function Hu(e,t,n,r,a,o){return Object(i.pf)((function(){var s;Ka(a),Ya(o),Xa(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==o&&(o="max"),e=zc(e,a);var c="same"===r?"same":"valid";return s="max"===o?i.se(e,t,n,c):i.sd(e,t,n,c),"channelsFirst"===a&&(s=i.sf(s,[0,4,1,2,3])),s}))}Uu.className="ZeroPadding2D",i.Se.registerClass(Uu);var Gu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),null==e.poolSize&&(e.poolSize=2),r=t.call(this,e),"number"===typeof e.poolSize)r.poolSize=[e.poolSize];else{if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!==typeof e.poolSize[0])throw new ua("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+"".concat(JSON.stringify(e.poolSize)));r.poolSize=e.poolSize}if(Ca(r.poolSize,"poolSize"),null==e.strides)r.strides=r.poolSize;else if("number"===typeof e.strides)r.strides=[e.strides];else{if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!==typeof e.strides[0])throw new ua("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+"".concat(JSON.stringify(e.strides)));r.strides=e.strides}return Ca(r.strides,"strides"),r.padding=null==e.padding?"valid":e.padding,Xa(r.padding),r.inputSpec=[new io({ndim:3})],r}return Object($r.a)(n,[{key:"computeOutputShape",value:function(e){var t=Dc((e=Ji(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){n.invokeCallHook(e,t),e=si(Zi(e),2);var r=n.poolingFunction(Zi(e),[n.poolSize[0],1],[n.strides[0],1],n.padding,"channelsLast");return i.ff(r,[2])}))}},{key:"getConfig",value:function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(lo),qu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,e)}return Object($r.a)(n,[{key:"poolingFunction",value:function(e,t,n,r,a){return Ka(a),Xa(r),Vu(e,t,n,r,a,"max")}}]),n}(Gu);qu.className="MaxPooling1D",i.Se.registerClass(qu);var Ku=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,e)}return Object($r.a)(n,[{key:"poolingFunction",value:function(e,t,n,r,a){return Ka(a),Xa(r),Vu(e,t,n,r,a,"avg")}}]),n}(Gu);Ku.className="AveragePooling1D",i.Se.registerClass(Ku);var Xu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),null==e.poolSize&&(e.poolSize=[2,2]),(r=t.call(this,e)).poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)r.strides=r.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new ua("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length "+"".concat(e.strides.length,"."));r.strides=e.strides}else r.strides=[e.strides,e.strides];return Ca(r.poolSize,"poolSize"),Ca(r.strides,"strides"),r.padding=null==e.padding?"valid":e.padding,r.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ka(r.dataFormat),Xa(r.padding),r.inputSpec=[new io({ndim:4})],r}return Object($r.a)(n,[{key:"computeOutputShape",value:function(e){e=Ji(e);var t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=Dc(t,this.poolSize[0],this.padding,this.strides[0]),n=Dc(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){return n.invokeCallHook(e,t),n.poolingFunction(Zi(e),n.poolSize,n.strides,n.padding,n.dataFormat)}))}},{key:"getConfig",value:function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(lo),Yu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,e)}return Object($r.a)(n,[{key:"poolingFunction",value:function(e,t,n,r,a){return Ka(a),Xa(r),Vu(e,t,n,r,a,"max")}}]),n}(Xu);Yu.className="MaxPooling2D",i.Se.registerClass(Yu);var $u=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,e)}return Object($r.a)(n,[{key:"poolingFunction",value:function(e,t,n,r,a){return Ka(a),Xa(r),Vu(e,t,n,r,a,"avg")}}]),n}(Xu);$u.className="AveragePooling2D",i.Se.registerClass($u);var Qu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;if(Object(Yr.a)(this,n),null==e.poolSize&&(e.poolSize=[2,2,2]),(r=t.call(this,e)).poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)r.strides=r.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new ua("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length "+"".concat(e.strides.length,"."));r.strides=e.strides}else r.strides=[e.strides,e.strides,e.strides];return Ca(r.poolSize,"poolSize"),Ca(r.strides,"strides"),r.padding=null==e.padding?"valid":e.padding,r.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ka(r.dataFormat),Xa(r.padding),r.inputSpec=[new io({ndim:5})],r}return Object($r.a)(n,[{key:"computeOutputShape",value:function(e){e=Ji(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=Dc(t,this.poolSize[0],this.padding,this.strides[0]),n=Dc(n,this.poolSize[1],this.padding,this.strides[1]),r=Dc(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]]}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){return n.invokeCallHook(e,t),n.poolingFunction(Zi(e),n.poolSize,n.strides,n.padding,n.dataFormat)}))}},{key:"getConfig",value:function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(lo),Zu=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,e)}return Object($r.a)(n,[{key:"poolingFunction",value:function(e,t,n,r,a){return Ka(a),Xa(r),Hu(e,t,n,r,a,"max")}}]),n}(Qu);Zu.className="MaxPooling3D",i.Se.registerClass(Zu);var Ju=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,e)}return Object($r.a)(n,[{key:"poolingFunction",value:function(e,t,n,r,a){return Ka(a),Xa(r),Hu(e,t,n,r,a,"avg")}}]),n}(Qu);Ju.className="AveragePooling3D",i.Se.registerClass(Ju);var el=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,e)).inputSpec=[new io({ndim:3})],r}return Object($r.a)(n,[{key:"computeOutputShape",value:function(e){return[e[0],e[2]]}},{key:"call",value:function(e,t){throw new la}}]),n}(lo),tl=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,e||{})}return Object($r.a)(n,[{key:"call",value:function(e,t){return Object(i.pf)((function(){var t=Zi(e);return i.ue(t,1)}))}}]),n}(el);tl.className="GlobalAveragePooling1D",i.Se.registerClass(tl);var nl=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){return Object(Yr.a)(this,n),t.call(this,e||{})}return Object($r.a)(n,[{key:"call",value:function(e,t){return Object(i.pf)((function(){var t=Zi(e);return i.qe(t,1)}))}}]),n}(el);nl.className="GlobalMaxPooling1D",i.Se.registerClass(nl);var rl=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,e)).dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,Ka(r.dataFormat),r.inputSpec=[new io({ndim:4})],r}return Object($r.a)(n,[{key:"computeOutputShape",value:function(e){return e=e,"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}},{key:"call",value:function(e,t){throw new la}},{key:"getConfig",value:function(){var e={dataFormat:this.dataFormat},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}}]),n}(lo),al=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){var t=Zi(e);return"channelsLast"===n.dataFormat?i.ue(t,[1,2]):i.ue(t,[2,3])}))}}]),n}(rl);al.className="GlobalAveragePooling2D",i.Se.registerClass(al);var il=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){return Object(Yr.a)(this,n),t.apply(this,arguments)}return Object($r.a)(n,[{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){var t=Zi(e);return"channelsLast"===n.dataFormat?i.qe(t,[1,2]):i.qe(t,[2,3])}))}}]),n}(rl);il.className="GlobalMaxPooling2D",i.Se.registerClass(il);var ol=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,e)).layer=e.layer,r}return Object($r.a)(n,[{key:"build",value:function(e){this.built=!0}},{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}},{key:"getWeights",value:function(){return this.layer.getWeights()}},{key:"setWeights",value:function(e){this.layer.setWeights(e)}},{key:"getConfig",value:function(){var e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},t=Object(Eo.a)(Object(na.a)(n.prototype),"getConfig",this).call(this);return Object.assign(e,t),e}},{key:"setFastWeightInitDuringBuild",value:function(e){Object(Eo.a)(Object(na.a)(n.prototype),"setFastWeightInitDuringBuild",this).call(this,e),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e)}}],[{key:"fromConfig",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.layer,a=Ao(r,n);delete t.layer;var i={layer:a};return Object.assign(i,t),new e(i)}}]),n}(lo),sl=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;return Object(Yr.a)(this,n),(r=t.call(this,e)).supportsMasking=!0,r}return Object($r.a)(n,[{key:"build",value:function(e){if((e=Ji(e)).length<3)throw new ua("TimeDistributed layer expects an input shape >= 3D, but received "+"input shape ".concat(JSON.stringify(e)));this.inputSpec=[{shape:e}];var t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),Object(Eo.a)(Object(na.a)(n.prototype),"build",this).call(this,e)}},{key:"computeOutputShape",value:function(e){var t=[(e=Ji(e))[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))}},{key:"call",value:function(e,t){var n=this;return Object(i.pf)((function(){return eu((function(e,r){return[Zi(n.layer.call(e,t)),[]]}),e=Zi(e),[],!1,null,null,!1,!0)[1]}))}}]),n}(ol);sl.className="TimeDistributed",i.Se.registerClass(sl);var cl=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r;Object(Yr.a)(this,n),r=t.call(this,e);var a=e.layer.getConfig(),i={};i.className=e.layer.getClassName(),i.config=a,r.forwardLayer=Ao(i),a.goBackwards=!0!==a.goBackwards;var o,s={};if(s.className=e.layer.getClassName(),s.config=a,r.backwardLayer=Ao(s),r.forwardLayer.name="forward_"+r.forwardLayer.name,r.backwardLayer.name="backward_"+r.backwardLayer.name,r.mergeMode=void 0===e.mergeMode?"concat":e.mergeMode,o=r.mergeMode,Na(Ga,"BidirectionalMergeMode",o),e.weights)throw new la("weights support is not implemented for Bidirectional layer yet.");return r._stateful=e.layer.stateful,r.returnSequences=e.layer.returnSequences,r.returnState=e.layer.returnState,r.supportsMasking=!0,r._trainable=!0,r.inputSpec=e.layer.inputSpec,r.numConstants=null,r}return Object($r.a)(n,[{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:"getWeights",value:function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}},{key:"setWeights",value:function(e){var t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))}},{key:"computeOutputShape",value:function(e){var t,n,r,a=this.forwardLayer.computeOutputShape(e);return Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),a=a,this.returnState?(r=a.slice(1),t=a[0]):t=a[0],t=t,"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()):ba(n)}},{key:"apply",value:function(e,t){var r=null==t?null:t.initialState,a=null==t?null:t.constants;null==t&&(t={});var i=Jc(e,r,a,this.numConstants);if(e=i.inputs,r=i.initialState,a=i.constants,Array.isArray(e)&&(r=e.slice(1),e=e[0]),(null==r||0===r.length)&&null==a)return Object(Eo.a)(Object(na.a)(n.prototype),"apply",this).call(this,e,t);var o=[],s=[];if(null!=r){var c=r.length;if(c%2>0)throw new ua("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=r,o.push.apply(o,Object(Vn.a)(r));var u=r.map((function(e){return new io({shape:e.shape})}));this.forwardLayer.stateSpec=u.slice(0,c/2),this.backwardLayer.stateSpec=u.slice(c/2),s.push.apply(s,Object(Vn.a)(u))}if(null!=a)throw new la("Support for constants in Bidirectional layers is not implemented yet.");for(var l=o[0]instanceof oo,d=0,f=o;d2&&void 0!==arguments[2]?arguments[2]:"";if("number"!==typeof e&&"number"!==typeof t){i.wf.assert(e.length===t.length,(function(){return n+" Shapes ".concat(e," and ").concat(t," must match")}));for(var r=0;r=0&&i>=0&&a!==i)throw new Error("Incompatible shape during merge: ".concat(e," vs. ").concat(t));n[r]=a>=0?a:i}return n}var xl=function(){function e(t,n,r,a,o,s,c){Object(Yr.a)(this,e),this.name=t,this.dtype=n,this.maxSize=r,this.elementShape=a,this.identicalElementShapes=o,this.dynamicSize=s,this.clearAfterRead=c,this.tensors=[],this.closed_=!1,this.idTensor=Object(i.Pe)(0),Object(i.he)(this.idTensor)}return Object($r.a)(e,[{key:"id",get:function(){return this.idTensor.id}},{key:"closed",get:function(){return this.closed_}},{key:"clearAndClose",value: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()}},{key:"size",value:function(){return this.tensors.length}},{key:"read",value:function(e){if(this.closed_)throw new Error("TensorArray ".concat(this.name," has already been closed."));if(e<0||e>=this.size())throw new Error("Tried to read from index ".concat(e,", but array size is: ").concat(this.size()));var t=this.tensors[e];if(t.cleared)throw new Error("TensorArray ".concat(this.name,": Could not read index ").concat(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}},{key:"readMany",value:function(e){var t=this;return e.map((function(e){return t.read(e)}))}},{key:"write",value:function(e,t){if(this.closed_)throw new Error("TensorArray ".concat(this.name," has already been closed."));if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error("Tried to write to index ".concat(e,", but array is not resizeable and size is: ").concat(this.maxSize));var n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error("TensorArray ".concat(this.name,": Could not write to TensorArray index ").concat(e,",\n because the value dtype is ").concat(t.dtype,", but TensorArray dtype is ").concat(this.dtype,"."));if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),vl(this.elementShape,t.shape,"TensorArray ".concat(this.name,": Could not write to TensorArray index ").concat(e,".")),n.read)throw new Error("TensorArray ".concat(this.name,": Could not write to TensorArray index ").concat(e,", because it has already been read."));if(n.written)throw new Error("TensorArray ".concat(this.name,": Could not write to TensorArray index ").concat(e,", because it has already been written."));n.tensor=t,Object(i.he)(t),n.written=!0,this.tensors[e]=n}},{key:"writeMany",value:function(e,t){var n=this;if(e.length!==t.length)throw new Error("TensorArray ".concat(this.name,": could not write multiple tensors,")+"because the index size: ".concat(e.length," is not the same as tensors size: ").concat(t.length,"."));e.forEach((function(e,r){return n.write(e,t[r])}))}},{key:"gather",value:function(e,t){if(t&&t!==this.dtype)throw new Error("TensorArray dtype is ".concat(this.dtype," but gather requested dtype ").concat(t));if(e)e=e.slice(0,this.size());else{e=[];for(var n=0;n=this.maxSize)throw new Error("Max index must be < array size (".concat(n," vs. ").concat(this.maxSize,")"));this.writeMany(e,Object(i.uf)(t,0))}},{key:"split",value:function(e,t){var n=this;if(t.dtype!==this.dtype)throw new Error("TensorArray dtype is ".concat(this.dtype," but tensor has dtype ").concat(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 ".concat(r,", and tensor's shape is: ").concat(t.shape));if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error("TensorArray's size is not equal to the size of lengths (".concat(this.maxSize," vs. ").concat(e.length,"), ")+"and the TensorArray is not marked as dynamically resizeable");var o=0===r?0:t.size/r,s=[];Object(i.pf)((function(){t=Object(i.Ne)(t,[1,r,o]);for(var c=0;c3&&void 0!==arguments[3]?arguments[3]:-1;Object(Yr.a)(this,e),this.tensors=t,this.elementShape=n,this.elementDtype=r,null!=t&&t.forEach((function(e){if(r!==e.dtype)throw new Error("Invalid data types; op elements ".concat(r,", but list elements ").concat(e.dtype));vl(n,e.shape,"TensorList shape mismatch: "),Object(i.he)(e)})),this.idTensor=Object(i.Pe)(0),this.maxNumElements=a,Object(i.he)(this.idTensor)}return Object($r.a)(e,[{key:"id",get:function(){return this.idTensor.id}},{key:"copy",value:function(){return new e(Object(Vn.a)(this.tensors),this.elementShape,this.elementDtype)}},{key:"clearAndClose",value:function(e){this.tensors.forEach((function(t){null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()}},{key:"size",value:function(){return this.tensors.length}},{key:"stack",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;if(t!==this.elementDtype)throw new Error("Invalid data types; op elements ".concat(t,", but list elements ").concat(this.elementDtype));if(-1!==r&&this.tensors.length!==r)throw new Error("Operation expected a list with ".concat(r," elements but got a list with ").concat(this.tensors.length," elements."));vl(e,this.elementShape,"TensorList shape mismatch: ");var a=yl(this.elementShape,this.tensors,e);return Object(i.pf)((function(){var e=n.tensors.map((function(e){return Object(i.Ne)(e,a)}));return Object(i.gf)(e,0)}))}},{key:"popBack",value:function(e,t){if(t!==this.elementDtype)throw new Error("Invalid data types; op elements ".concat(t,", but list elements ").concat(this.elementDtype));if(0===this.size())throw new Error("Trying to pop from an empty list.");var n=yl(this.elementShape,this.tensors,e),r=this.tensors.pop();return vl(r.shape,e,"TensorList shape mismatch: "),Object(i.Ne)(r,n)}},{key:"pushBack",value:function(e){if(e.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements ".concat(e.dtype,", but list elements ").concat(this.elementDtype));if(vl(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");Object(i.he)(e),this.tensors.push(e)}},{key:"resize",value:function(e){if(e<0)throw new Error("TensorListResize expects size to be non-negative. Got: ".concat(e));if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error("TensorListResize input size ".concat(e," is greater maxNumElement ").concat(this.maxNumElements,"."));this.tensors.length=e}},{key:"getItem",value:function(e,t,n){if(n!==this.elementDtype)throw new Error("Invalid data types; op elements ".concat(n,", but list elements ").concat(this.elementDtype));if(e<0||e>this.tensors.length)throw new Error("Trying to access element ".concat(e," in a list with ").concat(this.tensors.length," elements."));if(null==this.tensors[e])throw new Error("element at index ".concat(e," is null."));vl(this.tensors[e].shape,t,"TensorList shape mismatch: ");var r=yl(this.elementShape,this.tensors,t);return Object(i.Ne)(this.tensors[e],r)}},{key:"setItem",value:function(e,t){if(t.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements ".concat(t.dtype,", but list elements ").concat(this.elementDtype));if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error("Trying to set element ".concat(e," in a list with max ").concat(this.maxNumElements," elements."));vl(this.elementShape,t.shape,"TensorList shape mismatch: "),Object(i.he)(t),this.tensors[e]=t}},{key:"gather",value:function(e,t,n){var r=this;if(t!==this.elementDtype)throw new Error("Invalid data types; op elements ".concat(t,", but list elements ").concat(this.elementDtype));vl(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());var a=yl(this.elementShape,this.tensors,n);return 0===e.length?Object(i.lf)([],[0].concat(a)):Object(i.pf)((function(){var t=e.map((function(e){return Object(i.Ne)(r.tensors[e],a)}));return Object(i.gf)(t,0)}))}},{key:"concat",value:function(e,t){var n=this;if(e&&e!==this.elementDtype)throw new Error("TensorList dtype is ".concat(this.elementDtype," but concat requested dtype ").concat(e));vl(this.elementShape,t,"TensorList shape mismatch: ");var r=yl(this.elementShape,this.tensors,t);return 0===this.size()?Object(i.lf)([],[0].concat(r)):Object(i.pf)((function(){var e=n.tensors.map((function(e){return Object(i.Ne)(e,r)}));return Object(i.Dd)(e,0)}))}}]),e}();function wl(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: ".concat(e.shape));if(e.dtype!==n)throw new Error("Invalid data types; op elements ".concat(e.dtype,", but list elements ").concat(n));vl(e.shape.slice(1),t,"TensorList shape mismatch: ");var a=Object(i.uf)(e);return new kl(a,t,r)}function jl(e,t,n){return new kl([],e,t,n)}function Sl(e,t,n,r){if(t.length!==e.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: ".concat(t.length," vs. ").concat(e.shape[0]));var a=Math.max.apply(Math,Object(Vn.a)(t));if(null!=r&&-1!==r&&a>=r)throw new Error("Max index must be < array size (".concat(a," vs. ").concat(r,")"));var o=new kl([],n,e.dtype,r),s=Object(i.uf)(e,0);return t.forEach((function(e,t){o.setItem(e,s[t])})),o}function Nl(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 ".concat(r,", and tensor's shape is: ").concat(e.shape));for(var o=Ol(e.shape.slice(1),n),s=0===r?0:e.size/r,c=Object(i.pf)((function(){var n=[];e=Object(i.Ne)(e,[1,r,s]);for(var c=0;c0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Object(Yr.a)(this,e),this.weightMap=t,this.tensorArrayMap=n,this.tensorListMap=r,this.functionMap=a,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}return Object($r.a)(e,[{key:"newFrame",value:function(e,t){return{id:e,frameName:t,iterationId:0}}},{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}},{key:"generateCurrentContextIds",value:function(){for(var e=[],t=0;t1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}},{key:"nextIteration",value: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))}},{key:"getWeight",value:function(e){return this.weightMap[e]}},{key:"addTensorArray",value:function(e){this.tensorArrayMap[e.id]=e}},{key:"getTensorArray",value:function(e){return this.tensorArrayMap[e]}},{key:"addTensorList",value:function(e){this.tensorListMap[e.id]=e}},{key:"getTensorList",value:function(e){return this.tensorListMap[e]}},{key:"dispose",value:function(e){for(var t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(var n in this.tensorListMap)this.tensorListMap[n].clearAndClose(e)}}]),e}();function td(e,t,n,r){var a=new Set,i=[],o=null,s=null,c=new Set,u=Object.keys(e).map((function(e){return Object(ll.g)(e)[0]})),l=[];null!=r&&(l=r.map((function(e){return Object(ll.g)(e.name)[0]})));for(var d=Object(Vn.a)(t);d.length>0;){var f=d.pop();(id(f)||od(f)||sd(f))&&null==o&&(s=(o=f).children.map((function(e){return e.name})).filter((function(e){return a.has(e)}))),a.add(f.name),null==n[f.name]&&(-1===u.indexOf(f.name)&&-1===l.indexOf(f.name)&&(0!==f.inputs.length?f.inputs.forEach((function(e){c.has(e.name)||(c.add(e.name),d.push(e))})):i.push(f.name)))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:i,dynamicNode:o,syncInputs:s}}var nd=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],rd=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],ad=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function id(e){return nd.indexOf(e.op)>=0}function od(e){return rd.indexOf(e.op)>=0}function sd(e){return ad.indexOf(e.op)>=0}var cd=function(){function e(t,n){var r=this;Object(Yr.a)(this,e),this.graph=t,this.parent=n,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this._outputs=t.outputs,this._inputs=t.inputs,this._initNodes=t.initNodes,this._signature=t.signature,this._functions=t.functions,null!=t.functions&&Object.keys(t.functions).forEach((function(n){r._functionExecutorMap[n]=new e(t.functions[n],r)}))}return Object($r.a)(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,Object(Vn.a)(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?"".concat(t,":").concat(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}),{})}},{key:"getCompilationKey",value: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.SEPERATOR)+"--"+r.join(this.SEPERATOR)}},{key:"compile",value:function(e,t){var n=td(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 '".concat(a.name,"', which has ")+"the dynamic op '".concat(a.op,"'. Please use ")+"model.executeAsync() instead. Alternatively, to avoid the "+"dynamic ops, specify the inputs [".concat(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 [".concat(o,"] from the provided inputs ")+"[".concat(s,"]. Missing the following inputs: [").concat(r,"]"))}return function(e,t,n){var r=n.usedNodes,a=n.inputs,i=[],o=Object.keys(a).map((function(e){return Object(ll.g)(e)[0]})).map((function(t){return e.nodes[t]})),s=e.initNodes;o.forEach((function(e){r.has(e.name)&&i.push(e)})),e.weights.forEach((function(e){r.has(e.name)&&i.push(e)})),null!=s&&s.forEach((function(e){r.has(e.name)&&i.push(e)}));for(var c=new Set,u=[];i.length>0;){var l=i.pop();c.add(l.name),t[l.name]||u.push(l),l.children.forEach((function(e){!c.has(e.name)&&r.has(e.name)&&e.inputs.every((function(e){return c.has(e.name)}))&&i.push(e)}))}return u}(this.graph,this.weightMap,n)}},{key:"execute",value:function(e,t){var n=this;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[Object(ll.g)(e)[0]]})),s=t.map((function(e){return Object(ll.g)(e)[0]})),c=s.map((function(e){return n.graph.nodes[e]}));0===c.length&&(c=this._outputs);var u=this.getCompilationKey(a,c),l=this.compiledMap.get(u);null==l&&(l=this.compile(e,c),this.compiledMap.set(u,l));var d={},f={};return Object(i.pf)((function(){var r=new ed(n.weightMap,d,f,n.functionExecutorMap),a=Object.assign({},n.weightMap);Object.keys(e).forEach((function(t){var n=Object(ll.g)(t),r=Object(o.a)(n,2),i=r[0],s=[];s[r[1]]=e[t],a[i]=s}));for(var c=n.getFrozenTensorIds(a),u={},p=0;p2&&void 0!==f[2]&&f[2],a=f.length>3&&void 0!==f[3]?f[3]:{},i=f.length>4&&void 0!==f[4]?f[4]:{},r||(t=this.mapInputs(t),this.checkInputs(t),this.checkInputShapeAndType(t),n=this.mapOutputs(n),this.checkOutputs(n)),o=new ed(this.weightMap,a,i,this.functionExecutorMap),e.next=7,this.executeWithControlFlow(t,o,n,r);case 7:return s=e.sent,c=n.map((function(e){return Object(ll.e)(e,s,o)})),u=c.map((function(e){return e.id})),l=Object.keys(t).map((function(e){return t[e].id})),d=new Set([].concat(Object(Vn.a)(u),Object(Vn.a)(l),Object(Vn.a)(this.weightIds))),Object.keys(s).forEach((function(e){s[e].forEach((function(e){!e||e.kept||e.isDisposed||d.has(e.id)||e.dispose()}))})),null==this.parent&&o.dispose(d),e.abrupt("return",c);case 15:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"executeFunctionAsync",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n,r){var a,i=this;return vo.a.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)}}()},{key:"executeWithControlFlow",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n,r,a){var i,s,c,u,l,d,f,p,h,b,m,v,g,y,O,x,k,w=this;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=Object.keys(t),s=i.map((function(e){return w.graph.nodes[Object(ll.g)(e)[0]]})),c=r.map((function(e){return Object(ll.g)(e)[0]})),0===(u=c.map((function(e){return w.graph.nodes[e]}))).length&&(u=this._outputs),l=td(t,u,this.weightMap,this._initNodes),d=l.usedNodes,f=l.missingInputs,p=l.dynamicNode,h=l.syncInputs,b=[].concat(Object(Vn.a)(s),Object(Vn.a)(this.graph.weights),Object(Vn.a)(this._initNodes||[])).map((function(e){return{node:e,contexts:n.currentContext}})),m=Object.assign({},this.weightMap),Object.keys(t).forEach((function(e){var n=Object(ll.g)(e),r=Object(o.a)(n,2),a=r[0],i=[];i[r[1]]=t[e],m[a]=i})),v={},g=this.getFrozenTensorIds(m),y={};case 12:if(!(b.length>0)){e.next=18;break}return O=this.processStack(s,b,n,m,y,g,c,v,d),e.next=16,Promise.all(O);case 16:e.next=12;break;case 18:if(null!=p||a||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."),!((x=u.filter((function(e){return!id(e)&&!Object(ll.e)(e.name,m,n)})).map((function(e){return e.name}))).length>0)){e.next=24;break}throw k="",null!=p&&(k="Alternatively, to avoid the dynamic ops, use model.execute() "+"and specify the inputs [".concat(h,"]")),new Error("Cannot compute the outputs [".concat(x,"] from the provided ")+"inputs [".concat(i,"]. Consider providing the following inputs: ")+"[".concat(f,"]. ").concat(k));case 24:return e.abrupt("return",m);case 25:case"end":return e.stop()}}),e,this)})));return function(t,n,r,a){return e.apply(this,arguments)}}()},{key:"processStack",value:function(e,t,n,r,a,s,c,u,l){for(var d=this,f=[],p=function(){var e=t.pop();n.currentContext=e.contexts;var p="";if("Enter"===e.node.op&&Object(ll.d)("isConstant",e.node,r,n)){var h=Object(ll.b)(e.node.name,n),b=Object(o.a)(h,1);p=b[0]}if(null==r[e.node.name]){var m=Jl(e.node,r,n,d._resourceManager);if(!p){var v=Object(ll.b)(e.node.name,n),g=Object(o.a)(v,1);p=g[0]}var y=n.currentContext;i.wf.isPromise(m)?f.push(m.then((function(i){return r[p]=i,n.currentContext=y,d.checkTensorForDisposal(p,e.node,r,n,s,c,u),d.processChildNodes(e.node,t,n,r,a,l),i}))):(r[p]=m,d.checkTensorForDisposal(p,e.node,r,n,s,c,u),d.processChildNodes(e.node,t,n,r,a,l))}else d.processChildNodes(e.node,t,n,r,a,l)};t.length>0;)p();return f}},{key:"processChildNodes",value:function(e,t,n,r,a,i){e.children.forEach((function(e){var s=Object(ll.b)(e.name,n),c=Object(o.a)(s,1)[0];!a[c]&&i.has(e.name)&&("Merge"===e.op?e.inputNames.some((function(e){return!!Object(ll.e)(e,r,n)}))&&(a[c]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((function(e){return!!Object(ll.e)(e,r,n)}))&&(a[c]=!0,t.push({contexts:n.currentContext,node:e})))}))}},{key:"dispose",value:function(){var e=this;Object.keys(this.weightMap).forEach((function(t){return e.weightMap[t].forEach((function(e){return e.dispose()}))}))}},{key:"checkInputShapeAndType",value:function(e){var t=this;Object.keys(e).forEach((function(n){var r=e[n],a=Object(ll.g)(n),s=Object(o.a)(a,1)[0],c=t.graph.nodes[s];if(c.attrParams.shape&&c.attrParams.shape.value){var u=c.attrParams.shape.value,l=u.length===r.shape.length&&r.shape.every((function(e,t){return-1===u[t]||u[t]===e}));i.wf.assert(l,(function(){return"The shape of dict['".concat(c.name,"'] provided in ")+"model.execute(dict) must be [".concat(u,"], but was ")+"[".concat(r.shape,"]")}))}c.attrParams.dtype&&c.attrParams.dtype.value&&i.wf.assert(r.dtype===c.attrParams.dtype.value,(function(){return"The dtype of dict['".concat(c.name,"'] provided in ")+"model.execute(dict) must be "+"".concat(c.attrParams.dtype.value,", but was ").concat(r.dtype)}))}))}},{key:"mapInputs",value:function(e){var t={};for(var n in e){if(null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n])t[this._signature.inputs[n].name]=e[n];else t[n]=e[n]}return t}},{key:"checkInputs",value:function(e){var t=this,n=Object.keys(e).filter((function(e){var n=Object(ll.g)(e),r=Object(o.a)(n,1)[0];return null==t.graph.nodes[r]}));if(n.length>0)throw new Error("The dict provided in model.execute(dict) has "+"keys: [".concat(n,"] that are not part of graph"))}},{key:"mapOutputs",value:function(e){var t=this;return e.map((function(e){return null!=t._signature&&null!=t._signature.outputs&&null!=t._signature.outputs[e]?t._signature.outputs[e].name:e}),{})}},{key:"checkOutputs",value:function(e){var t=this;e.forEach((function(e){var n=Object(ll.g)(e),r=Object(o.a)(n,1)[0];if(!t.graph.nodes[r])throw new Error("The output '".concat(e,"' is not found in the graph"))}))}}]),e}(),ud=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(Yr.a)(this,e),this.hashTableNameToHandle=t,this.hashTableMap=n}return Object($r.a)(e,[{key:"addHashTable",value:function(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}},{key:"getHashTableHandleByName",value:function(e){return this.hashTableNameToHandle[e]}},{key:"getHashTableById",value:function(e){return this.hashTableMap[e]}},{key:"dispose",value: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}(),ld="?tfjs-format=file",dd="model.json",fd=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(Yr.a)(this,e),this.modelUrl=t,this.loadOptions=n,this.version="n/a",null==n&&(this.loadOptions={}),this.resourceManager=new ud}return Object($r.a)(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:"findIOHandler",value:function(){var e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=i.ge.browserHTTPRequest(e,this.loadOptions);else{var t=i.ge.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(i.ge.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error("Found more than one (".concat(t.length,") load handlers for ")+"URL '".concat([e],"'"));this.handler=t[0]}}},{key:"load",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.findIOHandler(),null!=this.handler.load){e.next=3;break}throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");case 3:return e.next=5,this.handler.load();case 5:return t=e.sent,e.abrupt("return",this.loadSync(t));case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"loadSync",value:function(e){this.artifacts=e;var t,n=this.artifacts.modelTopology;t=null!=this.artifacts.userDefinedMetadata&&null!=this.artifacts.userDefinedMetadata.signature?this.artifacts.userDefinedMetadata.signature:this.artifacts.signature,this.signature=t,this.version="".concat(n.versions.producer,".").concat(n.versions.minConsumer);var r=i.ge.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new cd(ul.a.Instance.transformGraph(n,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){var a=ul.a.Instance.transformGraph(e.modelInitializer);this.initializer=new cd(a),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}},{key:"save",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!==typeof t){e.next=9;break}if(0!==(r=i.ge.getSaveHandlers(t)).length){e.next=6;break}throw new Error("Cannot find any save handlers for URL '".concat(t,"'"));case 6:if(!(r.length>1)){e.next=8;break}throw new Error("Found more than one (".concat(r.length,") save handlers for ")+"URL '".concat(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)}}()},{key:"predict",value:function(e,t){return this.execute(e,this.outputNodes)}},{key:"normalizeInputs",value:function(e){if(!(e instanceof i.bd)&&!Array.isArray(e))return e;if((e=Array.isArray(e)?e:[e]).length!==this.inputNodes.length)throw new Error("Input tensor count mismatch,"+"the graph model has ".concat(this.inputNodes.length," placeholders, ")+"while there are ".concat(e.length," input tensors."));return this.inputNodes.reduce((function(t,n,r){return t[n]=e[r],t}),{})}},{key:"normalizeOutputs",value:function(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}},{key:"execute",value:function(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);var n=this.executor.execute(e,t);return n.length>1?n:n[0]}},{key:"executeAsync",value:function(){var e=Object(go.a)(vo.a.mark((function e(t,n){var r;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.normalizeInputs(t),n=this.normalizeOutputs(n),e.next=4,this.executor.executeAsync(t,n);case 4:return r=e.sent,e.abrupt("return",r.length>1?r:r[0]);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"convertTensorMapToTensorsMap",value:function(e){return Object.keys(e).reduce((function(t,n){return t[n]=[e[n]],t}),{})}},{key:"dispose",value:function(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}]),e}();function pd(e){return hd.apply(this,arguments)}function hd(){return(hd=Object(go.a)(vo.a.mark((function e(t){var n,r,a=arguments;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=a.length>1&&void 0!==a[1]?a[1]:{},null!=t){e.next=3;break}throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");case 3:return null==n&&(n={}),n.fromTFHub&&null==t.load&&(t.endsWith("/")||(t+="/"),t="".concat(t).concat(dd).concat(ld)),r=new fd(t,n),e.next=8,r.load();case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var bd=n(109),md=n(67),vd=n(95),gd=function(){function e(){Object(Yr.a)(this,e),this.size=null}return Object($r.a)(e,[{key:"batch",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this;return i.wf.assert(e>0,(function(){return"batchSize needs to be positive, but it is\n ".concat(e)})),t=this.size===1/0||null==this.size?this.size:n?Math.ceil(this.size/e):Math.floor(this.size/e),yd(Object(go.a)(vo.a.mark((function t(){return vo.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.iterator();case 2:return t.abrupt("return",t.sent.columnMajorBatch(e,n,kd));case 3:case"end":return t.stop()}}),t)}))),t)}},{key:"concatenate",value: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,yd(Object(go.a)(vo.a.mark((function t(){return vo.a.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)}},{key:"filter",value:function(e){var t,n=this;return t=this.size===1/0?1/0:null,yd(Object(go.a)(vo.a.mark((function t(){return vo.a.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 i.pf((function(){return e(t)}))})));case 3:case"end":return t.stop()}}),t)}))),t)}},{key:"forEachAsync",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){return vo.a.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)}}()},{key:"map",value:function(e){var t=this;return yd(Object(go.a)(vo.a.mark((function n(){return vo.a.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 i.pf((function(){return e(t)}))})));case 3:case"end":return n.stop()}}),n)}))),this.size)}},{key:"mapAsync",value:function(e){var t=this;return yd(Object(go.a)(vo.a.mark((function n(){return vo.a.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)}},{key:"prefetch",value:function(e){if(null==e)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var t=this;return yd(Object(go.a)(vo.a.mark((function n(){return vo.a.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)}},{key:"repeat",value: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,yd(Object(go.a)(vo.a.mark((function t(){var r;return vo.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object(md.e)(Object(go.a)(vo.a.mark((function e(){return vo.a.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",Object(md.d)(r.take(e)));case 2:case"end":return t.stop()}}),t)}))),t)}},{key:"skip",value:function(e){var t,n=this;return t=null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size2&&void 0!==arguments[2])||arguments[2];if(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 (".concat(this.size," elements)"));var r=this,a=bd.alea(t||i.wf.now().toString());return yd(Object(go.a)(vo.a.mark((function t(){var i;return vo.a.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)}},{key:"take",value:function(e){var t,n=this;return t=null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null,yd(Object(go.a)(vo.a.mark((function t(){return vo.a.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)}},{key:"toArray",value:function(){var e=Object(go.a)(vo.a.mark((function e(){return vo.a.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)}}()},{key:"toArrayForTest",value:function(){var e=Object(go.a)(vo.a.mark((function e(){return vo.a.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 yd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new(function(n){Object(Qr.a)(a,n);var r=Object(Zr.a)(a);function a(){var e;return Object(Yr.a)(this,a),(e=r.apply(this,arguments)).size=t,e}return Object($r.a)(a,[{key:"iterator",value:function(){var t=Object(go.a)(vo.a.mark((function t(){return vo.a.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)}}()}]),a}(gd))}function Od(e){return yd(Object(go.a)(vo.a.mark((function t(){return vo.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Object(md.f)(e));case 1:case"end":return t.stop()}}),t)}))),e.length)}function xd(e){if(!Object(vd.e)(e))throw new Error("The argument to zip() must be an object or array.");var t;if(Array.isArray(e))for(var n=0;n1})),i.wf.assert(0===r.length,(function(){return"Duplicate column names found: "+r.toString()})),!this.columnConfigs){e.next=22;break}a=0,o=Object.keys(this.columnConfigs);case 14:if(!(a1&&void 0!==arguments[1])||arguments[1],n=[],r=0,a=e.length,i=Sd,o=0;o14||!Number.isInteger(a))throw new Error("Invalid fftSize: it must be a power of 2 between "+"2 to 4 and 2 to 14, but got ".concat(r.fftSize));if(r.numFrames=e.numFramesPerSpectrogram||43,r.sampleRateHz=e.sampleRateHz,r.columnTruncateLength=e.columnTruncateLength||r.fftSize,r.audioTrackConstraints=e.audioTrackConstraints,r.smoothingTimeConstant=e.smoothingTimeConstant||0,r.includeSpectrogram=!1!==e.includeSpectrogram,r.includeWaveform=!0===e.includeWaveform,!r.includeSpectrogram&&!r.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return r}return Object($r.a)(n,[{key:"summary",value:function(){return"microphone"}},{key:"start",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t,n;return vo.a.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: ".concat(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: ".concat(this.sampleRateHz,"; ")+"Actual: ".concat(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)}}()},{key:"next",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t,n,r,a,i;return vo.a.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)}}()},{key:"capture",value:function(){var e=Object(go.a)(vo.a.mark((function e(){return vo.a.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)}}()},{key:"getAudioData",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t,n,r,a=this;return vo.a.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)}}()},{key:"stop",value: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())}},{key:"toArray",value:function(){throw new Error("Can not convert infinite audio stream to array.")}},{key:"getSampleRate",value:function(){return this.sampleRateHz}},{key:"flattenQueue",value: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}},{key:"getTensorFromAudioDataArray",value:function(e,t){var n=new Float32Array(i.wf.sizeFromShape(t));return n.set(e,n.length-e.length),Object(i.lf)(n,t)}}],[{key:"create",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t,r,a=arguments;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.length>0&&void 0!==a[0]?a[0]:{},!Object(i.Ud)().get("IS_NODE")){e.next=3;break}throw new Error("microphone API is only supported in browser environment.");case 3:return r=new n(t),e.next=6,r.start();case 6:return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()}]),n}(md.a),Rd=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e,r){var a;if(Object(Yr.a)(this,n),(a=t.call(this)).webcamVideoElement=e,a.webcamConfig=r,a.isClosed=!0,a.resize=!1,a.needToResize())if(a.resize=!0,a.cropSize=[a.webcamConfig.resizeHeight,a.webcamConfig.resizeWidth],a.cropBoxInd=Object(i.mf)([0],"int32"),a.webcamConfig.centerCrop){var o=1*a.webcamConfig.resizeWidth/a.webcamVideoElement.width,s=1*a.webcamConfig.resizeHeight/a.webcamVideoElement.height,c=(1-o)/2,u=(1-s)/2,l=c+o,d=s+u;a.cropBox=Object(i.nf)([u,c,d,l],[1,4])}else a.cropBox=Object(i.nf)([0,0,1,1],[1,4]);return a}return Object($r.a)(n,[{key:"summary",value:function(){return"webcam"}},{key:"start",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t=this;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.webcamConfig.facingMode&&i.wf.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(function(){return"Invalid webcam facing mode: ".concat(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: ".concat(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(n){console.log(n),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)}}()},{key:"next",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t;return vo.a.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=i.yd.fromPixels(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: ".concat(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: ".concat(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)}}()},{key:"needToResize",value:function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}},{key:"cropAndResizeFrame",value:function(e){var t=this;return Object(i.pf)((function(){var n,r=Object(i.Xd)(Object(i.Ad)(e,"float32"),0),a=(n=i.fe.cropAndResize(r,t.cropBox,t.cropBoxInd,t.cropSize,"bilinear")).shape;return Object(i.Ne)(n,a.slice(1))}))}},{key:"capture",value:function(){var e=Object(go.a)(vo.a.mark((function e(){return vo.a.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)}}()},{key:"stop",value: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}},{key:"toArray",value:function(){throw new Error("Can not convert infinite video stream to array.")}}],[{key:"create",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){var r,a,o=arguments;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=o.length>1&&void 0!==o[1]?o[1]:{},!Object(i.Ud)().get("IS_NODE")){e.next=3;break}throw new Error("tf.data.webcam is only supported in browser environment.");case 3:if(t){e.next=9;break}if(t=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:t.width=r.resizeWidth,t.height=r.resizeHeight;case 9:return a=new n(t,r),e.next=12,a.start();case 12:return e.abrupt("return",a);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}]),n}(md.a),Fd=function e(){Object(Yr.a)(this,e)},Dd=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object(Yr.a)(this,n),(r=t.call(this)).file=e,r.options=a,i.wf.assert(e instanceof Uint8Array||!!Object(i.Ud)().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),(function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."})),r.offset=a.offset||0,r.chunkSize=a.chunkSize||1048576,r}return Object($r.a)(n,[{key:"summary",value:function(){return"FileChunks ".concat(this.file)}},{key:"next",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t,n=this;return vo.a.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)}}()}]),n}(n(304).a);function _d(e){return Md.apply(this,arguments)}function Md(){return(Md=Object(go.a)(vo.a.mark((function e(t){var n,r,a,o,s,c=arguments;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>1&&void 0!==c[1]?c[1]:{},"string"===typeof t?r=t:(r=t.url,a=zd(t)),e.next=4,i.wf.fetch(r,a);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 Dd(s,n));case 14:throw new Error(o.statusText);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var zd=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 Ld(e){return"string"===typeof e&&"file://"===e.substr(0,7)}var Pd=function(e){Object(Qr.a)(r,e);var t=Object(Zr.a)(r);function r(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object(Yr.a)(this,r),(n=t.call(this)).input=e,n.options=a,n}return Object($r.a)(r,[{key:"iterator",value:function(){var e=Object(go.a)(vo.a.mark((function e(){var t;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Ld(this.input)&&Object(i.Ud)().get("IS_NODE")&&(t=n(346),this.input=t.readFileSync(this.input.substr(7))),e.abrupt("return",new Dd(this.input,this.options));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),r}(Fd),Bd=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(e){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object(Yr.a)(this,n),(r=t.call(this)).url=e,r.fileOptions=a,r}return Object($r.a)(n,[{key:"iterator",value:function(){var e=Object(go.a)(vo.a.mark((function e(){return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Ld(this.url)){e.next=4;break}return e.abrupt("return",new Pd(this.url,this.fileOptions).iterator());case 4:return e.abrupt("return",_d(this.url,this.fileOptions));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),n}(Fd);function Wd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Ed(new Bd(e),t)}function Ud(e){var t=Object(md.e)(e);return yd(Object(go.a)(vo.a.mark((function e(){return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))))}function Vd(e){return yd(Object(go.a)(vo.a.mark((function t(){var n;return vo.a.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",Object(md.e)((function(){return n.next()})));case 4:case"end":return t.stop()}}),t)}))))}function Hd(e,t){return Gd.apply(this,arguments)}function Gd(){return(Gd=Object(go.a)(vo.a.mark((function e(t,n){return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Rd.create(t,n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function qd(e){return Kd.apply(this,arguments)}function Kd(){return(Kd=Object(go.a)(vo.a.mark((function e(t){return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Ad.create(t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Xd="3.8.0";function Yd(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){null!=e&&i.wf.assert("complex64"!==e.dtype,(function(){return"".concat(t," does not support complex64 tensors in the CPU backend.")}))}))}var $d=i.ie.whereImpl,Qd=function(e){Object(Qr.a)(n,e);var t=Object(Zr.a)(n);function n(){var e;return Object(Yr.a)(this,n),(e=t.call(this)).blockSize=48,e.firstUse=!0,e.data=new i.L(Object(ta.a)(e),Object(i.Td)()),e}return Object($r.a)(n,[{key:"nextDataId",value:function(){return n.nextDataId++}},{key:"write",value:function(e,t,n){this.firstUse&&(this.firstUse=!1,Object(i.Ud)().get("IS_NODE")&&i.ud.warn("\n============================\nHi there \ud83d\udc4b. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================"));var r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}},{key:"makeTensorInfo",value:function(e,t,n){var r;if("string"===t&&null!=n&&n.length>0&&i.wf.isString(n[0])){var a=n.map((function(e){return i.wf.encodeString(e)}));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}},{key:"refCount",value:function(e){return this.data.has(e)?this.data.get(e).refCount:0}},{key:"incRef",value:function(e){this.data.get(e).refCount++}},{key:"decRef",value:function(e){this.data.has(e)&&this.data.get(e).refCount--}},{key:"move",value:function(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}},{key:"numDataIds",value:function(){return this.data.numDataIds()}},{key:"read",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){return vo.a.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)}}()},{key:"readSync",value:function(e){var t=this.data.get(e),n=t.dtype,r=t.complexTensorInfos;if("complex64"===n){var a=this.readSync(r.real.dataId),o=this.readSync(r.imag.dataId);return i.ud.mergeRealAndImagArrays(a,o)}return this.data.get(e).values}},{key:"bufferSync",value:function(e){var t=this.readSync(e.dataId),n=t;if("string"===e.dtype)try{n=t.map((function(e){return i.wf.decodeString(e)}))}catch(r){throw new Error("Failed to decode encoded string bytes into utf-8")}return Object(i.zd)(e.shape,e.dtype,n)}},{key:"makeOutput",value:function(e,t,n){var r=this.write(e,t,n);return Object(i.Td)().makeTensorFromDataId(r,t,n,this)}},{key:"disposeData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(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),r=n.complexTensorInfos;null!=r&&(this.disposeData(r.real.dataId,!0),this.disposeData(r.imag.dataId,!0)),this.data.delete(e)}return!0}},{key:"disposeIntermediateTensorInfo",value:function(e){this.disposeData(e.dataId)}},{key:"time",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){var n,r;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.wf.now(),t(),r=i.wf.now()-n,e.abrupt("return",{kernelMs:r});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()},{key:"memory",value:function(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}},{key:"where",value:function(e){Yd([e],"where");var t=this.readSync(e.dataId);return $d(e.shape,t)}},{key:"dispose",value:function(){}},{key:"floatPrecision",value:function(){return 32}},{key:"epsilon",value:function(){return Object(Eo.a)(Object(na.a)(n.prototype),"epsilon",this).call(this)}}]),n}(i.wb);Qd.nextDataId=0;function Zd(e,t,n){return function(r){var a=r.inputs,o=r.attrs,s=r.backend,c=a.x;if(Yd(c,e),"string"===c.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");for(var u=s,l=u.data.get(c.dataId).values,d=i.wf.sizeFromShape(c.shape),f=n||c.dtype,p=i.wf.getArrayFromDType(f,d),h=0;h=0?e:Math.exp(e)-1})),tf={kernelName:i.W,backendName:"cpu",kernelFunc:ef};function nf(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 rf={kernelName:i.rb,backendName:"cpu",kernelFunc:nf};function af(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.alpha;Yd([a],"leakyRelu");for(var s=i.wf.sizeFromShape(a.shape),c=n.data.get(a.dataId).values,u=i.wf.getTypedArrayFromDType("float32",s),l=0;l2&&void 0!==arguments[2]?arguments[2]:"float32";if("complex64"===n){var r=Of(e,t,"float32"),a=Of(e,t,"float32");return gf({inputs:{real:r,imag:a},backend:e})}var o=i.wf.makeZerosTypedArray(i.wf.sizeFromShape(t),n);return e.makeTensorInfo(t,n,o)}function xf(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 kf={kernelName:i.kc,backendName:"cpu",kernelFunc:xf};function wf(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,s=r.dtype;if("complex64"===s){if("complex64"===a.dtype)return nf({inputs:{x:a},backend:n});var c=Of(n,a.shape,a.dtype),u=wf({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),l=gf({inputs:{real:u,imag:c},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(u),l}if("complex64"===a.dtype){var d=xf({inputs:{input:a},backend:n}),f=wf({inputs:{x:d},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(d),f}if(!i.wf.hasEncodingLoss(a.dtype,s)){var p=nf({inputs:{x:a},backend:n});return{dataId:p.dataId,shape:p.shape,dtype:s}}if("int32"===s){var h=n.data.get(a.dataId).values,b=Int32Array.from(h);return n.makeTensorInfo(a.shape,"int32",b)}if("bool"===s){var m=n.data.get(a.dataId).values,v=i.wf.toTypedArray([0],a.dtype),g=sf((function(e,t){return e!==t?1:0}))(a.shape,[],m,v,"bool"),y=Object(o.a)(g,2),O=y[0],x=y[1];return n.makeTensorInfo(x,"bool",O)}throw new Error("Error in Cast: failed to cast ".concat(a.dtype," to ").concat(s))}var jf={kernelName:i.v,backendName:"cpu",kernelFunc:wf};function Sf(e,t,n,r){return null==n?function(n){var a=n.inputs,s=n.backend,c=a.a,u=a.b,l=s;Yd([c,u],e);var d=l.data.get(c.dataId).values,f=l.data.get(u.dataId).values,p="string"===c.dtype?i.ud.fromUint8ToStringArray(d):d,h="string"===c.dtype?i.ud.fromUint8ToStringArray(f):f,b=r||c.dtype,m=t(c.shape,u.shape,p,h,b),v=Object(o.a)(m,2),g=v[0],y=v[1];return l.makeTensorInfo(y,b,g)}:function(e){var a=e.inputs,i=e.backend,s=a.a,c=a.b,u=i;if("complex64"===s.dtype||"complex64"===c.dtype){var l=wf({inputs:{x:s},backend:u,attrs:{dtype:"complex64"}}),d=u.data.get(l.dataId),f=d.complexTensorInfos.real,p=d.complexTensorInfos.imag,h=u.data.get(f.dataId).values,b=u.data.get(p.dataId).values,m=wf({inputs:{x:c},backend:u,attrs:{dtype:"complex64"}}),v=u.data.get(m.dataId),g=v.complexTensorInfos.real,y=v.complexTensorInfos.imag,O=u.data.get(g.dataId).values,x=u.data.get(y.dataId).values,k=n(s.shape,c.shape,h,b,O,x),w=Object(o.a)(k,3),j=w[0],S=w[1],N=w[2],I=u.makeTensorInfo(N,"float32",j),C=u.makeTensorInfo(N,"float32",S),T=gf({inputs:{real:I,imag:C},backend:u});return u.disposeIntermediateTensorInfo(l),u.disposeIntermediateTensorInfo(m),u.disposeIntermediateTensorInfo(I),u.disposeIntermediateTensorInfo(C),T}var E=u.data.get(s.dataId).values,A=u.data.get(c.dataId).values,R=r||s.dtype,F=t(s.shape,c.shape,E,A,R),D=Object(o.a)(F,2),_=D[0],M=D[1];return u.makeTensorInfo(M,R,_)}}function Nf(e){return function(t,n,r,a,o,s){var c=i.ud.assertAndGetBroadcastShape(t,n),u=i.wf.sizeFromShape(c),l=c.length,d=i.wf.computeStrides(c),f=i.wf.getTypedArrayFromDType("float32",u),p=i.wf.getTypedArrayFromDType("float32",u),h=i.ud.getBroadcastDims(t,c),b=i.ud.getBroadcastDims(n,c),m=i.ud.mergeRealAndImagArrays(r,a),v=i.ud.mergeRealAndImagArrays(o,s),g=t.length,y=i.wf.computeStrides(t),O=n.length,x=i.wf.computeStrides(n);if(h.length+b.length===0)for(var k=0;k=2&&d>=2&&O,(function(){return"Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input "+"batch dimensions of (".concat(m,") and (").concat(v,").")}));var x=(g>y?a.shape.slice(0,-2):s.shape.slice(0,-2)).concat([h,b]);i.wf.assert(f===p,(function(){return"Error in matMul: inner shapes (".concat(f,") and (")+"".concat(p,") of Tensors with shapes ").concat(a.shape," and ")+"".concat(s.shape," and transposeA=").concat(c)+" and transposeB=".concat(u," must match.")}));for(var k=u?[y,b,p]:[y,p,b],w=Af({inputs:{x:a},backend:n,attrs:{shape:c?[g,f,h]:[g,h,f]}}),j=Af({inputs:{x:s},backend:n,attrs:{shape:k}}),S=c?w.shape[1]:w.shape[2],N=c?w.shape[2]:w.shape[1],I=u?j.shape[1]:j.shape[2],C=Math.max(g,y),T=n.data.get(w.dataId).values,E=n.data.get(j.dataId).values,A=i.wf.computeStrides(w.shape),R=i.wf.computeStrides(j.shape),F=c?[A[0],1,A[1]]:[A[0],A[1],1],D=Object(o.a)(F,3),_=D[0],M=D[1],z=D[2],L=u?[1,R[1],R[0]]:[R[1],1,R[0]],P=Object(o.a)(L,3),B=P[0],W=P[1],U=P[2],V=N*I,H=Object(i.zd)([C,N,I],w.dtype),G=H.values,q=n.blockSize,K=0;Kk&&(k=S,w=j)}v[O]=w}return d.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(h,"int32",v)}};var Yf={kernelName:i.i,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,s=r.axis;Yd(a,"argMin");var c=i.wf.parseAxisParam(s,a.shape),u=i.ud.getAxesPermutation(c,a.shape.length),l=a,d=[];null!=u&&(l=Hf({inputs:{x:a},backend:n,attrs:{perm:u}}),d.push(l),c=i.ud.getInnerMostAxes(c.length,l.shape.length)),c=[c[0]],i.ud.assertAxesAreInnerMostDims("argMin",c,l.shape.length);for(var f=i.ud.computeOutAndReduceShapes(l.shape,c),p=Object(o.a)(f,2),h=p[0],b=p[1],m=i.wf.sizeFromShape(h),v=i.wf.makeZerosTypedArray(m,"int32"),g=i.wf.sizeFromShape(b),y=n.data.get(l.dataId).values,O=0;OD?D=B:"avg"===o&&(_+=B,M++)}if(isNaN(D))break}v[T+E*O+j]="avg"===o?_/M:D}return m}function cp(e,t,n,r){for(var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=Object(i.zd)(r.outShape,"int32"),c=r.strideHeight,u=r.strideWidth,l=r.dilationHeight,d=r.dilationWidth,f=r.effectiveFilterHeight,p=r.effectiveFilterWidth,h=r.padInfo.top,b=r.padInfo.left,m=Object(i.zd)(t,n,e),v=0;vI&&(I=F,C=a?o?((v*r.inHeight+T)*r.inWidth+A)*r.inChannels+g:(T*r.inWidth+A)*r.inChannels+g:E*p+R)}s.set(C,v,y,w,g)}}return s}function up(e,t,n,r,a,o){for(var s=a.strideDepth,c=a.strideHeight,u=a.strideWidth,l=a.dilationDepth,d=a.dilationHeight,f=a.dilationWidth,p=a.effectiveFilterDepth,h=a.effectiveFilterHeight,b=a.effectiveFilterWidth,m=a.padInfo.front,v=a.padInfo.top,g=a.padInfo.left,y="max"===o?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,O=Object(i.zd)(a.outShape,n),x=O.values,k=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],w=a.outShape[2]*a.outShape[3]*a.outShape[4],j=a.outShape[3]*a.outShape[4],S=a.outShape[4],N=0;NG?G=J:"avg"===o&&(q+=J,K++),isNaN(G))break}if(isNaN(G))break}if(isNaN(G))break}x[H+T]="avg"===o?q/K:G}}}return O}var lp={kernelName:i.o,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;Yd(a,"avgPool");var o=r.filterSize,s=r.strides,c=r.pad,u=r.dimRoundingMode;i.wf.assert(i.ud.eitherStridesOrDilationsAreOne(s,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. "+"Got strides ".concat(s," and dilations '").concat(1,"'")}));var l,d=i.ud.computePool2DInfo(a.shape,o,s,1,c,u);if(1===d.filterWidth&&1===d.filterHeight&&i.wf.arraysEqual(d.inShape,d.outShape))l=nf({inputs:{x:a},backend:n});else{var f=n.data.get(a.dataId).values,p=i.wf.computeStrides(a.shape),h=sp(f,a.shape,a.dtype,p,d,"avg");l=n.makeTensorInfo(d.outShape,a.dtype,h.values)}return l}};var dp={kernelName:i.p,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.filterSize,s=r.strides,c=r.pad,u=r.dimRoundingMode,l=r.dataFormat;Yd(a,"avgPool3d");var d=i.ud.computePool3DInfo(a.shape,o,s,1,c,u,l),f=up(n.data.get(a.dataId).values,a.shape,a.dtype,i.wf.computeStrides(a.shape),d,"avg");return n.makeTensorInfo(f.shape,"float32",f.values)}};var fp={kernelName:i.q,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.input,s=r.filterSize,c=r.strides,u=r.pad,l=r.dimRoundingMode;Yd([a,o],"avgPool3DGrad");for(var d=i.ud.computePool3DInfo(o.shape,s,c,1,u,l),f=d.strideDepth,p=d.strideHeight,h=d.strideWidth,b=d.filterDepth,m=d.filterHeight,v=d.filterWidth,g=d.dilationDepth,y=d.dilationHeight,O=d.dilationWidth,x=d.effectiveFilterDepth,k=d.effectiveFilterHeight,w=d.effectiveFilterWidth,j=x-1-d.padInfo.front,S=w-1-d.padInfo.left,N=k-1-d.padInfo.top,I=Object(i.zd)(o.shape,"float32"),C=1/(b*m*v),T=n.bufferSync(a),E=0;E=d.outDepth||Math.floor(B)!==B))for(var W=0;W=d.outHeight||Math.floor(U)!==U))for(var V=0;V=d.outWidth||Math.floor(H)!==H))L+=T.get(E,B,U,H,A)}}}I.set(L*C,E,R,F,D,A)}return n.makeTensorInfo(I.shape,I.dtype,I.values)}};var pp={kernelName:i.r,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.input,s=o;Yd([a,o],"avgPoolGrad");for(var c=r.filterSize,u=r.strides,l=r.pad,d=i.ud.computePool2DInfo(s.shape,c,u,1,l),f=d.strideHeight,p=d.strideWidth,h=d.filterHeight,b=d.filterWidth,m=d.dilationHeight,v=d.dilationWidth,g=d.effectiveFilterHeight,y=d.effectiveFilterWidth,O=y-1-d.padInfo.left,x=g-1-d.padInfo.top,k=Object(i.zd)(s.shape,"float32"),w=1/(h*b),j=n.data.get(a.dataId).values,S=Object(i.zd)(a.shape,"float32",j),N=0;N=d.outHeight||Math.floor(D)!==D))for(var _=0;_=d.outWidth||Math.floor(M)!==M))R+=S.get(N,D,M,I)}}k.set(R*w,N,C,T,I)}return n.makeTensorInfo(k.shape,k.dtype,k.values)}};var hp={kernelName:i.jb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.scale,s=t.offset,c=t.mean,u=t.variance;i.wf.assert(c.shape.length===u.shape.length,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),i.wf.assert(null==s||c.shape.length===s.shape.length,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),i.wf.assert(null==o||c.shape.length===o.shape.length,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."})),Yd([a,c,u,o,s],"batchNorm");var l=r.varianceEpsilon;null==l&&(l=.001);for(var d=n.data.get(a.dataId).values,f=n.data.get(c.dataId).values,p=n.data.get(u.dataId).values,h=o?n.data.get(o.dataId).values:new Float32Array([1]),b=s?n.data.get(s.dataId).values:new Float32Array([0]),m=new Float32Array(d.length),v=b.length,g=h.length,y=p.length,O=f.length,x=0,k=0,w=0,j=0,S=0;S=v&&(x=0),k>=O&&(k=0),w>=g&&(w=0),j>=y&&(j=0);return n.makeTensorInfo(a.shape,a.dtype,m)}};function bp(e,t,n,r,a){var o=i.af.isSliceContinous(r,t,n),s=i.wf.sizeFromShape(n),c=i.wf.computeStrides(r);if(o){var u=i.af.computeFlatOffset(t,c);return"string"===a?e.slice(u,u+s):e.subarray(u,u+s)}for(var l="string"===a?i.ud.fromUint8ToStringArray(e):e,d=Object(i.zd)(r,a,l),f=Object(i.zd)(n,a),p=0;p=a||(s[u]+=o>0?t[c]:1)}return s}function Op(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.shape[0],o=e.shape[1],s=Object(i.zd)([a,n],t.dtype),c=0;c=n||(r?s.set(1,c,l):t.size>0?s.set(s.get(c,l)+t.get(c,u),c,l):s.set(s.get(c,l)+1,c,l))}return s}var xp={kernelName:i.u,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=yp(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,s)}};function kp(e){return function(t,n,r){for(var a=i.wf.getTypedArrayFromDType(n,t.length),o=0;on.clipValueMax?n.clipValueMax:e0}));if(1===s.length)return nf({inputs:{x:s[0]},backend:n});var c=s.map((function(e){return e.shape}));if(i.ud.assertParamsConsistent(c,a),"complex64"===s[0].dtype){var u=s.map((function(e){return xf({inputs:{input:e},backend:n})})),l=s.map((function(e){return Ep({inputs:{input:e},backend:n})})),d=Rp({inputs:u,backend:n,attrs:{axis:a}}),f=Rp({inputs:l,backend:n,attrs:{axis:a}}),p=gf({inputs:{real:d,imag:f},backend:n});return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),p}var h=s.map((function(e){var t=i.wf.sizeFromShape(e.shape.slice(a));return Af({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),b=h.map((function(e){return{vals:n.data.get(e.dataId).values,shape:e.shape}}));o=i.ud.computeOutShape(h.map((function(e){return e.shape})),1);var m=1===h[0].shape[0],v=Tp(b,o,t[0].dtype,m),g=i.ud.computeOutShape(s.map((function(e){return e.shape})),a),y=n.makeTensorInfo(g,t[0].dtype,v);return h.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),y}var Fp={kernelName:i.A,backendName:"cpu",kernelFunc:Rp};function Dp(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.filter,s=r.strides,c=r.pad,u=r.dataFormat,l=r.dilations,d=r.dimRoundingMode;Yd([a,o],"conv2d");for(var f=i.ud.convertConv2DDataFormat(u),p=i.ud.computeConv2DInfo(a.shape,o.shape,s,l,c,d,!1,f),h=p.filterHeight,b=p.filterWidth,m=p.dilationHeight,v=p.dilationWidth,g=p.padInfo.left,y=p.padInfo.top,O="channelsLast"===p.dataFormat,x=new i.cd(p.outShape,a.dtype),k=i.wf.computeStrides(a.shape),w=i.wf.computeStrides(o.shape),j=k[0],S=O?k[1]:k[2],N=O?k[2]:1,I=O?1:k[1],C=x.strides[0],T=O?x.strides[1]:x.strides[2],E=O?x.strides[2]:1,A=O?1:x.strides[1],R=n.data.get(a.dataId).values,F=n.data.get(o.dataId).values,D=x.values,_=0;_=p.inHeight))for(var V=W*w[0],H=M+U*S,G=0;G=p.inWidth))for(var $=H+Y*N,Q=V+X*w[1],Z=0;Z=l.inDepth))for(var _=F*N[0],M=C+D*S[1],z=0;z=l.inHeight))for(var U=_+B*N[1],V=M+W*S[2],H=0;H=l.inWidth))for(var Y=U+K*N[2],$=V+X*l.inChannels,Q=Y,Z=0;Z=p))for(var D=y>1?(A-T)*(h-1)/(y-1):0,_=O>1?(R-E)*(b-1)/(O-1):0,M=0;M1?T*(h-1)+M*D:.5*(T+A)*(h-1);if(z<0||z>h-1)for(var L=0;L1?E*(b-1)+H*_:.5*(E+R)*(b-1);if(G<0||G>b-1)for(var q=0;q1?E*(b-1)+ae*_:.5*(E+R)*(b-1);if(ie<0||ie>b-1)for(var oe=0;oe1,(function(){return"blockSize should be > 1 for depthToSpace, but was: ".concat(o)}));for(var c=a.shape[0],u=a.shape[1],l=a.shape[2],d=a.shape[3],f=u*o,p=l*o,h=d/(o*o),b=n.data.get(a.dataId).values,m=new Float32Array(c*f*p*h),v=0,g=0;g=h.inHeight))for(var _=F*f[0],M=C+D*d[1],z=0;z=h.inWidth))for(var U=_+B*f[1],V=M+W*h.inChannels,H=L,G=U,q=0;q=0&&W=0&&VP&&(P=q)}}}R[i.wf.locToIndex([F,D,M,L],A,i.wf.computeStrides(T))]=P}return{dataId:l.write(i.wf.toTypedArray(R,a.dtype),T,a.dtype),shape:T,dtype:a.dtype}}},th={kernelName:i.T,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.filter,s=t.dy,c=r.strides,u=r.pad,l=r.dilations,d=n,f=i.wf.toNestedArray(a.shape,d.data.get(a.dataId).values),p=i.wf.toNestedArray(o.shape,d.data.get(o.dataId).values),h=i.ud.computeDilation2DInfo(a.shape,o.shape,c,u,"NHWC",l),b=h.batchSize,m=h.inHeight,v=h.inWidth,g=h.inChannels,y=h.outHeight,O=h.outWidth,x=h.padInfo,k=h.strideHeight,w=h.strideWidth,j=h.filterHeight,S=h.filterWidth,N=h.dilationHeight,I=h.dilationWidth,C=h.outShape;i.wf.assert(s.rank===C.length,(function(){return"Error in ".concat(i.T,", dy ")+"must have the same rank as output ".concat(C.length,", but got ")+"".concat(s.rank)}));for(var T=i.wf.toNestedArray(C,d.data.get(s.dataId).values),E=i.wf.makeZerosNestedTypedArray(o.shape,o.dtype),A=0;A=0&&W=0&&Vz&&(z=H,L=B,P=U)}}}E[L][P][M]+=T[A][R][D][M]}return{dataId:d.write(i.wf.toTypedArray(E,a.dtype),o.shape,o.dtype),shape:o.shape,dtype:o.dtype}}},nh={kernelName:i.U,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.filter,s=t.dy,c=r.strides,u=r.pad,l=r.dilations,d=n,f=i.wf.toNestedArray(a.shape,d.data.get(a.dataId).values),p=i.wf.toNestedArray(o.shape,d.data.get(o.dataId).values),h=i.ud.computeDilation2DInfo(a.shape,o.shape,c,u,"NHWC",l),b=h.batchSize,m=h.inHeight,v=h.inWidth,g=h.inChannels,y=h.outHeight,O=h.outWidth,x=h.padInfo,k=h.strideHeight,w=h.strideWidth,j=h.filterHeight,S=h.filterWidth,N=h.dilationHeight,I=h.dilationWidth,C=h.outShape;i.wf.assert(s.rank===C.length,(function(){return"Error in ".concat(i.U,", dy ")+"must have the same rank as output ".concat(C.length,", but got ")+"".concat(s.rank)}));for(var T=i.wf.toNestedArray(C,d.data.get(s.dataId).values),E=i.wf.makeZerosNestedTypedArray(a.shape,a.dtype),A=0;A=0&&W=0&&Vz&&(z=H,L=W,P=V)}}}E[A][L][P][M]+=T[A][R][D][M]}return{dataId:d.write(i.wf.toTypedArray(E,a.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},rh=sf((function(e,t){return e*t})),ah=Nf((function(e,t,n,r){return{real:e*n-t*r,imag:e*r+t*n}})),ih=Sf(i.Vb,rh,ah),oh={kernelName:i.Vb,backendName:"cpu",kernelFunc:ih};function sh(e){var t,n=e.inputs,r=e.backend,a=e.attrs,s=n.x,c=a.axis,u=a.keepDims;Yd(s,"sum");var l=(t="bool"===s.dtype?wf({inputs:{x:s},backend:r,attrs:{dtype:"int32"}}):nf({inputs:{x:s},backend:r})).shape.length,d=i.wf.parseAxisParam(c,t.shape),f=i.ud.getAxesPermutation(d,l),p=d,h=t;null!=f&&(h=Hf({inputs:{x:t},backend:r,attrs:{perm:f}}),p=i.ud.getInnerMostAxes(p.length,l)),i.ud.assertAxesAreInnerMostDims("sum",p,h.shape.length);for(var b=i.ud.computeOutAndReduceShapes(h.shape,p),m=Object(o.a)(b,2),v=m[0],g=m[1],y=Of(r,v,i.ud.upcastType(h.dtype,"int32")),O=i.wf.sizeFromShape(g),x=r.data.get(y.dataId).values,k=r.data.get(h.dataId).values,w=0;w=0&&(h=sh({inputs:{x:h},backend:n,attrs:{axis:d[v]-(s.length-b),keepDims:!1}}),m.push(h)),b--)}for(var I=0,C=m;I=1?c[u]:c[u]*(l+1)}return n.makeTensorInfo(a.shape,"float32",o)}},dh=sf((function(e,t){return e===t?1:0})),fh=Sf(i.Y,dh,null,"bool"),ph={kernelName:i.Y,backendName:"cpu",kernelFunc:fh},hh=i.ud.ERF_P,bh=i.ud.ERF_A1,mh=i.ud.ERF_A2,vh=i.ud.ERF_A3,gh=i.ud.ERF_A4,yh=i.ud.ERF_A5,Oh=Zd(i.Z,(function(e){var t=Math.sign(e),n=Math.abs(e),r=1/(1+hh*n);return t*(1-((((yh*r+gh)*r+vh)*r+mh)*r+bh)*r*Math.exp(-n*n))})),xh={kernelName:i.Z,backendName:"cpu",kernelFunc:Oh},kh=kp((function(e){return Math.exp(e)})),wh=Jd(i.ab,kh),jh={kernelName:i.ab,backendName:"cpu",kernelFunc:wh};function Sh(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.input,o=r.dim,s=a.shape.length,c=a.shape.slice(),u=o;return o<0&&(i.wf.assert(-(s+1)<=o,(function(){return"Axis must be in the interval [".concat(-(s+1),", ").concat(s,"]")})),u=s+o+1),c.splice(u,0,1),Af({inputs:{x:a},backend:n,attrs:{shape:c}})}var Nh={kernelName:i.bb,backendName:"cpu",kernelFunc:Sh},Ih=kp((function(e){return Math.expm1(e)})),Ch=Jd(i.cb,Ih),Th={kernelName:i.cb,backendName:"cpu",kernelFunc:Ch},Eh=sf((function(e,t){return e/t})),Ah=Sf(i.lc,Eh),Rh={kernelName:i.lc,backendName:"cpu",kernelFunc:Ah},Fh=sf((function(e,t){return e-t})),Dh=Nf((function(e,t,n,r){return{real:e-n,imag:t-r}})),_h=Sf(i.Xc,Fh,Dh),Mh={kernelName:i.Xc,backendName:"cpu",kernelFunc:_h};function zh(e,t,n){for(var r=e.shape,a=r[0],o=r[1],s=n.data.get(e.dataId),c=s.complexTensorInfos.real,u=s.complexTensorInfos.imag,l=[a,o],d=i.wf.sizeFromShape(l),f=i.wf.getTypedArrayFromDType("float32",d),p=i.wf.getTypedArrayFromDType("float32",d),h=0;h=0&&x=u/o)throw new Error("Invalid indices: ".concat(f," does not index into ").concat(c));for(var m=0;mt?1:0})),rb=Sf(i.ob,nb,null,"bool"),ab={kernelName:i.ob,backendName:"cpu",kernelFunc:rb},ib=sf((function(e,t){return e>=t?1:0})),ob=Sf(i.pb,ib,null,"bool"),sb={kernelName:i.pb,backendName:"cpu",kernelFunc:ob};var cb={kernelName:i.qb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.input,a=i.wf.sizeFromShape(r.shape),o=r.shape[r.shape.length-1],s=Af({inputs:{x:r},backend:n,attrs:{shape:[a/o,o]}}),c=zh(s,!0,n),u=Af({inputs:{x:c},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(c),u}},ub=Zd(i.tb,(function(e){return Number.isFinite(e)?1:0}),"bool"),lb={kernelName:i.tb,backendName:"cpu",kernelFunc:ub},db=Zd(i.ub,(function(e){return Math.abs(e)===1/0?1:0}),"bool"),fb={kernelName:i.ub,backendName:"cpu",kernelFunc:db},pb=Zd(i.vb,(function(e){return Number.isNaN(e)?1:0}),"bool"),hb={kernelName:i.vb,backendName:"cpu",kernelFunc:pb},bb=sf((function(e,t){return ec)&&(c=l)}a[o]=c}return a}function Pb(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,s=r.reductionIndices,c=r.keepDims,u=n,l=a.shape,d=l.length,f=i.wf.parseAxisParam(s,l),p=f,h=i.ud.getAxesPermutation(p,d),b=u.data.get(a.dataId).values;if(null!=h){for(var m=new Array(d),v=0;v=E&&(E=L,A=F*d*f+_*d+z)}n.set(A,m,g,k,N,v)}}}return n}(n.bufferSync(o),d),p=d.strideDepth,h=d.strideHeight,b=d.strideWidth,m=d.dilationDepth,v=d.dilationHeight,g=d.dilationWidth,y=d.effectiveFilterDepth,O=d.effectiveFilterHeight,x=d.effectiveFilterWidth,k=y-1-d.padInfo.front,w=x-1-d.padInfo.left,j=O-1-d.padInfo.top,S=Object(i.zd)(o.shape,"float32"),N=n.bufferSync(a),I=0;I=d.outDepth||Math.floor(z)!==z))for(var L=0;L=d.outHeight||Math.floor(P)!==P))for(var B=0;B=d.outWidth||Math.floor(W)!==W)){var U=y*O*x-1-f.get(I,z,P,W,C)===M*O*x+L*x+B?1:0;if(0!==U)_+=N.get(I,z,P,W,C)*U}}}}S.set(_,I,T,E,A,C)}return n.makeTensorInfo(S.shape,S.dtype,S.values)}};var Kb={kernelName:i.Mb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.input,s=o;Yd([o,t.output],"maxPoolGrad");for(var c=r.filterSize,u=r.strides,l=r.pad,d=r.dimRoundingMode,f=i.ud.computePool2DInfo(s.shape,c,u,1,l,d),p=n.data.get(s.dataId).values,h=Object(i.zd)(f.outShape,s.dtype,cp(p,s.shape,s.dtype,f).values),b=f.strideHeight,m=f.strideWidth,v=f.dilationHeight,g=f.dilationWidth,y=f.effectiveFilterHeight,O=f.effectiveFilterWidth,x=O-1-f.padInfo.left,k=y-1-f.padInfo.top,w=Object(i.zd)(s.shape,"float32"),j=n.data.get(a.dataId).values,S=Object(i.zd)(a.shape,"float32",j),N=0;N=f.outHeight||Math.floor(D)!==D))for(var _=0;_=f.outWidth||Math.floor(M)!==M)){var z=y*O-1-h.get(N,D,M,I)===F*O+_?1:0;if(0!==z)R+=S.get(N,D,M,I)*z}}}w.set(R,N,C,T,I)}return n.makeTensorInfo(w.shape,w.dtype,w.values)}};var Xb={kernelName:i.Nb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,s=n.filterSize,c=n.strides,u=n.pad,l=n.includeBatchInIndex,d=r;Yd(a,"MaxPoolWithArgmax");var f=d.data.get(a.dataId).values,p=i.ud.computePool2DInfo(a.shape,s,c,[1,1],u),h=function(e,t,n,r,a){var o=sp(e,0,n,i.wf.computeStrides(t),a,"max"),s=cp(e,t,n,a,!0,r);return[o.values,s.values]}(f,a.shape,a.dtype,l,p),b=Object(o.a)(h,2),m=b[0],v=b[1],g=d.write(m,p.outShape,a.dtype),y=d.write(v,p.outShape,a.dtype);return[{dataId:g,shape:p.outShape,dtype:a.dtype},{dataId:y,shape:p.outShape,dtype:"int32"}]}};var Yb={kernelName:i.Pb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.axis,s=r.keepDims,c=i.wf.parseAxisParam(o,a.shape),u=i.ud.computeOutAndReduceShapes(a.shape,c)[1],l=i.wf.sizeFromShape(u),d=[],f=n.makeTensorInfo([],"float32",new Float32Array([l]));d.push(f);var p=wf({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});d.push(p);var h=Ah({inputs:{a:p,b:f},backend:n});d.push(h);var b=sh({inputs:{x:h},backend:n,attrs:{axis:o,keepDims:s}});return d.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),b}};var $b={kernelName:i.Qb,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,s=r.axis,c=r.keepDims;Yd(a,"min");var u=i.wf.parseAxisParam(s,a.shape),l=u,d=i.ud.getAxesPermutation(l,a.shape.length),f=a;null!=d&&(f=Hf({inputs:{x:a},backend:n,attrs:{perm:d}}),l=i.ud.getInnerMostAxes(l.length,a.shape.length)),i.ud.assertAxesAreInnerMostDims("min",l,f.shape.length);for(var p=i.ud.computeOutAndReduceShapes(f.shape,l),h=Object(o.a)(p,2),b=h[0],m=h[1],v=i.wf.sizeFromShape(m),g=i.wf.makeZerosTypedArray(i.wf.sizeFromShape(b),f.dtype),y=n.data.get(f.dataId).values,O=0;O=l[x]&&(O[x]=2*(l[x]-1)-O[x]+d);O=O.map((function(e,t){return e-u[t]}));var k=i.wf.locToIndex(O,p,h);g[y]=f[k]}return{dataId:n.write(g,c,a.dtype),shape:c,dtype:a.dtype}}},tm=sf((function(e,t){var n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),nm=Sf(i.Tb,tm),rm={kernelName:i.Tb,backendName:"cpu",kernelFunc:nm};function am(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,o=r.dim,s=a.shape.length,c=o;if(-1===c&&(c=s-1),c!==s-1)throw Error("Softmax along a non-last dimension is not yet supported. "+"Logits was rank ".concat(s," and dim was ").concat(c));var u=i.wf.parseAxisParam([c],a.shape),l=Pb({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),d=i.ud.expandShapeToKeepDim(l.shape,u),f=Af({inputs:{x:l},backend:n,attrs:{shape:d}}),p=_h({inputs:{a:a,b:f},backend:n}),h=wh({inputs:{x:p},backend:n}),b=sh({inputs:{x:h},backend:n,attrs:{axis:u,keepDims:!1}}),m=Af({inputs:{x:b},backend:n,attrs:{shape:d}}),v=Ah({inputs:{a:h,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(b),n.disposeIntermediateTensorInfo(m),v}var im={kernelName:i.Gc,backendName:"cpu",kernelFunc:am};var om={kernelName:i.Ub,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,o=r.numSamples,s=r.seed,c=r.normalized;Yd(a,"multinomial");for(var u=c?a:am({inputs:{logits:a},backend:n,attrs:{dim:-1}}),l=u.shape[0],d=u.shape[1],f=n.data.get(u.dataId).values,p=[l,o],h=i.wf.makeZerosTypedArray(i.wf.sizeFromShape(p),"int32"),b=0;b=0&&d[f]1)return i.wf.makeZerosTypedArray(0,r);var a=Math.abs(Math.ceil((t-e)/n)),o=i.wf.makeZerosTypedArray(a,r);t1?m-1:m,s&&p>1?v-1:v],k=[s&&f>1?f-1:f,s&&p>1?p-1:p],w=0,j=x[0]/k[0],S=x[1]/k[1],N=0;N1?f-1:f,c&&v>1?p-1:p],O=[c&&m>1?m-1:m,c&&v>1?v-1:v],x=y[0]/O[0],k=y[1]/O[1],w=n.data.get(s.dataId).values,j=0,S=0;S1?m-1:m,s&&p>1?v-1:v],k=[s&&f>1?f-1:f,s&&p>1?p-1:p],w=x[0]/k[0],j=x[1]/k[1],S=0,N=0;N1?p-1:p,c&&g>1?h-1:h],k=[c&&v>1?v-1:v,c&&g>1?g-1:g],w=x[0]/k[0],j=x[1]/k[1],S=1/w,N=1/j,I=2*Math.ceil(S)+2,C=2*Math.ceil(N)+2,T=0;T=v)){var V=E+U*l[1],H=U*w;if(A===Math.min(p-1,c?Math.round(H):Math.floor(H)))for(var G=0;G=g)){var K=V+q*l[2],X=q*j;_===Math.min(h-1,c?Math.round(X):Math.floor(X))&&(B+=O[K+P])}}}}y[M+P]=B}return n.makeTensorInfo(a.shape,a.dtype,y)}};var Lm={kernelName:i.uc,backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.dims;Yd(a,"reverse");var s=a.shape.length,c=i.wf.parseAxisParam(o,a.shape);if(0===s)return nf({inputs:{x:a},backend:n});for(var u=new i.cd(a.shape,a.dtype),l=n.bufferSync(a),d=function(e){var t=u.indexToLoc(e),n=t.slice();c.forEach((function(e){return n[e]=a.shape[e]-1-n[e]})),u.set.apply(u,[l.get.apply(l,Object(Vn.a)(n))].concat(Object(Vn.a)(t)))},f=0;f=0&&D=0&&_.5?Math.ceil(e):t%2===0?t:t+1})),Wm={kernelName:i.wc,backendName:"cpu",kernelFunc:Bm},Um=kp((function(e){return 1/Math.sqrt(e)})),Vm=Jd(i.xc,Um),Hm={kernelName:i.xc,backendName:"cpu",kernelFunc:Vm};function Gm(e,t,n,r,a,o,s,c,u,l){var d=[r/a,a],f=e.values,p=t.values;if(0===r)return Object(i.zd)(n,t.dtype);var h=Object(i.zd)(d,t.dtype);h.values.fill(u);for(var b=0;b=r/a)throw new Error("Invalid indices: ".concat(m," does not index into ").concat(n));for(var O=0;O1||1===a.shape.length?1:i.wf.sizeFromShape(a.shape.slice(1)),b=0;b=0?Ym*e:Xm*(Math.exp(e)-1)})),Qm={kernelName:i.Ac,backendName:"cpu",kernelFunc:$m},Zm=Zd(i.Cc,(function(e){return e<0?-1:e>0?1:0})),Jm={kernelName:i.Cc,backendName:"cpu",kernelFunc:Zm},ev=Zd(i.Dc,(function(e){return Math.sin(e)})),tv={kernelName:i.Dc,backendName:"cpu",kernelFunc:ev},nv=Zd(i.Ec,(function(e){return Math.sinh(e)})),rv={kernelName:i.Ec,backendName:"cpu",kernelFunc:nv},av=Math.log(1.1920928955078125e-7)+2,iv=Zd(i.Hc,(function(e){var t=e>-av,n=e=u)throw new Error("indices(".concat(m,", 0) is invalid: ").concat(v," >= ").concat(u));++b[v],p=p&&v>=h,h=v}for(var g=!0,y=0;y0&&(b[y]+=b[y-1])}if(g&&p){for(var x=e,k=r,w=0;w5&&void 0!==arguments[5]&&arguments[5],s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,c=r.length;if(c!==a.length)throw new Error("segmentIds and indices should have same size.");var u=[t[0],e.length/t[0]],l=u[1],d=c>0?a[c-1]+1:0,f=d;if(f<0)throw new Error("segment ids must be >= 0");var p=t.slice();p[0]=f;var h=p.reduce((function(e,t){return e*t}),1),b=i.wf.getArrayFromDType(n,h);if(0===c)return f>0&&b.fill(s),[b,p];if(f<=0)throw new Error("segment ids must be >= 0");for(var m=0,v=1,g=0,y=a[m];;){var O=0;if(v=O)throw new Error("segment ids are not increasing")}if(y<0||y>=f)throw new Error("Segment id ".concat(y," out of range [0, ").concat(f,"), possibly because segmentIds input is not sorted."));y>g&&b.fill(s,g*l,y*l);for(var x=m;x=u[0])throw new Error("Bad: indices[".concat(x,"] == ").concat(r[x]," out of range [0, ").concat(u[0],")"));for(var w=0;wc)break}return g0?1:n.alpha})),jv={kernelName:i.Sc,backendName:"cpu",kernelFunc:wv};function Sv(e,t,n,r){for(var a=Object(i.zd)(e,t.dtype),o=0;o0?0:s-c),p=0;p+=u*o.leftPad.length;for(var h=0;h0){v(e[f+d-1]);for(var O=0;O0){var o=t[0];if(0!==o)throw new Error("First split value must be 0, got ".concat(o));for(var s=1;s=o;if(!(c=c&&t[s]<=r))throw new Error("Invalid split value ".concat(t[s],", must be in [").concat(o,", ").concat(r,"]"));o=t[s]}if(o!==r)throw new Error("Last split value must be data size. Expected ".concat(r,", got ").concat(o))}var u=a-1,l=i.wf.getArrayFromDType("int32",a);if(0===r||0===a){for(var d=new Array(r),f=0;f<=u;++f)l[f]=0;return[d,l]}l[0]=0;for(var p=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},h=1;h<=u;++h)p(h);for(var b=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],c=n.getNumNGrams(s,o);n.createNGrams(e,a,b,i,c,o),i+=c})),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,b,i,1,s)}},v=0;v2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length-1;r>n;){if(r-n>600){var a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*c*(a-c)/a)*Math.sign(o-a/2),l=Math.max(n,Math.floor(t-o*c/a+u)),d=Math.min(r,Math.floor(t+(a-o)*c/a+u));Uv(e,t,l,d)}var f=e[t],p=n,h=r;for(i.wf.swap(e,n,t),Wv(e[r],f)>0&&i.wf.swap(e,n,r);p0;)h-=1}0===Wv(e[n],f)?i.wf.swap(e,n,h):(h+=1,i.wf.swap(e,h,r)),h<=t&&(n=h+1),t<=h&&(r=h-1)}}function Vv(e,t,n,r,a){for(var o=t[t.length-1],s=e.length/o,c=o,u=i.wf.getTypedArrayFromDType(n,s*r),l=i.wf.getTypedArrayFromDType("int32",s*r),d=function(t){var n=t*c,i=e.subarray(n,n+c),o=new Array(i.length);i.forEach((function(e,t){return o[t]={value:e,index:t}})),rt-1)if(t<=1)n=0;else{var a=2*t;(n-=a*Math.trunc(n/a))>=t&&(n=a-n-1)}return i.wf.clamp(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 i.wf.clamp(0,n,t-1)}(e,t);case"nearest":return function(e,t){return i.wf.clamp(0,e,t-1)}(e,t);case"constant":default:return function(e,t){return e}(e)}}function Kv(e,t,n,r,a,i,o,s,c,u,l){return 0<=s&&sn){var a="[gl.TEXTURE0, gl.TEXTURE".concat(n,"]");throw new Error("textureUnit must be in ".concat(a,"."))}}function Eg(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return i.wf.sizeFromShape(e.slice(0,e.length-t))}function Ag(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 Rg(e){var t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[Eg(e)].concat(Object(Vn.a)(Ag(e)))),t}function Fg(e){return e%2===0}function Dg(e,t){if(e=e.slice(-2),t=t.slice(-2),i.wf.arraysEqual(e,t))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.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(Fg(n)&&Fg(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&Fg(e[0])&&Fg(t[0])}function _g(e,t){return null!=e.getExtension(t)}function Mg(e){try{if(null!=cg(e))return!0}catch(t){return console.log("Error when getting WebGL context: ",t),!1}return!1}function zg(e){if(0===e)return!1;var t=cg(e);if(1!==e){if(_g(t,"EXT_color_buffer_float"))return Lg(t);var n="EXT_color_buffer_half_float";if(_g(t,n)){var r=t.getExtension(n);return function(e,t){var n=fg(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!!_g(t,"OES_texture_float")&&(!!_g(t,"WEBGL_color_buffer_float")&&Lg(t))}function Lg(e){var t=fg(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 Pg(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){null!=e&&i.wf.assert("complex64"!==e.dtype,(function(){return"".concat(t," does not support complex64 tensors ")+"in the WebGL backend."}))}))}var Bg=Object(i.Ud)();function Wg(){var e,t,n,r,a,o,s,c,u,l;return 2===Object(i.Ud)().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",o="outputColor",s="out vec4 outputColor;",c="\n bool isnan_custom(float val) {\n return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ",u="",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",o="gl_FragColor",s="",c="\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:o,defineOutput:s,defineSpecialNaN:c,defineSpecialInf:u,defineRound:l}}function Ug(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"index",r=i.wf.computeStrides(t);return r.map((function(t,a){var i="int ".concat(e[a]," = ").concat(n," / ").concat(t),o=a===r.length-1?"int ".concat(e[a+1]," = ").concat(n," - ").concat(e[a]," * ").concat(t):"index -= ".concat(e[a]," * ").concat(t);return"".concat(i,"; ").concat(o,";")})).join("")}function Vg(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"index",r=i.wf.computeStrides(t);return r.map((function(t,a){var i="int ".concat(e[a]," = ").concat(n," / outShapeStrides[").concat(a,"]"),o=a===r.length-1?"int ".concat(e[a+1]," = ").concat(n," - ").concat(e[a]," * outShapeStrides[").concat(a,"]"):"index -= ".concat(e[a]," * outShapeStrides[").concat(a,"]");return"".concat(i,"; ").concat(o,";")})).join("")}function Hg(e){var t=i.wf.computeStrides(e).map((function(e){return e.toString()}));return"\n int getFlatIndex(ivec3 coords) {\n return coords.x * ".concat(t[0]," + coords.y * ").concat(t[1]," + coords.z;\n }\n")}Bg.registerFlag("HAS_WEBGL",(function(){return Bg.getNumber("WEBGL_VERSION")>0})),Bg.registerFlag("WEBGL_VERSION",(function(){return Mg(2)?2:Mg(1)?1:0})),Bg.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(function(){return!1})),Bg.registerFlag("WEBGL_BUFFER_SUPPORTED",(function(){return 2===Bg.get("WEBGL_VERSION")})),Bg.registerFlag("WEBGL_CPU_FORWARD",(function(){return!0})),Bg.registerFlag("WEBGL_FORCE_F16_TEXTURES",(function(){return!1})),Bg.registerFlag("WEBGL_PACK",(function(){return Bg.getBool("HAS_WEBGL")})),Bg.registerFlag("WEBGL_PACK_NORMALIZATION",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_PACK_CLIP",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_PACK_DEPTHWISECONV",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_PACK_REDUCE",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_LAZILY_UNPACK",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_CONV_IM2COL",(function(){return Bg.getBool("WEBGL_PACK")})),Bg.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(function(){return function(e){if(null==vg){var t=cg(e);vg=t.getParameter(t.MAX_TEXTURE_SIZE)}return vg}(Bg.getNumber("WEBGL_VERSION"))})),Bg.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(function(){return function(e){if(null==gg){var t=cg(e);gg=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,gg)}(Bg.getNumber("WEBGL_VERSION"))})),Bg.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(function(){var e=Bg.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;var t=cg(e);return _g(t,"EXT_disjoint_timer_query_webgl2")&&2===e?2:_g(t,"EXT_disjoint_timer_query")?1:0}(e)})),Bg.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(function(){return Bg.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!i.Od.isMobile()})),Bg.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(function(){return function(e){if(0===e)return!1;var t=cg(e);if(1===e){if(!_g(t,"OES_texture_float"))return!1}else if(!_g(t,"EXT_color_buffer_float"))return!1;return Lg(t)}(Bg.getNumber("WEBGL_VERSION"))})),Bg.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(function(){return!Bg.getBool("WEBGL_FORCE_F16_TEXTURES")&&Bg.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")})),Bg.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(function(){return zg(Bg.getNumber("WEBGL_VERSION"))})),Bg.registerFlag("WEBGL_FENCE_API_ENABLED",(function(){return 2===(e=Bg.getNumber("WEBGL_VERSION"))&&null!=cg(e).fenceSync;var e})),Bg.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(function(){return Bg.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0})),Bg.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 ".concat(e,"."))})),Bg.registerFlag("WEBGL_FLUSH_THRESHOLD",(function(){return i.Od.isMobile()&&Bg.getBool("IS_CHROME")?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 ".concat(e,"."))})),Bg.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(function(){return 128})),Bg.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(function(){return!1})),Bg.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(function(){return 1e5})),Bg.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(function(){return 128}));var Gg="\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",qg=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=rg.DENSE;var n=lg(t),r=Wg();this.outputShape=t,this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n ".concat(Ug(["r","c","d"],t),"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(").concat(n[0],", ").concat(n[1],"));\n int index = 4 * (resTexRC.x * ").concat(n[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 ").concat(r.output," = result;\n }\n ")},Kg=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=rg.DENSE;var n=lg(t),r=Wg();this.outputShape=t,this.userCode="\n ivec3 outCoordsFromFlatIndex(int index) {\n ".concat(Ug(["r","c","d"],t),"\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(").concat(n[0],", ").concat(n[1],"));\n int index = 4 * (resTexRC.x * ").concat(n[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 ").concat(r.output," = result;\n }\n ")},Xg=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.outTexUsage=ag.DOWNLOAD;var n=Wg();this.outputShape=t,this.userCode="\n ".concat(Gg,"\n\n void main() {\n float x = getAAtOutCoords();\n ").concat(n.output," = encode_float(x);\n }\n ")},Yg=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=ag.DOWNLOAD;var n=Wg();this.outputShape=t,this.userCode="\n ".concat(Gg,"\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ").concat(n.output," = encode_float(x);\n }\n ")},$g=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];Object(Yr.a)(this,e),this.variableNames=["A"];var a=Wg(),i=Object(o.a)(n,2),s=i[0],c=i[1];this.outputShape=t;var u="result";r&&(u="floor(result * 255. + 0.5)"),this.userCode="\n ".concat(Hg(t),"\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n int flatIndex = getFlatIndex(coords);\n int offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / ").concat(c,";\n int c = imod(flatIndex, ").concat(c,");\n vec2 uv = (vec2(c, r) + halfCR) / vec2(").concat(c,".0, ").concat(s,".0);\n vec4 values = ").concat(a.texture2D,"(A, uv);\n\n float result;\n\n if(offset == 0) {\n result = values[0];\n } else if(offset == 1) {\n result = values[1];\n } else if(offset == 2) {\n result = values[2];\n } else {\n result = values[3];\n }\n\n ").concat(a.output," = vec4(").concat(u,", 0., 0., 0.);\n }\n ")},Qg=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var a=Wg(),i=Object(o.a)(n,2),s=i[0],c=i[1];this.outputShape=t;var u="",l="result";r&&(l="floor(result * 255. + 0.5)");for(var d=0;d<=1;d++)for(var f=0;f<=1;f++){var p=2*d+f;u+="\n localCoords = coords;\n if(localCoords[2] + ".concat(f," < ").concat(t[2],") {\n localCoords[2] += ").concat(f,";\n if(localCoords[1] + ").concat(d," < ").concat(t[1],") {\n localCoords[1] += ").concat(d,";\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n r = flatIndex / ").concat(c,";\n c = imod(flatIndex, ").concat(c,");\n uv = (vec2(c, r) + halfCR) / vec2(").concat(c,".0, ").concat(s,".0);\n values = ").concat(a.texture2D,"(A, uv);\n\n if(offset == 0) {\n result[").concat(p,"] = values[0];\n } else if(offset == 1) {\n result[").concat(p,"] = values[1];\n } else if(offset == 2) {\n result[").concat(p,"] = values[2];\n } else {\n result[").concat(p,"] = values[3];\n }\n }\n }\n ")}this.userCode="\n ".concat(Hg(t),"\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ").concat(u,"\n\n ").concat(a.output," = ").concat(l,";\n }\n ")};function Zg(e){var t=Wg();return function(e,t){var n=Cg(e,(function(){return e.createShader(e.VERTEX_SHADER)}),"Unable to create vertex WebGLShader.");if(pg(e,(function(){return e.shaderSource(n,t)})),pg(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}(e,"".concat(t.version,"\n precision highp float;\n ").concat(t.attribute," vec3 clipSpacePos;\n ").concat(t.attribute," vec2 uv;\n ").concat(t.varyingVs," vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }"))}function Jg(e){return function(e,t){var n=Cg(e,(function(){return e.createBuffer()}),"Unable to create WebGLBuffer");return pg(e,(function(){return e.bindBuffer(e.ARRAY_BUFFER,n)})),pg(e,(function(){return e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)})),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function ey(e){return function(e,t){var n=Cg(e,(function(){return e.createBuffer()}),"Unable to create WebGLBuffer");return pg(e,(function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)})),pg(e,(function(){return e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)})),n}(e,new Uint16Array([0,1,2,2,1,3]))}function ty(e,t,n,r,a,o){!function(e,t){var n=Object(i.Ud)().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0){var r="[".concat(e,"x").concat(t,"]");throw new Error("Requested texture size "+r+" is invalid.")}if(e>n||t>n){var a="[".concat(e,"x").concat(t,"]"),o="[".concat(n,"x").concat(n,"]");throw new Error("Requested texture size "+a+" greater than WebGL maximum on this browser / GPU "+o+".")}}(t,n);var s=function(e){return Cg(e,(function(){return e.createTexture()}),"Unable to create WebGLTexture.")}(e),c=e.TEXTURE_2D;return pg(e,(function(){return e.bindTexture(c,s)})),pg(e,(function(){return e.texParameteri(c,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)})),pg(e,(function(){return e.texParameteri(c,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)})),pg(e,(function(){return e.texParameteri(c,e.TEXTURE_MIN_FILTER,e.NEAREST)})),pg(e,(function(){return e.texParameteri(c,e.TEXTURE_MAG_FILTER,e.NEAREST)})),pg(e,(function(){return e.texImage2D(c,0,r,t,n,0,a,o,null)})),pg(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)})),s}function ny(e){return e.internalFormatFloat}function ry(e){return e.internalFormatHalfFloat}function ay(e){return e.downloadTextureFormat}function iy(e){return e.internalFormatPackedFloat}function oy(e){return e.internalFormatPackedHalfFloat}function sy(e,t,n,r,a,i,s,c){var u=e,l=new Float32Array(function(e,t){var n=dg(e,t),r=Object(o.a)(n,2);return r[0]*r[1]*4}(i,s));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}var cy=function(){function e(t){Object(Yr.a)(this,e),this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var n=Object(i.Ud)().getNumber("WEBGL_VERSION");null!=t?(this.gl=t,function(e,t){og[e]=t}(n,t)):this.gl=cg(n);var r="WEBGL_color_buffer_float",a="EXT_color_buffer_half_float";if(1===Object(i.Ud)().getNumber("WEBGL_VERSION")){var o="OES_texture_half_float";if(this.textureFloatExtension=bg(this.gl,"OES_texture_float"),_g(this.gl,o))this.textureHalfFloatExtension=bg(this.gl,o);else if(Object(i.Ud)().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(r),_g(this.gl,a))this.colorBufferHalfFloatExtension=bg(this.gl,a);else if(Object(i.Ud)().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(r="EXT_color_buffer_float",_g(this.gl,r))this.colorBufferFloatExtension=this.gl.getExtension(r);else{if(!_g(this.gl,a))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(a)}this.vertexBuffer=Jg(this.gl),this.indexBuffer=ey(this.gl),this.framebuffer=function(e){return Cg(e,(function(){return e.createFramebuffer()}),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=fg(this.gl,this.textureHalfFloatExtension)}return Object($r.a)(e,[{key:"debug",get:function(){return Object(i.Ud)().getBool("DEBUG")}},{key:"dispose",value: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;pg(t,(function(){return t.finish()})),pg(t,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,null)})),pg(t,(function(){return t.deleteFramebuffer(e.framebuffer)})),pg(t,(function(){return t.bindBuffer(t.ARRAY_BUFFER,null)})),pg(t,(function(){return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)})),pg(t,(function(){return t.deleteBuffer(e.indexBuffer)})),this.disposed=!0}}},{key:"createFloat32MatrixTexture",value:function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=ug(t,n),i=Object(o.a)(a,2);return ty(e,i[0],i[1],ny(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)}},{key:"createFloat16MatrixTexture",value:function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=ug(t,n),i=Object(o.a)(a,2);return ty(e,i[0],i[1],ry(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}},{key:"createUnsignedBytesMatrixTexture",value:function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=ug(t,n),i=Object(o.a)(a,2);return ty(e,i[0],i[1],ay(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)}},{key:"uploadPixelDataToTexture",value:function(e,t){this.throwIfDisposed(),function(e,t,n){pg(e,(function(){return e.bindTexture(e.TEXTURE_2D,t)})),n.data instanceof Uint8Array?pg(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)})):pg(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)})),pg(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))}(this.gl,e,t)}},{key:"uploadDenseMatrixToTexture",value:function(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,a,i){var o,s,c;pg(e,(function(){return e.bindTexture(e.TEXTURE_2D,t)})),a instanceof Uint8Array?(o=new Uint8Array(n*r*4),s=e.UNSIGNED_BYTE,c=e.RGBA):(o=new Float32Array(n*r*4),s=e.FLOAT,c=i.internalFormatPackedFloat),o.set(a),pg(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,c,n,r,0,e.RGBA,s,o)})),pg(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))}(this.gl,e,t,n,r,this.textureConfig)}},{key:"createFloat16PackedMatrixTexture",value:function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=dg(t,n),i=Object(o.a)(a,2);return ty(e,i[0],i[1],oy(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}},{key:"createPackedMatrixTexture",value:function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=dg(t,n),i=Object(o.a)(a,2);return ty(e,i[0],i[1],iy(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)}},{key:"deleteMatrixTexture",value:function(e){var t=this;this.throwIfDisposed(),this.outputTexture===e&&(Ng(this.gl,this.framebuffer),this.outputTexture=null),pg(this.gl,(function(){return t.gl.deleteTexture(e)}))}},{key:"downloadByteEncodedFloatMatrixFromOutputTexture",value:function(e,t,n){var r=this;return this.downloadMatrixDriver(e,(function(){return function(e,t,n,r){var a=ug(t,n),i=Object(o.a)(a,2),s=i[0],c=i[1],u=new Uint8Array(t*n*4);return pg(e,(function(){return e.readPixels(0,0,s,c,r.downloadTextureFormat,e.UNSIGNED_BYTE,u)})),new Float32Array(u.buffer)}(r.gl,t,n,r.textureConfig)}))}},{key:"downloadPackedMatrixFromBuffer",value:function(e,t,n,r,a,i){return sy(this.gl,e,0,0,0,a,i,this.textureConfig)}},{key:"downloadFloat32MatrixFromBuffer",value:function(e,t){return function(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}(this.gl,e,t)}},{key:"createBufferFromTexture",value:function(e,t,n){this.bindTextureToFrameBuffer(e);var r=function(e,t,n,r){var a=e.createBuffer();pg(e,(function(){return e.bindBuffer(e.PIXEL_PACK_BUFFER,a)}));var i=16*t*n;return pg(e,(function(){return e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ)})),pg(e,(function(){return e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)})),pg(e,(function(){return e.bindBuffer(e.PIXEL_PACK_BUFFER,null)})),a}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}},{key:"createAndWaitForFence",value:function(){var e=this.createFence(this.gl);return this.pollFence(e)}},{key:"createFence",value:function(e){var t,n,r=this;if(Object(i.Ud)().getBool("WEBGL_FENCE_API_ENABLED")){var a=e,o=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=function(){var e=a.clientWaitSync(o,0,0);return e===a.ALREADY_SIGNALED||e===a.CONDITION_SATISFIED},t=o}else Object(i.Ud)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=function(){return r.isQueryAvailable(t,Object(i.Ud)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):n=function(){return!0};return{query:t,isFencePassed:n}}},{key:"downloadMatrixFromPackedTexture",value:function(e,t,n){var r=this;return this.downloadMatrixDriver(e,(function(){return function(e,t,n){var r=new Float32Array(t*n*4);return pg(e,(function(){return e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r)})),r}(r.gl,t,n)}))}},{key:"createProgram",value:function(e){var t=this;this.throwIfDisposed();var n=this.gl,r=mg(n,e);null==this.vertexShader&&(this.vertexShader=Zg(n));var a=function(e){return Cg(e,(function(){return e.createProgram()}),"Unable to create WebGLProgram.")}(n);return pg(n,(function(){return n.attachShader(a,t.vertexShader)})),pg(n,(function(){return n.attachShader(a,r)})),function(e,t){if(pg(e,(function(){return e.linkProgram(t)})),!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}(n,a),this.debug&&Og(n,a),this.vertexAttrsAreBound||(this.setProgram(a),this.vertexAttrsAreBound=function(e,t,n){return pg(e,(function(){return e.bindBuffer(e.ARRAY_BUFFER,n)})),xg(e,t,"clipSpacePos",n,3,20,0)&&xg(e,t,"uv",n,2,20,12)}(n,this.program,this.vertexBuffer)),a}},{key:"deleteProgram",value:function(e){var t=this;this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&pg(this.gl,(function(){return t.gl.deleteProgram(e)}))}},{key:"setProgram",value:function(e){var t=this;this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&Og(this.gl,this.program),pg(this.gl,(function(){return t.gl.useProgram(e)}))}},{key:"getUniformLocation",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.throwIfDisposed(),n?kg(this.gl,e,t):wg(this.gl,e,t)}},{key:"getAttributeLocation",value:function(e,t){var n=this;return this.throwIfDisposed(),pg(this.gl,(function(){return n.gl.getAttribLocation(e,t)}))}},{key:"getUniformLocationNoThrow",value:function(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}},{key:"setInputMatrixTexture",value:function(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),jg(this.gl,e,t,n)}},{key:"setOutputMatrixTexture",value:function(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}},{key:"setOutputPackedMatrixTexture",value:function(e,t,n){this.throwIfDisposed();var r=dg(t,n),a=Object(o.a)(r,2),i=a[0],s=a[1];this.setOutputMatrixTextureDriver(e,i,s)}},{key:"setOutputMatrixWriteRegion",value:function(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}},{key:"setOutputPackedMatrixWriteRegion",value:function(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}},{key:"debugValidate",value:function(){null!=this.program&&Og(this.gl,this.program),Ig(this.gl)}},{key:"executeProgram",value:function(){this.throwIfDisposed(),this.throwIfNoProgram();var e=this.gl;this.debug&&this.debugValidate(),pg(e,(function(){return e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}))}},{key:"blockUntilAllProgramsCompleted",value:function(){var e=this;this.throwIfDisposed(),pg(this.gl,(function(){return e.gl.finish()}))}},{key:"getQueryTimerExtension",value:function(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=bg(this.gl,2===Object(i.Ud)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}},{key:"getQueryTimerExtensionWebGL2",value:function(){return this.getQueryTimerExtension()}},{key:"getQueryTimerExtensionWebGL1",value:function(){return this.getQueryTimerExtension()}},{key:"beginQuery",value:function(){if(2===Object(i.Ud)().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}},{key:"endQuery",value:function(){if(2!==Object(i.Ud)().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)}}},{key:"waitForQueryAndGetTime",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){var n=this;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.wf.repeatedTry((function(){return n.disposed||n.isQueryAvailable(t,Object(i.Ud)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}));case 2:return e.abrupt("return",this.getQueryTime(t,Object(i.Ud)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getQueryTime",value: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}},{key:"isQueryAvailable",value: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}},{key:"pollFence",value:function(e){var t=this;return new Promise((function(n){t.addItemToPoll((function(){return e.isFencePassed()}),(function(){return n()}))}))}},{key:"pollItems",value:function(){for(var e=function(e){for(var t=0;t1||i.wf.repeatedTry((function(){return n.pollItems(),0===n.itemsToPoll.length}))}},{key:"bindTextureToFrameBuffer",value:function(e){this.throwIfDisposed(),Sg(this.gl,e,this.framebuffer),this.debug&&Ig(this.gl)}},{key:"unbindTextureToFrameBuffer",value:function(){null!=this.outputTexture?(Sg(this.gl,this.outputTexture,this.framebuffer),this.debug&&Ig(this.gl)):Ng(this.gl,this.framebuffer)}},{key:"downloadMatrixDriver",value:function(e,t){this.bindTextureToFrameBuffer(e);var n=t();return this.unbindTextureToFrameBuffer(),n}},{key:"setOutputMatrixTextureDriver",value:function(e,t,n){this.throwIfDisposed();var r=this.gl;Sg(r,e,this.framebuffer),this.debug&&Ig(r),this.outputTexture=e,pg(r,(function(){return r.viewport(0,0,t,n)})),pg(r,(function(){return r.scissor(0,0,t,n)}))}},{key:"setOutputMatrixWriteRegionDriver",value:function(e,t,n,r){var a=this;this.throwIfDisposed(),pg(this.gl,(function(){return a.gl.scissor(e,t,n,r)}))}},{key:"throwIfDisposed",value:function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}},{key:"throwIfNoProgram",value:function(){if(null==this.program)throw new Error("No GPU program is currently set.")}}]),e}();var uy=i.ud.getBroadcastDims;function ly(e,t,n){var r=[];if(e.forEach((function(e){var t=i.wf.sizeFromShape(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push("uniform float ".concat(e.name).concat(t>1?"[".concat(t,"]"):"",";")):(r.push("uniform sampler2D ".concat(e.name,";")),r.push("uniform int offset".concat(e.name,";"))),n.enableShapeUniforms){switch(Ty(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape).uniformShape.length){case 1:r.push("uniform int ".concat(e.name,"Shape;"));break;case 2:r.push("uniform ivec2 ".concat(e.name,"Shape;"));break;case 3:r.push("uniform ivec3 ".concat(e.name,"Shape;"));break;case 4:r.push("uniform ivec4 ".concat(e.name,"Shape;"))}r.push("uniform ivec2 ".concat(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 ".concat(e.type," ").concat(e.name).concat(e.arrayIndex?"[".concat(e.arrayIndex,"]"):"",";"))}));var a,o,s=r.join("\n"),c=e.map((function(e){return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3?arguments[3]:void 0,a="";a+=n?fy(e,r):dy(e,r);var i=e.shapeInfo.logicalShape,o=t.logicalShape;i.length<=o.length&&(a+=n?Ny(e,t):Iy(e,t));return a}(e,t,n.packedInputs,n.enableShapeUniforms)})).join("\n"),u=t.texShape,l=Wg(),d=function(e){return"\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ".concat(e.texture2D,"(textureSampler, uv).r;\n }\n ")}(l),f=function(e){return"".concat(e.version,"\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ").concat(e.varyingFs," vec2 resultUV;\n ").concat(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 ").concat(e.defineSpecialNaN,"\n ").concat(e.defineSpecialInf,"\n ").concat(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 ").concat(py,"\n ").concat(hy,"\n ").concat(by,"\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 * ".concat(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 * ".concat(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(".concat(r[0],", ").concat(r[1],"));\n return 2 * (resTexRC.x * ").concat(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(i.wf.arraysEqual(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(".concat(r[0],", ").concat(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(".concat(r[0],", ").concat(r[1],"));\n\n int index = resTexRC.x * ").concat(r[1]," + resTexRC.y;\n int r = 2 * (index / ").concat(a,");\n int c = imod(index, ").concat(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(".concat(r[0],", ").concat(r[1],"));\n int index = resTexRC.x * ").concat(r[1]," + resTexRC.y;\n\n int b = index / ").concat(i,";\n index -= b * ").concat(i,";\n\n int r = 2 * (index / ").concat(a,");\n int c = imod(index, ").concat(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="",c="b, r, c",u=2;u1&&void 0!==arguments[1]&&arguments[1],n=e.shapeInfo.logicalShape;switch(n.length){case 0:return gy(e,t);case 1:return yy(e,t);case 2:return Oy(e,t);case 3:return xy(e,t);case 4:return ky(e,t);case 5:return wy(e);case 6:return jy(e);default:throw new Error("".concat(n.length,"-D input sampling")+" is not yet supported")}}function fy(e,t){switch(e.shapeInfo.logicalShape.length){case 0:return function(e){var t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=Wg();return"\n vec4 ".concat(n,"() {\n return ").concat(r.texture2D,"(").concat(t,", halfCR);\n }\n ")}(e);case 1:return function(e,t){var n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,i=Wg();if(t)return"\n vec4 ".concat(r,"(int index) {\n ivec2 packedTexShape = ivec2(ceil(float(").concat(n,"TexShape[0]) / 2.0), ceil(float(").concat(n,"TexShape[1]) / 2.0));\n vec2 uv = packedUVfrom1D(\n packedTexShape[0], packedTexShape[1], index);\n return ").concat(i.texture2D,"(").concat(n,", uv);\n }\n ");var o=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];return"\n vec4 ".concat(r,"(int index) {\n vec2 uv = packedUVfrom1D(\n ").concat(o[0],", ").concat(o[1],", index);\n return ").concat(i.texture2D,"(").concat(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),o=e.shapeInfo.texShape,s=o[0],c=o[1],u=Wg();if(null!=o&&i.wf.arraysEqual(n,o))return t?"\n vec4 ".concat(a,"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(").concat(r,"TexShape[1], ").concat(r,"TexShape[0]);\n\n return ").concat(u.texture2D,"(").concat(r,", uv);\n }\n "):"\n vec4 ".concat(a,"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(").concat(c,".0, ").concat(s,".0);\n\n return ").concat(u.texture2D,"(").concat(r,", uv);\n }\n ");if(t)return"\n vec4 ".concat(a,"(int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(").concat(r,"TexShape[0]) / 2.0), ceil(float(").concat(r,"TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(").concat(r,"Shape[1]) / 2.0));\n vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);\n return ").concat(u.texture2D,"(").concat(r,", uv);\n }\n ");var l=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],d=Math.ceil(n[1]/2);return"\n vec4 ".concat(a,"(int row, int col) {\n vec2 uv = packedUVfrom2D(").concat(d,", ").concat(l[0],", ").concat(l[1],", row, col);\n return ").concat(u.texture2D,"(").concat(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],c=Ey(e,n.slice(1)),u=["b","row","col"];return"\n ".concat(fy(c,t),"\n vec4 ").concat(a,"(int b, int row, int col) {\n return ").concat(a,"(").concat(Ay(u,s),");\n }\n ")}var l=Wg();if(t)return"\n vec4 ".concat(a,"(int b, int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(").concat(r,"TexShape[0]) / 2.0), ceil(float(").concat(r,"TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(").concat(r,"Shape[2]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(").concat(r,"Shape[1]) / 2.0));\n vec2 uv = packedUVfrom3D(\n packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);\n return ").concat(l.texture2D,"(").concat(r,", uv);\n }\n ");var d=o[0],f=o[1],p=Math.ceil(n[2]/2),h=p*Math.ceil(n[1]/2);return"\n vec4 ".concat(a,"(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ").concat(d,", ").concat(f,", ").concat(h,", ").concat(p,", b, row, col);\n return ").concat(l.texture2D,"(").concat(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=Wg();if(t)return"\n vec4 ".concat(r,"(int b2, int b, int row, int col) {\n int valuesPerRow = int(ceil(float(").concat(n,"Shape[3]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(").concat(n,"Shape[2]) / 2.0));\n int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);\n texelsInBatch *= ").concat(n,"Shape[1];\n index = b2 * texelsInBatch + index;\n ivec2 packedTexShape = ivec2(ceil(float(").concat(n,"TexShape[0]) / 2.0), ceil(float(").concat(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 ").concat(a.texture2D,"(").concat(n,", uv);\n }\n ");for(var i=e.shapeInfo.logicalShape,o=i.length,s=e.shapeInfo.texShape,c=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],u=c[0],l=c[1],d=Math.ceil(i[o-1]/2),f=d*Math.ceil(i[o-2]/2),p="int b, int row, int col",h="b * ".concat(f," + (row / 2) * ").concat(d," + (col / 2)"),b=2;b=1?"coords = 0;":u.map((function(e){return"coords.".concat(f[e+d]," = 0;")})).join("\n");var p="";p=c<2&&s>0?"coords":e.shapeInfo.logicalShape.map((function(e,t){return"coords.".concat(f[t+d])})).join(", ");var h="return outputValue;",b=1===i.wf.sizeFromShape(e.shapeInfo.logicalShape),m=1===i.wf.sizeFromShape(t.logicalShape);if(1!==s||b||m){if(b&&!m)h=1===c?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(u.length){var v=s-2,g=s-1;u.indexOf(v)>-1&&u.indexOf(g)>-1?h="return vec4(outputValue.x);":u.indexOf(v)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(g)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}}else h="\n return vec4(outputValue.xy, outputValue.xy);\n ";return"\n vec4 ".concat(o,"() {\n ").concat(l," coords = getOutputCoords();\n ").concat(n,"\n vec4 outputValue = get").concat(a,"(").concat(p,");\n ").concat(h,"\n }\n ")}function Iy(e,t){var n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",o=t.texShape,s=e.shapeInfo.texShape,c=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&c===u&&null==e.shapeInfo.flatOffset&&i.wf.arraysEqual(s,o))return"\n float ".concat(a,"() {\n return sampleTexture(").concat(n,", resultUV);\n }\n ");var l,d=Cy(u),f=uy(e.shapeInfo.logicalShape,t.logicalShape),p=u-c,h=["x","y","z","w","u","v"];l=0===c?"":u<2&&f.length>=1?"coords = 0;":f.map((function(e){return"coords.".concat(h[e+p]," = 0;")})).join("\n");var b="";return b=u<2&&c>0?"coords":e.shapeInfo.logicalShape.map((function(e,t){return"coords.".concat(h[t+p])})).join(", "),"\n float ".concat(a,"() {\n ").concat(d," coords = getOutputCoords();\n ").concat(l,"\n return get").concat(r,"(").concat(b,");\n }\n ")}function Cy(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 ".concat(e," is not yet supported"))}function Ty(e,t,n){var r=i.wf.squeezeShape(t).newShape,a=t.length,o=e&&3===a&&1===t[0],s=o?t.slice(1):r,c=!e&&a>1&&!i.wf.arraysEqual(t,n)&&r.length0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),o=a.map((function(e){return e.shapeInfo})),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},c=ly(a,s,t),u=e.createProgram(c),l=null,d=e.getUniformLocation(u,"NAN",!1);1===Object(i.Ud)().getNumber("WEBGL_VERSION")&&(l=e.getUniformLocation(u,"INFINITY",!1));for(var f,p,h,b=!1,m={},v={},g={},y=0;y0;if(e.enableShapeUniforms&&!t.isUniform){var o=t.texData.texShape,s=Ty(e.packedInputs,t.shape,o),c=s.useSqueezeShape,u=s.uniformShape,l="",d="",f="";if(1===u.length&&e.packedInputs){var p=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];l="".concat(p[0]>1,"_").concat(p[1]>1)}else if(2!==u.length||e.packedInputs){if(u.length>2&&!e.packedInputs){var h=i.wf.computeStrides(u);f="".concat(h[0]===o[1],"_").concat(h[h.length-1]===o[1])}}else d="".concat(u[0]>1,"_").concat(u[1]>1);var b=t.shape.length,m=2===b&&i.wf.arraysEqual(t.shape,o),v=1===i.wf.sizeFromShape(t.shape),g=i.ud.getBroadcastDims(t.shape,n.shape),y=!e.packedInputs&&b===n.shape.length&&i.wf.arraysEqual(o,n.texData.texShape),O=e.packedInputs||b>2?"":"".concat(o[0]>1,"_").concat(o[1]>1);r+="".concat(b,"_").concat(y,"_").concat(c,"_").concat(u.length,"_").concat(v,"_").concat(g,"_").concat(m,"_").concat(l,"_").concat(d,"_").concat(f,"_").concat(O,"_").concat(a)}else{var x=t.isUniform?"uniform":t.texData.texShape;r+="".concat(t.shape,"_").concat(x,"_").concat(a)}}));var a=e.userCode,o=e.constructor.name;return o+="_"+r+"_"+a+"".concat(Object(i.Ud)().getNumber("WEBGL_VERSION"))}function My(e){return Object(i.Ud)().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}var zy=If,Ly=yp,Py=Op,By=wp,Wy=Tp,Uy=dh,Vy=kh,Hy=Ih,Gy=Hh,qy=Zh,Ky=eb,Xy=nb,Yy=ib,$y=bb,Qy=gb,Zy=xb,Jy=wb,eO=Lb,tO=Wb,nO=Qb,rO=rh,aO=sm,iO=bm,oO=Cm,sO=Em,cO=Um,uO=Mf,lO=bp,dO=cv,fO=lv,pO=fv,hO=Sv,bO=Cv,mO=Av,vO=Fv,gO=Fh,yO=Pv,OO=Vv,xO=Vf,kO=$v;function wO(e,t){return["x","y","z","w","u","v"].slice(0,t).map((function(t){return"".concat(e,".").concat(t)}))}function jO(e,t){return 1===t?[e]:wO(e,t)}var SO=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=t;var n=t.length;if(0===n)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{var r=jO("rc",n),a=Cy(n),i=function(e,t,n){if(1===e)return"rc > ".concat(t[0]);for(var r="",a=e-2;a= ").concat(t[a]),a= ").concat(t,";\n bool rEdge = rp1 >= ").concat(n,";\n ")}(n,t[t.length-1],t[t.length-2],r),s=function(e,t){var n=e.length,r=function(e,t){for(var n=[],r=0;r<=1;r++)for(var a=0;a<=1;a++){for(var i="".concat(0===r?"r":"rp1",", ").concat(0===a?"c":"cp1"),o=2;o= ".concat(e[0]," ? 0. : getA(rc + 1),\n 0, 0");return"getA(".concat(r[0],"),\n cEdge ? 0. : getA(").concat(r[1],"),\n rEdge ? 0. : getA(").concat(r[2],"),\n rEdge || cEdge ? 0. : getA(").concat(r[3],")")}(t,r);this.userCode="\n void main() {\n ".concat(a," rc = getOutputCoords();\n\n if(").concat(i,") {\n setOutput(vec4(0));\n } else {\n ").concat(o,"\n\n setOutput(vec4(").concat(s,"));\n }\n }\n ")}};var NO=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var 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 ".concat(i,"\n ").concat(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[").concat(a,"] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ").concat(a>0?"}":"","\n ")}this.userCode="\n ".concat(function(e){var t=Ug(["r","c","d"],e);return"\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ".concat(t,"\n return ivec3(r, c, d);\n }\n ")}(n),"\n ").concat(Hg(t),"\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ").concat(t[1],";\n int cols = ").concat(t[2],";\n\n ").concat(r,"\n\n setOutput(result);\n }\n ")};var IO=function(){function e(t){Object(Yr.a)(this,e),this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}return Object($r.a)(e,[{key:"acquireTexture",value:function(e,t,n){var r=TO(t,n),a=EO(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);var i,o=CO(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].shift();return this.usedTextures[a].push(s),s}return r===ig.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===ig.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===ig.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===ig.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===ig.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}},{key:"releaseTexture",value:function(e,t,n,r){if(null!=this.freeTextures){var a=TO(n,r),o=EO(t,a,r);o in this.freeTextures||(this.freeTextures[o]=[]);var s=CO(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),c=Object(i.Ud)().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==c&&this._numBytesAllocated>c?(this.gpgpu.deleteMatrixTexture(e),this._numBytesAllocated-=s):(this.freeTextures[o].push(e),this.numFreeTextures++,this._numBytesFree+=s),this.numUsedTextures--;var u=this.usedTextures[o],l=u.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u.splice(l,1),this.log()}}},{key:"log",value:function(){if(this.logEnabled){var e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used","".concat(this.numFreeTextures," / ").concat(this.numUsedTextures),"(".concat(e,")"));var t=this._numBytesFree/this._numBytesAllocated;console.log("Bytes allocated: ".concat(this._numBytesAllocated)),console.log("Bytes unused: ".concat(this._numBytesFree," (").concat(Math.round(100*t),"%)"))}}},{key:"numBytesAllocated",get:function(){return this._numBytesAllocated}},{key:"numBytesFree",get:function(){return this._numBytesFree}},{key:"getNumUsedTextures",value:function(){return this.numUsedTextures}},{key:"getNumFreeTextures",value:function(){return this.numFreeTextures}},{key:"dispose",value:function(){var e=this;if(null!=this.freeTextures){for(var t in this.freeTextures)this.freeTextures[t].forEach((function(t){e.gpgpu.deleteMatrixTexture(t)}));for(var n in this.usedTextures)this.usedTextures[n].forEach((function(t){e.gpgpu.deleteMatrixTexture(t)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}]),e}();function CO(e,t,n,r,a){var i,s=function(e,t){switch(e){case ig.PACKED_2X2_FLOAT32:return iy(t);case ig.PACKED_2X2_FLOAT16:return oy(t);case ig.UNPACKED_FLOAT32:return ny(t);case ig.UNPACKED_FLOAT16:return ry(t);case ig.PACKED_4X1_UNSIGNED_BYTE:return ay(t);default:throw new Error("Unknown physical texture type ".concat(e))}}(t,r);if(a){var c=dg(e[0],e[1]),u=Object(o.a)(c,2);i=u[0]*u[1]}else{var l=ug(e[0],e[1]),d=Object(o.a)(l,2);i=d[0]*d[1]}return i*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;throw new Error("Unknown internal format ".concat(t))}(n,s)}function TO(e,t){if(e===ag.UPLOAD)return ig.PACKED_2X2_FLOAT32;if(e===ag.RENDER||null==e)return function(e){return Object(i.Ud)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?ig.PACKED_2X2_FLOAT32:ig.UNPACKED_FLOAT32:e?ig.PACKED_2X2_FLOAT16:ig.UNPACKED_FLOAT16}(t);if(e===ag.DOWNLOAD||e===ag.PIXELS)return ig.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type ".concat(e))}function EO(e,t,n){return"".concat(e[0],"_").concat(e[1],"_").concat(t,"_").concat(n)}var AO=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["A"],this.outputShape=t,this.enableShapeUniforms=My(this.outputShape.length),this.userCode="\n float unaryOperation(float x) {\n ".concat(n,"\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n ")},RO="if (isnan(x)) return x;",FO="return x;",DO="return abs(x);";var _O="return (x >= 0.0) ? x : (exp(x) - 1.0);",MO=RO+"\n return (x < 0.0) ? 0.0 : x;\n",zO=RO+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",LO="return x;",PO="return 1.0 / (1.0 + exp(-1.0 * x));",BO="return x;",WO="\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",UO="\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",VO="\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",HO="return 1.0 / (1.0 + exp(-1.0 * x));",GO=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.enableShapeUniforms=My(this.outputShape.length),this.userCode="\n vec4 unaryOperation(vec4 x) {\n ".concat(n,"\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n ")},qO=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t;var n=t.length,r=jO("rc",n),a=Cy(n),i=function(e,t){if(1===e)return"rc";for(var n="",r=0;r0}},{key:"time",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){var n,r,a,o,s,c,u;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.activeTimers,r=[],a=!1,null==this.programTimersStack?(this.programTimersStack=r,a=!0):this.activeTimers.push(r),this.activeTimers=r,t(),o=i.wf.flatten(this.activeTimers.map((function(e){return e.query}))).filter((function(e){return null!=e})),s=i.wf.flatten(this.activeTimers.map((function(e){return e.name}))).filter((function(e){return null!=e})),this.activeTimers=n,a&&(this.programTimersStack=null),c={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null},!(Object(i.Ud)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)){e.next=19;break}return e.next=14,Promise.all(o);case 14:u=e.sent,c.kernelMs=i.wf.sum(u),c.getExtraProfileInfo=function(){return u.map((function(e,t){return{name:s[t],ms:e}})).map((function(e){return"".concat(e.name,": ").concat(e.ms)})).join(", ")},e.next=20;break;case 19:c.kernelMs={error:"WebGL query timers are not supported in this environment."};case 20:return this.uploadWaitMs=0,this.downloadWaitMs=0,e.abrupt("return",c);case 23:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"memory",value:function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}},{key:"startTimer",value:function(){return Object(i.Ud)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:i.wf.now(),endMs:null}}},{key:"endTimer",value:function(e){return Object(i.Ud)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=i.wf.now(),e)}},{key:"getQueryTime",value:function(){var e=Object(go.a)(vo.a.mark((function e(t){var n;return vo.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Object(i.Ud)().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)}}()},{key:"disposeData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(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),r=n.complexTensorInfos;return null!=r&&(this.disposeData(r.real.dataId,t),this.disposeData(r.imag.dataId,t)),this.texData.delete(e),!0}},{key:"releaseGPUData",value: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,c=s&&s.origDataId||e,u=this.dataRefCount.get(c);u>1?this.dataRefCount.set(c,u-1):(this.dataRefCount.delete(c),null!=n&&(this.numBytesInGPU-=this.computeBytes(a,r),this.textureManager.releaseTexture(n,a,i,o)));var l=this.texData.get(e);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null}},{key:"getTexture",value:function(e){return this.uploadToGPU(e),this.texData.get(e).texture}},{key:"getDataInfo",value:function(e){return this.texData.get(e)}},{key:"shouldExecuteOnCPU",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:YO;return Object(i.Ud)().getBool("WEBGL_CPU_FORWARD")&&e.every((function(e){return null==t.texData.get(e.dataId).texture&&i.wf.sizeFromShape(e.shape)0&&i.wf.isString(n[0])){var a=n.map((function(e){return i.wf.encodeString(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}}},{key:"makeOutput",value:function(e,t,n){var r=this.makeTensorInfo(e,t,n).dataId;return Object(i.Td)().makeTensorFromDataId(r,e,t,this)}},{key:"unpackTensor",value:function(e){var t=new qO(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}},{key:"packTensor",value:function(e){var t=new SO(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}},{key:"packedReshape",value:function(e,t){var n=[Eg(e.shape)].concat(Object(Vn.a)(Ag(e.shape))),r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[Eg(t)].concat(Object(Vn.a)(Ag(t))),i=new NO(a,n),o=this.runWebGLProgram(i,[r],e.dtype,null,!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}},{key:"decode",value:function(e){var t,n=this.texData.get(e),r=n.isPacked,a=n.shape,i=n.dtype,o=Rg(a);t=r?new Kg(o):new qg(o);return{dtype:i,shape:a,dataId:this.runWebGLProgram(t,[{shape:o,dtype:i,dataId:e}],i,null,!0).dataId}}},{key:"runWebGLProgram",value:function(e,t,n,r){var a=this,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=this.makeTensorInfo(e.outputShape,n),c=this.texData.get(s.dataId);if(e.packedOutput&&(c.isPacked=!0),e.outPackingScheme===rg.DENSE){var u=lg(e.outputShape);c.texShape=u.map((function(e){return 2*e}))}if(null!=e.outTexUsage&&(c.usage=e.outTexUsage),0===i.wf.sizeFromShape(s.shape))return c.values=i.wf.getTypedArrayFromDType(s.dtype,0),s;var l=[],d=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=a.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&i.wf.sizeFromShape(t.shape)<=Object(i.Ud)().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)}else if(!!n.isPacked!==!!e.packedInputs)t=n.isPacked?a.unpackTensor(t):a.packTensor(t),l.push(t),n=a.texData.get(t.dataId);else if(n.isPacked&&!Dg(n.shape,t.shape)){var r=t,o=t.shape;t.shape=n.shape,t=a.packedReshape(t,o),l.push(t),n=a.texData.get(t.dataId),r.shape=o}return a.uploadToGPU(t.dataId),{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(s.dataId);var f,p={shape:s.shape,texData:c,isUniform:!1},h=_y(e,d,p),b=this.getAndSaveBinary(h,(function(){return Ry(a.gpgpu,e,d,p)})),m=null!=this.activeTimers;m&&(f=this.startTimer()),Dy(this.gpgpu,b,d,p,r),l.forEach((function(e){return a.disposeIntermediateTensorInfo(e)})),m&&(f=this.endTimer(f),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(f)}));var v=Object(i.Ud)().get("WEBGL_FLUSH_THRESHOLD");if(v>0){var g=i.wf.now();g-this.lastGlFlushTime>v&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=g)}if(!Object(i.Ud)().getBool("WEBGL_LAZILY_UNPACK")&&c.isPacked&&!1===o){var y=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),y}return s}},{key:"compileAndRun",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];n=n||t[0].dtype;var i=this.runWebGLProgram(e,t,n,r,a);return i}},{key:"getAndSaveBinary",value:function(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}},{key:"getTextureManager",value:function(){return this.textureManager}},{key:"dispose",value:function(){var e=this;if(!this.disposed){if(!Object(i.Ud)().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}}},{key:"floatPrecision",value:function(){var e=this;return null==this.floatPrecisionValue&&(this.floatPrecisionValue=Object(i.pf)((function(){if(!Object(i.Ud)().get("WEBGL_RENDER_FLOAT32_ENABLED")){var t=Object(i.Ud)().getBool("DEBUG");Object(i.Ud)().set("DEBUG",!1);var n=e.abs(Object(i.Pe)(1e-8)).dataSync()[0];if(Object(i.Ud)().set("DEBUG",t),n>0)return 32}return 16}))),this.floatPrecisionValue}},{key:"epsilon",value:function(){return 32===this.floatPrecision()?1e-7:1e-4}},{key:"uploadToGPU",value:function(e){var t=this.texData.get(e),n=t.shape,r=t.dtype,a=t.values,s=t.texture,c=t.usage,u=t.isPacked;if(null==s){var l,d=null!=this.activeTimers;d&&(l=i.wf.now());var f=t.texShape;if(null==f&&(f=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Object(i.Ud)().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(n*=2,1===(e=e.map((function(t,n){return n>=e.length-2?i.wf.nearestLargerEven(e[n]):e[n]}))).length&&(e=[2,e[0]])),2!==e.length){var r=i.wf.squeezeShape(e);e=r.newShape}var a=i.wf.sizeFromShape(e);if(e.length<=1&&a<=n)return[1,a];if(2===e.length&&e[0]<=n&&e[1]<=n)return e;if(3===e.length&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){var s=Eg(e),c=2,u=2;if(e.length){var l=Ag(e),d=Object(o.a)(l,2);c=d[0],u=d[1]}return a=s*(c/2)*(u/2),i.wf.sizeToSquarishShape(a).map((function(e){return 2*e}))}return i.wf.sizeToSquarishShape(a)}(n,u),t.texShape=f),null!=a){var p,h=Rg(n),b=f[1],m=f[0],v=a instanceof Uint8Array;if(u){var g=dg(f[0],f[1]),y=Object(o.a)(g,2);b=y[0],m=y[1],p=new Qg(h,[m,b],v)}else p=new $g(h,[m,b],v);var O=this.makeTensorInfo([m,b],r);this.texData.get(O.dataId).usage=v?ag.PIXELS:ag.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(O.dataId),b,m,a);var x=this.runWebGLProgram(p,[O],r,null,!0),k=this.texData.get(x.dataId);t.texture=k.texture,t.texShape=k.texShape,t.isPacked=k.isPacked,t.usage=k.usage,this.disposeIntermediateTensorInfo(O),this.texData.delete(x.dataId),t.values=null,d&&(this.uploadWaitMs+=i.wf.now()-l)}else{var w=this.acquireTexture(f,c,r,u);t.texture=w}}}},{key:"convertAndCacheOnCPU",value:function(e,t){var n=this.texData.get(e),r=n.dtype;return this.releaseGPUData(e),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;r1024*this.numMBBeforeWarning*1024){var a=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: ".concat(a," MB, ")+"most likely due to a memory leak")}return this.textureManager.acquireTexture(e,t,r)}},{key:"computeBytes",value:function(e,t){return e[0]*e[1]*i.wf.bytesPerElement(t)}}]),n}(i.wb);$O.nextDataId=0;i.Od.isBrowser()&&Object(i.Ke)("webgl",(function(){return new $O}),2);var QO=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["A","B"],this.outputShape=i.ud.assertAndGetBroadcastShape(n,r),this.enableShapeUniforms=My(this.outputShape.length),this.userCode="\n float binaryOperation(float a, float b) {\n ".concat(t,"\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n ")},ZO=function e(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Object(Yr.a)(this,e),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i.ud.assertAndGetBroadcastShape(n,r);var o=this.outputShape.length;this.enableShapeUniforms=My(o);var s="";if(a)if(0===o||1===i.wf.sizeFromShape(this.outputShape))s="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else{var c=Cy(o);if(s="\n ".concat(c," coords = getOutputCoords();\n "),1===o)this.enableShapeUniforms?s+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":s+="\n result.y = (coords + 1) >= ".concat(this.outputShape[0]," ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ");else{var u=jO("coords",o);this.enableShapeUniforms?s+="\n bool nextRowOutOfBounds =\n (".concat(u[o-2]," + 1) >= outShape[").concat(o," - 2];\n bool nextColOutOfBounds =\n (").concat(u[o-1]," + 1) >= outShape[").concat(o," - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n "):s+="\n bool nextRowOutOfBounds =\n (".concat(u[o-2]," + 1) >= ").concat(this.outputShape[o-2],";\n bool nextColOutOfBounds =\n (").concat(u[o-1]," + 1) >= ").concat(this.outputShape[o-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 ".concat(t,"\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ").concat(s,"\n\n setOutput(result);\n }\n ")};function JO(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 ex={kernelName:i.rb,backendName:"webgl",kernelFunc:JO};function tx(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=JO({inputs:{x:r},backend:n}),c=JO({inputs:{x:a},backend:n});return o.complexTensorInfos={real:s,imag:c},i}var nx={kernelName:i.y,backendName:"webgl",kernelFunc:tx},rx="return (a < 0.) ? b * a : a;",ax="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";var ix={kernelName:i.zb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.alpha,s=n.makeTensorInfo([],"float32",i.wf.createScalarValue(o,"float32")),c=Object(i.Ud)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new ZO(ax,a.shape,s.shape):new QO(rx,a.shape,s.shape),u=n.runWebGLProgram(c,[a,s],a.dtype);return n.disposeIntermediateTensorInfo(s),u}},ox="return (a < 0.) ? b * a : a;",sx="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";var cx={kernelName:i.hc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=t.alpha,o=Object(i.Ud)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new ZO(sx,r.shape,a.shape):new QO(ox,r.shape,a.shape);return n.runWebGLProgram(o,[r,a],r.dtype)}};function ux(e){var t=e.opSnippet,n=e.packedOpSnippet,r=e.cpuKernelImpl,a=e.dtype;return function(e){var o,s=e.inputs,c=e.backend,u=s.x,l=c,d=a||u.dtype;if(l.shouldExecuteOnCPU([u])&&null!=r){var f=l.texData.get(u.dataId),p=r(f.values,d);return l.makeTensorInfo(u.shape,d,p)}return o=Object(i.Ud)().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=n?new GO(u.shape,n):new AO(u.shape,t),l.runWebGLProgram(o,[u],d)}}function lx(e){var t=e.opSnippet,n=e.packedOpSnippet,r=e.checkOutOfBounds,a=void 0!==r&&r,s=e.supportsComplex,c=void 0!==s&&s,u=e.cpuKernelImpl,l=e.dtype;return function(e){var r=e.inputs,s=e.backend,d=r.a,f=r.b,p=s;if(c&&"complex64"===d.dtype){var h=p.texData.get(d.dataId),b=p.texData.get(f.dataId),m=[[h.complexTensorInfos.real,b.complexTensorInfos.real],[h.complexTensorInfos.imag,b.complexTensorInfos.imag]].map((function(e){var n=Object(o.a)(e,2),r=n[0],a=n[1],s={dataId:r.dataId,dtype:r.dtype,shape:d.shape},c={dataId:a.dataId,dtype:a.dtype,shape:f.shape},u=new QO(t,d.shape,f.shape);return p.runWebGLProgram(u,[s,c],Object(i.vf)(r.dtype,a.dtype))})),v=Object(o.a)(m,2),g=v[0],y=v[1],O=tx({inputs:{real:g,imag:y},backend:p});return p.disposeIntermediateTensorInfo(g),p.disposeIntermediateTensorInfo(y),O}var x,k=l||Object(i.vf)(d.dtype,f.dtype);if(("string"===d.dtype||"string"===f.dtype||p.shouldExecuteOnCPU([d,f]))&&null!=u){var w=p.texData.get(d.dataId).values,j=p.texData.get(f.dataId).values,S="string"===d.dtype?i.ud.fromUint8ToStringArray(w):w,N="string"===d.dtype?i.ud.fromUint8ToStringArray(j):j,I=u(d.shape,f.shape,S,N,k),C=Object(o.a)(I,2),T=C[0],E=C[1],A=p.makeTensorInfo(E,k);return p.texData.get(A.dataId).values=T,A}return x=Object(i.Ud)().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=n?new ZO(n,d.shape,f.shape,a):new QO(t,d.shape,f.shape),p.runWebGLProgram(x,[d,f],k)}}function dx(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("linear"===e)return t?BO:FO;if("relu"===e)return t?UO:MO;if("elu"===e)return t?WO:_O;if("relu6"===e)return t?VO:zO;if("prelu"===e)return t?sx:ox;if("leakyrelu"===e)return t?ax:rx;if("sigmoid"===e)return t?HO:PO;throw new Error("Activation ".concat(e," has not been implemented for the WebGL backend."))}var fx=function e(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,c=arguments.length>7&&void 0!==arguments[7]&&arguments[7],u=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Object(Yr.a)(this,e),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r;var l=a?t[1]:t[2],d=Math.ceil(l/2),f=a?"i * 2, rc.y":"rc.y, i * 2",p=i?"rc.z, i * 2":"i * 2, rc.z",h=a?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],b=i?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",v="";s&&(m=c?"vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ".concat(s,"\n }"):u?"vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ".concat(s,"\n }"):"vec4 activation(vec4 x) {\n ".concat(s,"\n }"),v="result = activation(result);");var g=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),c&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");var y="rc.x",O="rc.x";t[0]0&&(f="\n if (inIdx < 0 || inIdx >= ".concat(o,") {\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 ".concat(f,"\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 * ").concat(r,";\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ").concat(c,"; 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 ").concat(l,"\n }\n\n int inIdx = inOffset + ").concat(c,";\n if (").concat(1===u,") {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ").concat(l,"\n } else if (").concat(2===u,") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ").concat(l,"\n } else if (").concat(3===u,") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ").concat(l,"\n }\n setOutput(sumValue);\n }\n ")},kx=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["x"];var r=t.windowSize,a=t.batchSize,i=t.inSize,o=t.outSize;this.outputShape=[a,o];var s="0.0",c="";"prod"===n?s="1.0":"min"===n?(s="1.0 / 1e-20",c="min"):"max"===n&&(s="-1.0 / 1e-20",c="max");var u="".concat(n,"(").concat(n,"(").concat(n,"(")+"minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===n?u="sumValue":"prod"===n?u="prodValue":"all"===n?u="allValue":"any"===n&&(u="anyValue");var l=4*Math.floor(r/4),d=r%4,f="\n if (".concat("sum"===n,") {\n sumValue += dot(values, ones);\n } else if (").concat("prod"===n,") {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ").concat(c,"(values, minMaxValue);\n if (").concat("min"===n," || ").concat("max"===n,") {\n minMaxValue = ").concat(c,"(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 "),p="vec4";"all"===n?(s="1.0",f="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",p="bvec4"):"any"===n&&(s="0.0",f="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",p="bvec4");var h="";i%r>0&&(h="\n if (inIdx < 0 || inIdx >= ".concat(i,") {\n return initializationValue;\n }\n ")),this.userCode="\n const float initializationValue = ".concat(s,";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ").concat(h,"\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 * ").concat(r,";\n\n vec4 minMaxValue = vec4(").concat(s,");\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 < ").concat(l,"; i += 4) {\n int inIdx = inOffset + i;\n ").concat(p," values = ").concat(p,"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ").concat(f,"\n }\n\n int inIdx = inOffset + ").concat(l,";\n if (").concat(1===d,") {\n ").concat(p," values = ").concat(p,"(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ").concat(f,"\n } else if (").concat(2===d,") {\n ").concat(p," values = ").concat(p,"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ").concat(f,"\n } else if (").concat(3===d,") {\n ").concat(p," values = ").concat(p,"(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ").concat(f,"\n }\n setOutput(").concat(u,");\n }\n ")};function wx(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=i.ud.computeOptimalWindowSize(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape),o=e,s=0;s6)throw Error("Transpose for rank ".concat(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;a6)throw Error("Packed transpose for rank ".concat(this.rank," is not yet supported."));for(var i=Cy(this.rank),o=wO("rc",this.rank),s=new Array(this.rank),c=0;c=2&&m>=2&&S,(function(){return"Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input "+"batch dimensions of (".concat(x,") and (").concat(k,").")}));var N=(w>j?t.shape.slice(0,-2):n.shape.slice(0,-2)).concat([y,O]);i.wf.assert(v===g,(function(){return"Error in matMul: inner shapes (".concat(v,") and (")+"".concat(g,") of Tensors with shapes ").concat(t.shape," and ")+"".concat(n.shape," and transposeA=").concat(r)+" and transposeB=".concat(a," must match.")}));var I,C=r?[w,v,y]:[w,y,v],T=a?[j,O,g]:[j,g,O],E=yx({inputs:{x:t},backend:o,attrs:{shape:C}}),A=yx({inputs:{x:n},backend:o,attrs:{shape:T}}),R=[E,A],F=Math.max(w,j),D=r?E.shape[1]:E.shape[2],_=null!=c,M=null!=l,z="leakyrelu"===h,L=null!=h?dx(h,!0):null;if((1===y||1===O)&&D>1e3&&!1===(_||M||z||null!=L)){var P=E,B=A;r&&(P=Tx({inputs:{x:E},backend:o,attrs:{perm:[0,2,1]}}),R.push(P)),a&&(B=Tx({inputs:{x:A},backend:o,attrs:{perm:[0,2,1]}}),R.push(B));var W=1===O,U=P;1!==O&&(U=yx({inputs:{x:P},backend:o,attrs:{shape:[F,D,1]}}),R.push(U));var V=1===O?2:1,H=B;W&&(H=yx({inputs:{x:B},backend:o,attrs:{shape:[F,1,D]}}),R.push(H));var G=vx({inputs:{a:U,b:H},backend:o});I=Ix({inputs:{x:G},backend:o,attrs:{axis:V,keepDims:!0}}),R.push(G)}else{var q=Object(i.vf)(t.dtype,n.dtype),K=new fx(C,T,[F,y,O],r,a,_,L,M,z),X=[E,A];if(null!=c&&X.push(c),M&&X.push(l),z){var Y=o.makeTensorInfo([],"float32",i.wf.createScalarValue(f,"float32"));X.push(Y),R.push(Y)}I=o.runWebGLProgram(K,X,q)}var $=yx({inputs:{x:I},backend:o,attrs:{shape:N}});R.push(I);for(var Q=0,Z=R;Q 1.) {\n return NAN;\n }\n return acos(x);\n"}),Mx={kernelName:i.b,backendName:"webgl",kernelFunc:_x},zx=ux({opSnippet:"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),Lx={kernelName:i.c,backendName:"webgl",kernelFunc:zx},Px="return a + b;",Bx=lx({opSnippet:Px,packedOpSnippet:Px,supportsComplex:!0,cpuKernelImpl:zy}),Wx={kernelName:i.d,backendName:"webgl",kernelFunc:Bx},Ux=function e(t,n){Object(Yr.a)(this,e),this.outputShape=[],this.outputShape=t,this.variableNames=n.map((function(e,t){return"T".concat(t)}));var r=[];this.variableNames.forEach((function(e){r.push("float v".concat(e," = get").concat(e,"AtOutCoords();"))}));var a=this.variableNames.map((function(e){return"v".concat(e)})).join(" + ");this.userCode="\n void main() {\n ".concat(r.join("\n "),"\n\n float result = ").concat(a,";\n setOutput(result);\n }\n ")},Vx=function e(t,n){Object(Yr.a)(this,e),this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.variableNames=n.map((function(e,t){return"T".concat(t)}));var r=[];this.variableNames.forEach((function(e){r.push("vec4 v".concat(e," = get").concat(e,"AtOutCoords();"))}));var a=this.variableNames.map((function(e){return"v".concat(e)})).join(" + ");this.userCode="\n void main() {\n ".concat(r.join("\n "),"\n\n vec4 result = ").concat(a,";\n setOutput(result);\n }\n ")};var Hx={kernelName:i.e,backendName:"webgl",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=n;if(1===a.length)return JO({inputs:{x:a[0]},backend:r});if(a.length>Object(i.Ud)().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var o=Math.floor(a.length/2),s=e({inputs:a.slice(0,o),backend:r}),c=e({inputs:a.slice(o),backend:r});return e({inputs:[s,c],backend:r})}var u=a.map((function(e){return e.dtype})).reduce((function(e,t){return Object(i.vf)(e,t)})),l=a.map((function(e){return e.shape})),d=Object(i.Ud)().getBool("WEBGL_PACK")?new Vx(a[0].shape,l):new Ux(a[0].shape,l);return r.runWebGLProgram(d,a,u)}};var Gx={kernelName:i.f,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,s=r.axis,c=r.keepDims,u=a.shape.length,l=i.wf.parseAxisParam(s,a.shape),d=l,f=i.ud.getAxesPermutation(d,u),p=a;null!=f&&(p=Tx({inputs:{x:a},backend:n,attrs:{perm:f}}),d=i.ud.getInnerMostAxes(d.length,u)),i.ud.assertAxesAreInnerMostDims("all",d,u);var h,b=i.ud.computeOutAndReduceShapes(p.shape,d),m=Object(o.a)(b,2),v=m[0],g=m[1],y=yx({inputs:{x:p},backend:n,attrs:{shape:[-1,i.wf.sizeFromShape(g)]}}),O=wx(y,y.dtype,"all",n);return h=yx(c?{inputs:{x:O},backend:n,attrs:{shape:i.ud.expandShapeToKeepDim(v,l)}}:{inputs:{x:O},backend:n,attrs:{shape:v}}),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(O),null!=f&&n.disposeIntermediateTensorInfo(p),h}};var qx={kernelName:i.g,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,s=r.axis,c=r.keepDims,u=a.shape.length,l=i.wf.parseAxisParam(s,a.shape),d=l,f=i.ud.getAxesPermutation(d,u),p=a;null!=f&&(p=Tx({inputs:{x:a},backend:n,attrs:{perm:f}}),d=i.ud.getInnerMostAxes(d.length,u)),i.ud.assertAxesAreInnerMostDims("any",d,u);var h,b=i.ud.computeOutAndReduceShapes(p.shape,d),m=Object(o.a)(b,2),v=m[0],g=m[1],y=yx({inputs:{x:p},backend:n,attrs:{shape:[-1,i.wf.sizeFromShape(g)]}}),O=wx(y,y.dtype,"any",n);return h=yx(c?{inputs:{x:O},backend:n,attrs:{shape:i.ud.expandShapeToKeepDim(v,l)}}:{inputs:{x:O},backend:n,attrs:{shape:v}}),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(O),null!=f&&n.disposeIntermediateTensorInfo(p),h}},Kx=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["A"];var a=t.windowSize,i=t.batchSize,o=t.outSize;r||this.variableNames.push("bestIndicesA"),this.outputShape=[i,o];var s="max"===n?">":"<",c=r?"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 * ".concat(a,";\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ").concat(a,"; i++) {\n int inIdx = ").concat(c,";\n float candidate = getA(batch, inIdx);\n if (candidate ").concat(s," bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n ")},Xx=function e(t,n,r,a){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,i.wf.assert(t.length>2,(function(){return"Packed arg".concat(r.charAt(0).toUpperCase()+r.slice(1)," supports only inputs with rank above 2.")}));var o=t[t.length-1],s=Math.ceil(o/n);this.outputShape=t.slice(0,-1),s>1&&this.outputShape.push(s),a||this.variableNames.push("bestIndicesA");var c,u,l=this.outputShape,d=l.length,f=Cy(d),p=jO("coords",d);if(1===s){var h=Cy(u=d+1);c="\n ".concat(h," sourceLocR = ").concat(h,"(").concat(p.join(),", 0);\n ++").concat(p[d-1],";\n ").concat(h," sourceLocG = ").concat(h,"(").concat(p.join(),", 0);\n ++").concat(p[d-2],";\n ").concat(h," sourceLocA = ").concat(h,"(").concat(p.join(),", 0);\n --").concat(p[d-1],";\n ").concat(h," sourceLocB = ").concat(h,"(").concat(p.join(),", 0);\n --").concat(p[d-2],";")}else u=d,c="\n ".concat(f," sourceLocR = coords;\n ++").concat(p[d-1],";\n ").concat(f," sourceLocG = coords;\n ++").concat(p[d-2],";\n ").concat(f," sourceLocA = coords;\n --").concat(p[d-1],";\n ").concat(f," sourceLocB = coords;\n --").concat(p[d-2],";");var b=["x","y","z","w","u","v"].slice(0,u),m="."+b[u-1],v=b.map((function(e){return"int "+e})),g=jO("sourceLocR",u-1).concat("inIdx.r"),y=jO("sourceLocG",u-1).concat("inIdx.g"),O=jO("sourceLocB",u-1).concat("inIdx.b"),x=jO("sourceLocA",u-1).concat("inIdx.a"),k="max"===r?"greaterThan":"lessThan",w=a?"":"\n inIdx = round(vec4(getBestIndicesAChannel(".concat(g.join(),"),\n getBestIndicesAChannel(").concat(y.join(),"),\n getBestIndicesAChannel(").concat(O.join(),"),\n getBestIndicesAChannel(").concat(x.join(),")));"),j="vec4(\n getAChannel(".concat(g.join(),"),\n hasNextCol ? getAChannel(").concat(y.join(),") : 0.,\n hasNextRow ? getAChannel(").concat(O.join(),") : 0.,\n hasNextRow && hasNextCol ? getAChannel(").concat(x.join(),") : 0.)"),S=a?"":"\n float getBestIndicesAChannel(".concat(v.join(),") {\n return getChannel(getBestIndicesA(").concat(b.join(),"),\n vec2(").concat(b.slice(-2).join(),"));\n }");this.userCode="\n float getAChannel(".concat(v.join(),") {\n return getChannel(getA(").concat(b.join(),"),\n vec2(").concat(b.slice(-2).join(),"));\n }\n ").concat(S,"\n void main() {\n ").concat(f," coords = getOutputCoords();\n bool hasNextCol = ").concat(p[d-1]," < ").concat(l[d-1]-1,";\n bool hasNextRow = ").concat(p[d-2]," < ").concat(l[d-2]-1,";\n ").concat(c,"\n ivec4 srcIdx = ivec4(sourceLocR").concat(m,", sourceLocG").concat(m,",\n sourceLocB").concat(m,", sourceLocA").concat(m,") * ").concat(n,";\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ").concat(j,";\n\n for (int i = 0; i < ").concat(n,"; i++) {\n inIdx = srcIdx;\n ").concat(w,"\n vec4 candidate = ").concat(j,";\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(").concat(k,"(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 Yx(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=t.shape[0],o=t.shape[1];null!=r&&(a=r.shape[0],o=r.shape[1]);var s=i.ud.computeOptimalWindowSize(o),c={windowSize:s,inSize:o,batchSize:a,outSize:Math.ceil(o/s)},u=new Kx(c,n,null==r),l=[t];null!=r&&l.push(r);var d=e.runWebGLProgram(u,l,"int32");if(1===d.shape[1])return d;var f=Yx(e,t,n,d);return e.disposeIntermediateTensorInfo(d),f}function $x(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=null!=r?r.shape:t.shape,o=a[a.length-1],s=i.ud.computeOptimalWindowSize(o),c=new Xx(a,s,n,null==r),u=null==r?[t]:[t,r],l=e.runWebGLProgram(c,u,"int32");if(l.shape.length===t.shape.length){var d=$x(e,t,n,l);return e.disposeIntermediateTensorInfo(l),d}return l}function Qx(e,t,n,r){var a=[n];if(i.ud.assertAxesAreInnerMostDims("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Object(i.Ud)().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){var s=[],c=i.ud.computeOutAndReduceShapes(t.shape,a),u=Object(o.a)(c,2),l=u[0],d=u[1],f=i.wf.sizeFromShape(d),p=yx({inputs:{x:t},backend:e,attrs:{shape:[-1,f]}});s.push(p);var h=Yx(e,p,r);s.push(h);var b=yx({inputs:{x:h},backend:e,attrs:{shape:l}});return s.forEach((function(t){return e.disposeIntermediateTensorInfo(t)})),b}return $x(e,t,r)}var Zx={kernelName:i.h,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.axis,s=i.wf.parseAxisParam(o,a.shape),c=i.ud.getAxesPermutation(s,a.shape.length),u=a,l=[];null!=c&&(u=Tx({inputs:{x:a},backend:n,attrs:{perm:c}}),l.push(u),s=i.ud.getInnerMostAxes(s.length,u.shape.length)),i.ud.assertAxesAreInnerMostDims("argMax",[s[0]],u.shape.length);var d=Qx(n,u,s[0],"max");return l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),d}};var Jx={kernelName:i.i,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.axis,s=i.wf.parseAxisParam(o,a.shape),c=i.ud.getAxesPermutation(s,a.shape.length),u=a,l=[];null!=c&&(u=Tx({inputs:{x:a},backend:n,attrs:{perm:c}}),l.push(u),s=i.ud.getInnerMostAxes(s.length,u.shape.length)),i.ud.assertAxesAreInnerMostDims("argMin",[s[0]],u.shape.length);var d=Qx(n,u,s[0],"min");return l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),d}},ek=ux({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),tk={kernelName:i.j,backendName:"webgl",kernelFunc:ek},nk=ux({opSnippet:"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));"}),rk={kernelName:i.k,backendName:"webgl",kernelFunc:nk},ak=ux({opSnippet:"if (isnan(x)) return x;\n return atan(x);\n"}),ik={kernelName:i.l,backendName:"webgl",kernelFunc:ak},ok=lx({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 vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),sk={kernelName:i.m,backendName:"webgl",kernelFunc:ok},ck=ux({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;"}),uk={kernelName:i.n,backendName:"webgl",kernelFunc:ck},lk=function e(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Object(Yr.a)(this,e),this.variableNames=["x"],"avg"===n&&r)throw new Error("Cannot compute positions for average pool.");var o=t.filterWidth,s=t.strideHeight,c=t.strideWidth,u=t.dilationHeight,l=t.dilationWidth,d=t.effectiveFilterHeight,f=t.effectiveFilterWidth,p=t.padInfo.top,h=t.padInfo.left;this.outputShape=t.outShape;var b="avg"===n,m="((batch * ".concat(t.inHeight," + xR) * ").concat(t.inWidth," + xC) * ").concat(t.inChannels," + d"),v="(xR * ".concat(t.inWidth," + xC) * ").concat(t.inChannels," + d"),g="0.0";if(b||(g="-1.0 / 1e-20"),r){var y=">=";this.userCode="\n const ivec2 strides = ivec2(".concat(s,", ").concat(c,");\n const ivec2 pads = ivec2(").concat(p,", ").concat(h,");\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 < ").concat(d,";\n wR += ").concat(u,") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int wC = 0; wC < ").concat(f,";\n wC += ").concat(l,") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ").concat(t.inWidth,") {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ").concat(y," currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ").concat(a?i?m:v:"wR * ".concat(f," + wC"),";\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n ")}else{var O="max",x="".concat(n,"(").concat(n,"(").concat(n,"(")+"minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===n&&(x="avgValue / count");var k=4*Math.floor(o/4),w=o%4,j="\n if (".concat(b,") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = ").concat(O,"(values, minMaxValue);\n }\n ");this.userCode="\n const ivec2 strides = ivec2(".concat(s,", ").concat(c,");\n const ivec2 pads = ivec2(").concat(p,", ").concat(h,");\n const float initializationValue = ").concat(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 >= ").concat(t.inWidth,") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(").concat(g,");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ").concat(d,";\n wR += ").concat(u,") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int wC = 0; wC < ").concat(k,"; wC += 4) {\n int xC = xCCorner + wC * ").concat(l,";\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ").concat(l,", d),\n getValue(batch, xR, xC + 2 * ").concat(l,", d),\n getValue(batch, xR, xC + 3 * ").concat(l,", d)\n );\n\n ").concat(j,"\n }\n\n int xC = xCCorner + ").concat(k,";\n if (").concat(1===w,") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ").concat(j,"\n } else if (").concat(2===w,") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ").concat(l,", d),\n initializationValue,\n initializationValue\n );\n\n ").concat(j,"\n } else if (").concat(3===w,") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ").concat(l,", d),\n getValue(batch, xR, xC + 2 * ").concat(l,", d),\n initializationValue\n );\n\n ").concat(j,"\n }\n }\n setOutput(").concat(x,");\n }\n ")}},dk=function e(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Object(Yr.a)(this,e),this.variableNames=["x"],"avg"===n&&r)throw new Error("Cannot compute positions for average pool.");var o=t.filterWidth,s=t.strideDepth,c=t.strideHeight,u=t.strideWidth,l=t.dilationDepth,d=t.dilationHeight,f=t.dilationWidth,p=t.effectiveFilterDepth,h=t.effectiveFilterHeight,b=t.effectiveFilterWidth,m=t.padInfo.front,v=t.padInfo.top,g=t.padInfo.left;this.outputShape=t.outShape;var y="avg"===n,O="0.0";if(y||(O="-1.0 / 1e-20"),r){var x=">=";this.userCode="\n const ivec3 strides =\n ivec3(".concat(s,", ").concat(c,", ").concat(u,");\n const ivec3 pads = ivec3(").concat(m,", ").concat(v,", ").concat(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 < ").concat(p,";\n wD += ").concat(l,") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ").concat(t.inDepth,") {\n continue;\n }\n\n for (int wR = 0; wR < ").concat(h,";\n wR += ").concat(d,") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int wC = 0; wC < ").concat(b,";\n wC += ").concat(f,") {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ").concat(t.inWidth,") {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ").concat(x," currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ").concat(a?i?"(((batch * ".concat(t.inDepth," + xD) * ").concat(t.inHeight," + xR) * ").concat(t.inWidth," + xC) * ").concat(t.inChannels," + ch"):"((xD * ".concat(t.inHeight," + xR) * ").concat(t.inWidth," + xC) * ").concat(t.inChannels," + ch"):"wD * ".concat(h," * ").concat(b," +\n wR * ").concat(b," + wC"),";\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n ")}else{var k="max",w="".concat(n,"(").concat(n,"(").concat(n,"(")+"minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===n&&(w="avgValue / count");var j=4*Math.floor(o/4),S=o%4,N="\n if (".concat(y,") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = ").concat(k,"(values, minMaxValue);\n }\n ");this.userCode="\n const ivec3 strides =\n ivec3(".concat(s,", ").concat(c,", ").concat(u,");\n const ivec3 pads = ivec3(").concat(m,", ").concat(v,", ").concat(g,");\n const float initializationValue = ").concat(O,";\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 >= ").concat(t.inWidth,") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4(").concat(O,");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ").concat(p,";\n wD += ").concat(l,") {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ").concat(t.inDepth,") {\n continue;\n }\n\n for (int wR = 0; wR < ").concat(h,";\n wR += ").concat(d,") {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int wC = 0; wC < ").concat(j,"; wC += 4) {\n int xC = xCCorner + wC * ").concat(f,";\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ").concat(f,", ch),\n getValue(batch, xD, xR, xC + 2 * ").concat(f,", ch),\n getValue(batch, xD, xR, xC + 3 * ").concat(f,", ch)\n );\n\n ").concat(N,"\n }\n\n int xC = xCCorner + ").concat(j,";\n if (").concat(1===S,") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ").concat(N,"\n } else if (").concat(2===S,") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ").concat(f,", ch),\n initializationValue,\n initializationValue\n );\n\n ").concat(N,"\n } else if (").concat(3===S,") {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ").concat(f,", ch),\n getValue(batch, xD, xR, xC + 2 * ").concat(f,", ch),\n initializationValue\n );\n\n ").concat(N,"\n }\n }\n setOutput(").concat(w,");\n }\n }\n ")}};var fk={kernelName:i.o,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;Pg(a,"avgPool");var o=r.filterSize,s=r.strides,c=r.pad,u=r.dimRoundingMode;i.wf.assert(i.ud.eitherStridesOrDilationsAreOne(s,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. "+"Got strides ".concat(s," and dilations '").concat(1,"'")}));var l=i.ud.computePool2DInfo(a.shape,o,s,1,c,u);if(1===l.filterWidth&&1===l.filterHeight&&i.wf.arraysEqual(l.inShape,l.outShape))return JO({inputs:{x:a},backend:n});var d=new lk(l,"avg",!1);return n.runWebGLProgram(d,[a],"float32")}};var pk={kernelName:i.p,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.filterSize,s=r.strides,c=r.pad,u=r.dimRoundingMode,l=r.dataFormat,d=i.ud.computePool3DInfo(a.shape,o,s,[1,1,1],c,u,l),f=new dk(d,"avg",!1);return n.runWebGLProgram(f,[a],"float32")}},hk=function e(t){Object(Yr.a)(this,e),this.variableNames=["dy"],this.outputShape=t.inShape;var n=t.filterHeight,r=t.filterWidth,a=t.strideHeight,i=t.strideWidth,o=t.dilationHeight,s=t.dilationWidth,c=t.effectiveFilterHeight,u=t.effectiveFilterWidth,l=c-1-t.padInfo.top,d=u-1-t.padInfo.left,f=1/(n*r);this.userCode="\n const ivec2 pads = ivec2(".concat(l,", ").concat(d,");\n const float avgMultiplier = float(").concat(f,");\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 < ").concat(c,";\n wR += ").concat(o,") {\n float dyR = float(dyRCorner + wR) / ").concat(a,".0;\n\n if (dyR < 0.0 || dyR >= ").concat(t.outHeight,".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ").concat(u,";\n wC+= ").concat(s,") {\n float dyC = float(dyCCorner + wC) / ").concat(i,".0;\n\n if (dyC < 0.0 || dyC >= ").concat(t.outWidth,".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n ")},bk=function e(t){Object(Yr.a)(this,e),this.variableNames=["dy"],this.outputShape=t.inShape;var n=t.filterDepth,r=t.filterHeight,a=t.filterWidth,i=t.strideDepth,o=t.strideHeight,s=t.strideWidth,c=t.dilationDepth,u=t.dilationHeight,l=t.dilationWidth,d=t.effectiveFilterDepth,f=t.effectiveFilterHeight,p=t.effectiveFilterWidth,h=d-1-t.padInfo.front,b=f-1-t.padInfo.top,m=p-1-t.padInfo.left,v=1/(n*r*a);this.userCode="\n const ivec3 pads = ivec3(".concat(h,", ").concat(b,", ").concat(m,");\n const float avgMultiplier = float(").concat(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 < ").concat(d,";\n wD += ").concat(c,") {\n float dyD = float(dyDCorner + wD) / ").concat(i,".0;\n\n if (dyD < 0.0 || dyD >= ").concat(t.outDepth,".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ").concat(f,";\n wR += ").concat(u,") {\n float dyR = float(dyRCorner + wR) / ").concat(o,".0;\n\n if (dyR < 0.0 || dyR >= ").concat(t.outHeight,".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ").concat(p,";\n wC += ").concat(l,") {\n float dyC = float(dyCCorner + wC) / ").concat(s,".0;\n\n if (dyC < 0.0 || dyC >= ").concat(t.outWidth,".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n ")};var mk={kernelName:i.q,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.input,s=r.filterSize,c=r.strides,u=r.pad,l=r.dimRoundingMode,d=i.ud.computePool3DInfo(o.shape,s,c,[1,1,1],u,l),f=new bk(d);return n.runWebGLProgram(f,[a],o.dtype)}};var vk={kernelName:i.r,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.input,s=o;Pg([a,o],"avgPoolGrad");var c=r.filterSize,u=r.strides,l=r.pad,d=i.ud.computePool2DInfo(s.shape,c,u,1,l),f=new hk(d);return n.runWebGLProgram(f,[a],s.dtype)}};var gk={kernelName:i.s,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs;return Ax({a:t.a,b:t.b,transposeA:r.transposeA,transposeB:r.transposeB,backend:n})}},yk=function e(t,n,r,a,o,s){Object(Yr.a)(this,e),this.outputShape=[],this.variableNames=["x","mean","variance"],i.ud.assertAndGetBroadcastShape(t,n),i.ud.assertAndGetBroadcastShape(t,r);var c="0.0";null!=a&&(i.ud.assertAndGetBroadcastShape(t,a),this.variableNames.push("offset"),c="getOffsetAtOutCoords()");var u="1.0";null!=o&&(i.ud.assertAndGetBroadcastShape(t,o),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=t,this.userCode="\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ".concat(c,";\n float scale = ").concat(u,";\n float inv = scale * inversesqrt(variance + float(").concat(s,"));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n ")},Ok=function e(t,n,r,a,o,s){Object(Yr.a)(this,e),this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],i.ud.assertAndGetBroadcastShape(t,n),i.ud.assertAndGetBroadcastShape(t,r);var c="vec4(0.0)";null!=a&&(i.ud.assertAndGetBroadcastShape(t,a),this.variableNames.push("offset"),c="getOffsetAtOutCoords()");var u="vec4(1.0)";null!=o&&(i.ud.assertAndGetBroadcastShape(t,o),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=t,this.userCode="\n void main() {\n vec4 offset = ".concat(c,";\n vec4 scale = ").concat(u,";\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(").concat(s,"));\n\n setOutput((x - mean) * inv + offset);\n }\n ")},xk={kernelName:i.jb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.mean,s=t.variance,c=t.offset,u=t.scale;i.wf.assert(o.shape.length===s.shape.length,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),i.wf.assert(null==c||o.shape.length===c.shape.length,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),i.wf.assert(null==u||o.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 d=[a,o,s],f=null;null!=c&&(f=c.shape,d.push(c));var p=null;null!=u&&(p=u.shape,d.push(u));var h=Object(i.Ud)().getBool("WEBGL_PACK_NORMALIZATION")?new Ok(a.shape,o.shape,s.shape,f,p,l):new yk(a.shape,o.shape,s.shape,f,p,l);return n.runWebGLProgram(h,d,d[0].dtype)}},kk=function e(t){Object(Yr.a)(this,e),this.variableNames=["source"],this.outputShape=t,this.rank=t.length;var n=Cy(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];var r,a=function(e){if(1===e)return"sourceLoc";if(e<=6)return wk.slice(0,e).map((function(e){return"sourceLoc."+e})).join(",");throw Error("Slicing for rank ".concat(e," is not yet supported"))}(this.rank),i=t.map((function(e,t){return"sourceLoc.".concat(wk[t]," = start[").concat(t,"] + coords.").concat(wk[t],";")}));r="\n ".concat(n," sourceLoc;\n ").concat(n," coords = getOutputCoords();\n ").concat(i.join("\n"),"\n "),this.userCode="\n void main() {\n ".concat(r,"\n setOutput(getSource(").concat(a,"));\n }\n ")},wk=["x","y","z","w","u","v"];var jk=function e(t){Object(Yr.a)(this,e),this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];var n=Cy(this.rank),r=jO("coords",this.rank),a=jO("sourceLoc",this.rank),i=1===this.rank?"sourceLoc":"vec2(".concat(a.slice(-2).join(),")"),o="getChannel(getSource(".concat(a.join(),"), ").concat(i,")"),s="\n result.x = ".concat(o,";\n if (++").concat(r[this.rank-1]," < ").concat(t[this.rank-1],") {\n ++").concat(a[this.rank-1],";\n result.y = ").concat(o,";\n --").concat(a[this.rank-1],";\n }\n "),c=1===this.rank?"":"\n --".concat(r[this.rank-1],";\n if (++").concat(r[this.rank-2]," < ").concat(t[this.rank-2],") {\n ++").concat(a[this.rank-2],";\n result.z = ").concat(o,";\n if (++").concat(r[this.rank-1]," < ").concat(t[this.rank-1],") {\n ++").concat(a[this.rank-1],";\n result.w = ").concat(o,";\n }\n }\n "),u=this.rank<=4?"sourceLoc = coords +\n ".concat(n,"(").concat(t.map((function(e,t){return"start[".concat(t,"]")})).join(),");"):t.map((function(e,t){return"".concat(a[t]," = ").concat(r[t]," + start[").concat(t,"];")})).join("\n");this.userCode="\n void main() {\n ".concat(n," coords = getOutputCoords();\n ").concat(n," sourceLoc;\n ").concat(u,"\n vec4 result = vec4(0.);\n ").concat(s,"\n ").concat(c,"\n setOutput(result);\n }\n ")};function Sk(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,s=r.begin,c=r.size,u=i.af.parseSliceParams(a,s,c),l=Object(o.a)(u,2),d=l[0],f=l[1];if(i.af.assertParamsValid(a,d,f),0===i.wf.sizeFromShape(f))return n.makeTensorInfo(f,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){var p=n.texData.get(a.dataId),h=lO(p.values,d,f,a.shape,a.dtype);return n.makeTensorInfo(f,a.dtype,h)}var b=n.texData.get(a.dataId).isPacked,m=i.af.isSliceContinous(a.shape,d,f);if(b||!m){var v=Object(i.Ud)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new jk(f):new kk(f),g=[d];return n.runWebGLProgram(v,[a],a.dtype,g)}return n.uploadToGPU(a.dataId),function(e,t,n,r){var a=r.texData.get(e.dataId),o=r.makeTensorInfo(n,e.dtype),s=r.texData.get(o.dataId);Object.assign(s,a),s.refCount=1,s.shape=n,s.dtype=e.dtype;var c=i.af.computeFlatOffset(t,i.wf.computeStrides(e.shape));a.slice&&(c+=a.slice.flatOffset),s.slice={flatOffset:c,origDataId:a.slice&&a.slice.origDataId||e.dataId};var u=r.dataRefCount.get(s.slice.origDataId)||1;return r.dataRefCount.set(s.slice.origDataId,u+1),o}(a,d,f,n)}var Nk={kernelName:i.Fc,backendName:"webgl",kernelFunc:Sk},Ik={kernelName:i.t,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.blockShape,s=r.crops;i.wf.assert(a.shape.length<=4,(function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"}));var c=o.reduce((function(e,t){return e*t})),u=i.ud.getReshaped(a.shape,o,c),l=i.ud.getPermuted(u.length,o.length),d=i.ud.getReshapedPermuted(a.shape,o,c),f=i.ud.getSliceBeginCoords(s,o.length),p=i.ud.getSliceSize(d,s,o.length),h=[],b=yx({inputs:{x:a},backend:n,attrs:{shape:u}}),m=Tx({inputs:{x:b},backend:n,attrs:{perm:l}}),v=yx({inputs:{x:m},backend:n,attrs:{shape:d}}),g=Sk({inputs:{x:v},backend:n,attrs:{begin:f,size:p}});return h.push(b),h.push(m),h.push(v),h.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),g}};var Ck={kernelName:i.u,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),c=n.readSync(i.dataId),u=Ly(s,c,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,u)}},Tk=lx({opSnippet:"return float(a != b);",cpuKernelImpl:iO,dtype:"bool"}),Ek={kernelName:i.ac,backendName:"webgl",kernelFunc:Tk};function Ak(e){var t=e.inputs,n=e.backend,r=t.input;return JO({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}var Rk={kernelName:i.kc,backendName:"webgl",kernelFunc:Ak};var Fk={kernelName:i.v,backendName:"webgl",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=t.attrs,o=n.x,s=a.dtype;if("complex64"===s){if("complex64"===o.dtype)return JO({inputs:{x:o},backend:r});var c=i.Bf(o.shape),u=e({inputs:{x:o},backend:r,attrs:{dtype:"float32"}}),l=tx({inputs:{real:u,imag:c},backend:r});return c.dispose(),r.disposeIntermediateTensorInfo(u),l}if("complex64"===o.dtype){var d=Ak({inputs:{input:o},backend:r}),f=e({inputs:{x:d},backend:r,attrs:{dtype:s}});return r.disposeIntermediateTensorInfo(d),f}if(!i.wf.hasEncodingLoss(o.dtype,s)){var p=JO({inputs:{x:o},backend:r});return{dataId:p.dataId,shape:p.shape,dtype:s}}if("int32"===s)return function(e,t){var n=new AO(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(o,r);if("bool"===s){var h=r.makeTensorInfo([],"bool",i.wf.getTypedArrayFromDType("bool",1)),b=Tk({inputs:{a:o,b:h},backend:r});return r.disposeIntermediateTensorInfo(h),b}throw new Error("Error in Cast: failed to cast ".concat(o.dtype," to ").concat(s))}},Dk="return ceil(x);",_k=ux({opSnippet:Dk,packedOpSnippet:Dk,cpuKernelImpl:By}),Mk={kernelName:i.w,backendName:"webgl",kernelFunc:_k},zk=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=t,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 "},Lk=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=t,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 Pk={kernelName:i.x,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,o=n.x,s=a.clipValueMin,c=a.clipValueMax;t=Object(i.Ud)().getBool("WEBGL_PACK_CLIP")?new Lk(o.shape):new zk(o.shape);var u=[[s],[c]];return r.runWebGLProgram(t,[o],o.dtype,u)}},Bk=function e(t){Object(Yr.a)(this,e),this.variableNames=["real","imag"],this.outputShape=t,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "};function Wk(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}var Uk={kernelName:i.z,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=n.texData.get(r.dataId),i=new Bk(r.shape),o=[Wk(r,a.complexTensorInfos.real),Wk(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(i,o,o[0].dtype)}},Vk=function e(t){Object(Yr.a)(this,e),this.outputShape=[],this.outputShape=i.ud.computeOutShape(t,1),this.variableNames=t.map((function(e,t){return"T".concat(t)}));var n=new Array(t.length-1);n[0]=t[0][1];for(var r=1;r= ").concat(u[b-1],") {\n return getChannel(\n getT").concat(b,"(").concat(Gk(c,d,m),"),\n vec2(").concat(Gk(f,d,m),"));\n }")}var v=u.length,g=u[u.length-1];h+="\n return getChannel(\n getT".concat(v,"(").concat(Gk(c,d,g),"),\n vec2(").concat(Gk(f,d,g),"));"),this.userCode="\n float getValue(".concat(c.map((function(e){return"int "+e})),") {\n ").concat(h,"\n }\n\n void main() {\n ").concat(o," coords = getOutputCoords();\n vec4 result = vec4(getValue(").concat(s,"), 0., 0., 0.);\n\n ").concat(s[a-1]," = ").concat(s[a-1]," + 1;\n if (").concat(s[a-1]," < ").concat(r[a-1],") {\n result.g = getValue(").concat(s,");\n }\n\n ").concat(s[a-2]," = ").concat(s[a-2]," + 1;\n if (").concat(s[a-2]," < ").concat(r[a-2],") {\n result.a = getValue(").concat(s,");\n }\n\n ").concat(s[a-1]," = ").concat(s[a-1]," - 1;\n if (").concat(s[a-2]," < ").concat(r[a-2]," &&\n ").concat(s[a-1]," < ").concat(r[a-1],") {\n result.b = getValue(").concat(s,");\n }\n setOutput(result);\n }\n ")};function Gk(e,t,n){var r=e.indexOf(t);return e.map((function(e,t){return t===r?"".concat(e," - ").concat(n):e})).join()}function qk(e){var t=e.inputs,n=e.backend,r=t.input;return JO({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}var Kk={kernelName:i.sb,backendName:"webgl",kernelFunc:qk};function Xk(e,t,n){var r=e[0].dtype;if("complex64"===r){var a=e.map((function(e){return Ak({inputs:{input:e},backend:n})})),o=e.map((function(e){return qk({inputs:{input:e},backend:n})})),s=Xk(a,t,n),c=Xk(o,t,n),u=tx({inputs:{real:s,imag:c},backend:n});return a.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),o.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(c),u}var l=n.shouldExecuteOnCPU(e);if("string"===r&&(l=!0),l){var d=e.map((function(e){var r=i.wf.sizeFromShape(e.shape.slice(t));return yx({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})})),f=d.map((function(e){return{vals:n.readSync(e.dataId),shape:e.shape}})),p=i.ud.computeOutShape(d.map((function(e){return e.shape})),1),h=1===d[0].shape[0],b=Wy(f,p,r,h),m=i.ud.computeOutShape(e.map((function(e){return e.shape})),t),v=n.makeTensorInfo(m,r,b);return d.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),v}if(e.length>Object(i.Ud)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var g=Math.floor(e.length/2),y=Xk(e.slice(0,g),t,n),O=Xk(e.slice(g),t,n),x=Xk([y,O],t,n);return n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(O),x}if(Object(i.Ud)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){var k=new Hk(e.map((function(e){return e.shape})),t);return n.runWebGLProgram(k,e,r)}var w=function(e,t,n){var r=i.ud.computeOutShape(e.map((function(e){return e.shape})),t);return{tensors2D:e.map((function(e){return yx({inputs:{x:e},attrs:{shape:[-1,i.wf.sizeFromShape(e.shape.slice(t))]},backend:n})})),outShape:r}}(e,t,n),j=w.tensors2D,S=w.outShape,N=new Vk(j.map((function(e){return e.shape}))),I=n.runWebGLProgram(N,j,r);j.forEach((function(e){return n.disposeIntermediateTensorInfo(e)}));var C=yx({inputs:{x:I},attrs:{shape:S},backend:n});return n.disposeIntermediateTensorInfo(I),C}function Yk(e){var t=e.inputs,n=e.backend,r=e.attrs.axis,a=i.wf.parseAxisParam(r,t[0].shape)[0],o=i.ud.computeOutShape(t.map((function(e){return e.shape})),a);if(0===i.wf.sizeFromShape(o))return n.makeTensorInfo(o,t[0].dtype,[]);var s=t.filter((function(e){return i.wf.sizeFromShape(e.shape)>0}));if(1===s.length)return JO({inputs:{x:s[0]},backend:n});var c=s.map((function(e){return e.shape}));return i.ud.assertParamsConsistent(c,a),Xk(s,a,n)}var $k={kernelName:i.A,backendName:"webgl",kernelFunc:Yk},Qk=function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Object(Yr.a)(this,e),this.variableNames=["x","W"],this.outputShape=t.outShape;var o=t.padInfo.top,s=t.padInfo.left,c=t.strideHeight,u=t.strideWidth,l=t.dilationHeight,d=t.dilationWidth,f=t.filterHeight,p=t.filterWidth,h=4*Math.floor(t.inChannels/4),b=t.inChannels%4,m="channelsLast"===t.dataFormat,v=m?1:2,g=m?2:3,y=m?3:1,O="",x="";r&&(O=a?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ".concat(r,"\n }"):i?"float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ".concat(r,"\n }"):"\n float activation(float x) {\n ".concat(r,"\n }\n "),x="result = activation(result);");var k=n?"result += getBiasAtOutCoords();":"";n&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),i&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n ".concat(O,"\n\n const ivec2 strides = ivec2(").concat(c,", ").concat(u,");\n const ivec2 pads = ivec2(").concat(o,", ").concat(s,");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[").concat(y,"];\n\n ivec2 xRCCorner =\n ivec2(coords[").concat(v,"], coords[").concat(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 < ").concat(f,"; wR++) {\n int xR = xRCorner + wR * ").concat(l,";\n\n if (xR < 0 || xR >= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int wC = 0; wC < ").concat(p,"; wC++) {\n int xC = xCCorner + wC * ").concat(d,";\n\n if (xC < 0 || xC >= ").concat(t.inWidth,") {\n continue;\n }\n\n for (int d1 = 0; d1 < ").concat(h,"; 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 (").concat(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 (").concat(1===b,") {\n\n if (").concat(m,") {\n dotProd +=\n getX(batch, xR, xC, ").concat(h,") *\n getW(wR, wC, ").concat(h,", d2);\n } else {\n dotProd +=\n getX(batch, ").concat(h,", xR, xC) *\n getW(wR, wC, ").concat(h,", d2);\n }\n\n } else if (").concat(2===b,") {\n vec2 wValues = vec2(\n getW(wR, wC, ").concat(h,", d2),\n getW(wR, wC, ").concat(h," + 1, d2)\n );\n\n if (").concat(m,") {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ").concat(h,"),\n getX(batch, xR, xC, ").concat(h," + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ").concat(h,", xR, xC),\n getX(batch, ").concat(h," + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (").concat(3===b,") {\n vec3 wValues = vec3(\n getW(wR, wC, ").concat(h,", d2),\n getW(wR, wC, ").concat(h," + 1, d2),\n getW(wR, wC, ").concat(h," + 2, d2)\n );\n\n if (").concat(m,") {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ").concat(h,"),\n getX(batch, xR, xC, ").concat(h," + 1),\n getX(batch, xR, xC, ").concat(h," + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ").concat(h,", xR, xC),\n getX(batch, ").concat(h," + 1, xR, xC),\n getX(batch, ").concat(h," + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ").concat(k,"\n ").concat(x,"\n setOutput(result);\n }\n ")},Zk=function e(t){Object(Yr.a)(this,e),this.variableNames=["x","W"],this.outputShape=t.outShape;var n=t.padInfo.front,r=t.padInfo.top,a=t.padInfo.left,i=t.strideDepth,o=t.strideHeight,s=t.strideWidth,c=t.dilationDepth,u=t.dilationHeight,l=t.dilationWidth,d=t.filterDepth,f=t.filterHeight,p=t.filterWidth,h=4*Math.floor(t.inChannels/4),b=t.inChannels%4;this.userCode="\n const ivec3 strides = ivec3(".concat(i,", ").concat(o,", ").concat(s,");\n const ivec3 pads = ivec3(").concat(n,", ").concat(r,", ").concat(a,");\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 < ").concat(d,"; wF++) {\n int xF = xFCorner + wF * ").concat(c,";\n\n if (xF < 0 || xF >= ").concat(t.inDepth,") {\n continue;\n }\n\n for (int wR = 0; wR < ").concat(f,"; wR++) {\n int xR = xRCorner + wR * ").concat(u,";\n\n if (xR < 0 || xR >= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int wC = 0; wC < ").concat(p,"; wC++) {\n int xC = xCCorner + wC * ").concat(l,";\n\n if (xC < 0 || xC >= ").concat(t.inWidth,") {\n continue;\n }\n\n for (int d1 = 0; d1 < ").concat(h,"; 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 (").concat(1===b,") {\n dotProd +=\n getX(batch, xF, xR, xC, ").concat(h,") *\n getW(wF, wR, wC, ").concat(h,", d2);\n } else if (").concat(2===b,") {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ").concat(h,"),\n getX(batch, xF, xR, xC, ").concat(h," + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ").concat(h,", d2),\n getW(wF, wR, wC, ").concat(h," + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (").concat(3===b,") {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ").concat(h,"),\n getX(batch, xF, xR, xC, ").concat(h," + 1),\n getX(batch, xF, xR, xC, ").concat(h," + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ").concat(h,", d2),\n getW(wF, wR, wC, ").concat(h," + 1, d2),\n getW(wF, wR, wC, ").concat(h," + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ")},Jk=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var a=r.filterWidth,i=r.inChannels,o=r.strideWidth,s=r.strideHeight,c=r.padInfo,u=r.outWidth,l=r.dilationWidth,d=r.dilationHeight,f=r.dataFormat,p=c.left,h=c.top,b=i*a,m=Wg(),v="channelsLast"===f,g=v?0:1,y=v?1:2,O="",x=0;x<=1;x++)for(var k=0;k<=1;k++)O+="\n blockIndex = rc.y + ".concat(k,";\n pos = rc.x + ").concat(x,";\n\n if(blockIndex < ").concat(t[1]," && pos < ").concat(t[0],") {\n offsetY = int(blockIndex / (").concat(u,")) * ").concat(s," - ").concat(h,";\n d0 = offsetY + ").concat(d," * (pos / ").concat(b,");\n\n if(d0 < ").concat(n[g]," && d0 >= 0) {\n\n offsetX = int(mod(float(blockIndex), ").concat(u,".) * ").concat(o,". - ").concat(p,".);\n d1 = offsetX + ").concat(l," * (int(mod(float(pos), ").concat(b,".) / ").concat(i,".));\n\n if(d1 < ").concat(n[y]," && d1 >= 0) {\n\n ch = int(mod(float(pos), ").concat(i,".));\n\n if (").concat(v,") {\n innerDims = vec2(d1, ch);\n result[").concat(2*x+k,"] = getChannel(\n getA(d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[").concat(2*x+k,"] = getChannel(\n getA(ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n ");this.userCode="\n void main() {\n ivec2 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ".concat(O,"\n\n ").concat(m.output," = result;\n }\n ")};function ew(e){var t,n=e.x,r=e.filter,a=e.convInfo,o=e.backend,s=e.bias,c=void 0===s?null:s,u=e.preluActivationWeights,l=void 0===u?null:u,d=e.leakyreluAlpha,f=void 0===d?0:d,p=e.activation,h=void 0===p?null:p,b=n.shape,m=o.texData.get(n.dataId),v=a.inChannels,g=b[0]*b[1]*b[2],y=a.outChannels,O="channelsLast"===a.dataFormat,x=[],k=(1===g||1===y)&&v>1e3,w=b[2]%2!==0&&!!m.isPacked;if(!k&&Object(i.Ud)().getBool("WEBGL_LAZILY_UNPACK")&&Object(i.Ud)().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&w){var j=O?b[0]*b[1]*(b[2]+1):b[0]*b[2]*(b[3]+1),S={dataId:n.dataId,shape:[1,j,a.inChannels],dtype:n.dtype},N=m.shape;m.shape=m.shape.slice(),m.shape[m.shape.length-2]++,i.wf.assert(Dg(m.shape,S.shape),(function(){return"packed reshape ".concat(m.shape," to ").concat(S.shape," isn't free")}));var I=yx({inputs:{x:r},backend:o,attrs:{shape:[1,a.inChannels,a.outChannels]}});x.push(I);var C=Ax({a:S,b:I,backend:o,transposeA:false,transposeB:false,bias:c,activation:h,preluActivationWeights:l,leakyreluAlpha:f}),T=o.texData.get(C.dataId);i.wf.assert(T.isPacked,(function(){return"batchMatMul result is expected to be packed"})),m.shape=N,T.shape=a.outShape,(t=JO({inputs:{x:C},backend:o})).shape=a.outShape,x.push(C)}else{var E=yx({inputs:{x:n},backend:o,attrs:{shape:[1,O?b[0]*b[1]*b[2]:b[0]*b[2]*b[3],a.inChannels]}}),A=yx({inputs:{x:r},backend:o,attrs:{shape:[1,a.inChannels,a.outChannels]}}),R=Ax({a:E,b:A,transposeA:false,transposeB:false,backend:o,bias:c,activation:h,preluActivationWeights:l,leakyreluAlpha:f});t=yx({inputs:{x:R},backend:o,attrs:{shape:a.outShape}}),x.push(E),x.push(A),x.push(R)}for(var F=0,D=x;F= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int yC = 0; yC < ").concat(t.outWidth,"; yC++) {\n int xC = wC + yC * ").concat(r," - ").concat(i,";\n\n if (xC < 0 || xC >= ").concat(t.inWidth,") {\n continue;\n }\n\n if (").concat(o,") {\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n } else {\n float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n ")},aw=function e(t){Object(Yr.a)(this,e),this.variableNames=["dy","W"],this.outputShape=t.inShape;var n=t.filterHeight,r=t.filterWidth,a=t.strideHeight,i=t.strideWidth,o="channelsLast"===t.dataFormat,s=n-1-t.padInfo.top,c=r-1-t.padInfo.left,u=o?1:2,l=o?2:3,d=o?3:1;this.userCode="\n const ivec2 pads = ivec2(".concat(s,", ").concat(c,");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[").concat(d,"];\n\n ivec2 dyCorner = ivec2(coords[").concat(u,"], coords[").concat(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 < ").concat(n,"; wR++) {\n float dyR = float(dyRCorner + wR) / ").concat(a,".0;\n\n if (dyR < 0.0 || dyR >= ").concat(t.outHeight,".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ").concat(n," - 1 - wR;\n\n for (int wC = 0; wC < ").concat(r,"; wC++) {\n float dyC = float(dyCCorner + wC) / ").concat(i,".0;\n\n if (dyC < 0.0 || dyC >= ").concat(t.outWidth,".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ").concat(r," - 1 - wC;\n\n for (int d2 = 0; d2 < ").concat(t.outChannels,"; d2++) {\n\n if (").concat(o,") {\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 ")},iw=function e(t){Object(Yr.a)(this,e),this.variableNames=["x","dy"],this.outputShape=t.filterShape;var n=t.strideDepth,r=t.strideHeight,a=t.strideWidth,i=t.padInfo.front,o=t.padInfo.top,s=t.padInfo.left;this.userCode="\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < ".concat(t.batchSize,"; b++) {\n for (int yF = 0; yF < ").concat(t.outDepth,"; yF++) {\n int xF = wF + yF * ").concat(n," - ").concat(i,";\n\n if (xF < 0 || xF >= ").concat(t.inDepth,") {\n continue;\n }\n\n for (int yR = 0; yR < ").concat(t.outHeight,"; yR++) {\n int xR = wR + yR * ").concat(r," - ").concat(o,";\n\n if (xR < 0 || xR >= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int yC = 0; yC < ").concat(t.outWidth,"; yC++) {\n int xC = wC + yC * ").concat(a," - ").concat(s,";\n\n if (xC < 0 || xC >= ").concat(t.inWidth,") {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ")},ow=function e(t){Object(Yr.a)(this,e),this.variableNames=["dy","W"],this.outputShape=t.inShape;var n=t.filterDepth,r=t.filterHeight,a=t.filterWidth,i=t.strideDepth,o=t.strideHeight,s=t.strideWidth,c=n-1-t.padInfo.front,u=r-1-t.padInfo.top,l=a-1-t.padInfo.left;this.userCode="\n const ivec3 pads = ivec3(".concat(c,", ").concat(u,", ").concat(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 < ").concat(n,"; wF++) {\n float dyF = float(dyFCorner + wF) / ").concat(i,".0;\n\n if (dyF < 0.0 || dyF >= ").concat(t.outDepth,".0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ").concat(n," - 1 - wF;\n\n for (int wR = 0; wR < ").concat(r,"; wR++) {\n float dyR = float(dyRCorner + wR) / ").concat(o,".0;\n\n if (dyR < 0.0 || dyR >= ").concat(t.outHeight,".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ").concat(r," - 1 - wR;\n\n for (int wC = 0; wC < ").concat(a,"; wC++) {\n float dyC = float(dyCCorner + wC) / ").concat(s,".0;\n\n if (dyC < 0.0 || dyC >= ").concat(t.outWidth,".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ").concat(a," - 1 - wC;\n\n for (int d2 = 0; d2 < ").concat(t.outChannels,"; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ")};var sw={kernelName:i.C,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.dy,s=r.strides,c=r.pad,u=r.dataFormat,l=r.dimRoundingMode,d=r.filterShape,f=i.ud.convertConv2DDataFormat(u),p=i.ud.computeConv2DInfo(a.shape,d,s,1,c,l,!1,f),h=new rw(p);return n.runWebGLProgram(h,[a,o],"float32")}};var cw={kernelName:i.D,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.filter,s=r.inputShape,c=r.strides,u=r.pad,l=r.dataFormat,d=r.dimRoundingMode,f=i.ud.convertConv2DDataFormat(l),p=i.ud.computeConv2DInfo(s,o.shape,c,1,u,d,!1,f),h=new aw(p);return n.runWebGLProgram(h,[a,o],"float32")}};var uw={kernelName:i.E,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.filter,s=r.strides,c=r.pad,u=r.dilations,l=i.ud.computeConv3DInfo(a.shape,o.shape,s,u,c),d=new Zk(l);return n.runWebGLProgram(d,[a,o],"float32")}};var lw={kernelName:i.F,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.dy,s=r.strides,c=r.pad,u=r.filterShape,l=i.ud.computeConv3DInfo(a.shape,u,s,1,c),d=new iw(l);return n.runWebGLProgram(d,[a,o],"float32")}};var dw={kernelName:i.G,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.filter,s=r.pad,c=r.strides,u=r.inputShape,l=i.ud.computeConv3DInfo(u,o.shape,c,1,s),d=new ow(l);return n.runWebGLProgram(d,[a,o],"float32")}},fw=ux({opSnippet:"if (isnan(x)) return x;\n return cos(x);\n"}),pw={kernelName:i.H,backendName:"webgl",kernelFunc:fw},hw=ux({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),bw={kernelName:i.I,backendName:"webgl",kernelFunc:hw},mw=function e(t,n,r,a,i){Object(Yr.a)(this,e),this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var s=Object(o.a)(t,4),c=s[0],u=s[1],l=s[2],d=s[3],f=Object(o.a)(n,1)[0],p=Object(o.a)(r,2),h=p[0],b=p[1];this.outputShape=[f,h,b,d];var m="bilinear"===a?1:0,v="".concat(u-1,".0"),g="".concat(l-1,".0"),y=h>1?["".concat((u-1)/(h-1)),"(y2-y1) * height_ratio","y1*".concat(v," + float(y)*(height_scale)")]:["0.0","0.0","0.5 * (y1+y2) * ".concat(v)],O=Object(o.a)(y,3),x=O[0],k=O[1],w=O[2],j=b>1?["".concat((l-1)/(b-1)),"(x2-x1) * width_ratio","x1*".concat(g," + float(x)*(width_scale)")]:["0.0","0.0","0.5 * (x1+x2) * ".concat(g)],S=Object(o.a)(j,3),N=S[0],I=S[1],C=S[2];this.userCode="\n const float height_ratio = float(".concat(x,");\n const float width_ratio = float(").concat(N,");\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 >= ").concat(c,") {\n return;\n }\n\n float height_scale = ").concat(k,";\n float width_scale = ").concat(I,";\n\n float in_y = ").concat(w,";\n if( in_y < 0.0 || in_y > ").concat(v," ) {\n setOutput(float(").concat(i,"));\n return;\n }\n float in_x = ").concat(C,";\n if( in_x < 0.0 || in_x > ").concat(g," ) {\n setOutput(float(").concat(i,"));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(").concat(m," == 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 ")},vw={kernelName:i.J,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,c=r.method,u=r.extrapolationValue,l=new mw(a.shape,i.shape,s,c,u);return n.runWebGLProgram(l,[a,i,o],"float32")}},gw=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}],this.outputShape=t;var a=t.length,i=n?"0.0":"getX(".concat(yw(a,"coords"),")"),o=t[t.length-1],s="",c="";n?(s=r?"end != ".concat(o-1):"end != 0",c=r?"end + 1":"end - 1"):(s=r?"end + pow2 < ".concat(o):"end >= pow2",c=r?"end + pow2":"end - pow2"),this.userCode="\n void main() {\n ".concat(Cy(a)," coords = getOutputCoords();\n int end = ").concat(Ow(a,"coords"),";\n float val = ").concat(i,";\n int pow2 = int(pow(2.0, index));\n if (").concat(s,") {\n int idx = ").concat(c,";\n ").concat(Ow(a,"coords")," = idx;\n val += getX(").concat(yw(a,"coords"),");\n }\n setOutput(val);\n }\n ")};function yw(e,t){if(1===e)return"".concat(t);if(2===e)return"".concat(t,".x, ").concat(t,".y");if(3===e)return"".concat(t,".x, ").concat(t,".y, ").concat(t,".z");if(4===e)return"".concat(t,".x, ").concat(t,".y, ").concat(t,".z, ").concat(t,".w");throw Error("Cumulative sum for rank ".concat(e," is not yet supported"))}function Ow(e,t){if(1===e)return"".concat(t);if(2===e)return"".concat(t,".y");if(3===e)return"".concat(t,".z");if(4===e)return"".concat(t,".w");throw Error("Cumulative sum for rank ".concat(e," is not yet supported"))}var xw={kernelName:i.K,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.axis,s=r.exclusive,c=r.reverse,u=a.shape.length,l=i.ud.getAxesPermutation([o],u),d=a;null!=l&&(d=Tx({inputs:{x:a},backend:n,attrs:{perm:l}}));var f=i.ud.getInnerMostAxes(1,u)[0];if(f!==u-1)throw new Error("WebGL cumsum shader expects an inner-most axis=".concat(a.shape.length-1," ")+"but got axis=".concat(o));for(var p=d.shape[f],h=JO({inputs:{x:d},backend:n}),b=0;b<=Math.ceil(Math.log2(p))-1;b++){var m=new gw(d.shape,!1,c),v=[[b]],g=h;h=n.runWebGLProgram(m,[h],h.dtype,v),n.disposeIntermediateTensorInfo(g)}if(s){var y=new gw(d.shape,s,c),O=h;h=n.runWebGLProgram(y,[h],h.dtype),n.disposeIntermediateTensorInfo(O)}if(null!=l){var x=Tx({inputs:{x:h},backend:n,attrs:{perm:i.ud.getUndoAxesPermutation(l)}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),x}return h}};var kw={kernelName:i.M,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 c=n.readSync(a.dataId),u=n.readSync(i.dataId),l=Ly(c,u,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,l)}if(2===a.shape.length){var d=n.bufferSync(a),f=n.bufferSync(i),p=Py(d,f,o,s);return n.makeTensorInfo(p.shape,i.dtype,p.values)}throw new Error("Error in denseBincount: input must be at most rank 2, but got rank"+"".concat(a.shape.length,"."))}},ww=function(){function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=n,this.dataFormat=r,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = ".concat(this.getHeightCoordString(),";\n int w = ").concat(this.getWidthCoordString(),";\n int d = ").concat(this.getDepthCoordString(),";\n\n int in_h = h / ").concat(n,";\n int offset_h = imod(h, ").concat(n,");\n int in_w = w / ").concat(n,";\n int offset_w = imod(w, ").concat(n,");\n int offset_d = (offset_h * ").concat(n," + offset_w) *\n ").concat(this.getOutputDepthSize(),";\n int in_d = d + offset_d;\n\n float result = ").concat(this.getInputSamplingString(),";\n setOutput(result);\n }\n ")}return Object($r.a)(e,[{key:"getHeightCoordString",value:function(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}},{key:"getWidthCoordString",value:function(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}},{key:"getDepthCoordString",value:function(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}},{key:"getOutputDepthSize",value:function(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}},{key:"getInputSamplingString",value:function(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}]),e}();var jw={kernelName:i.N,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.blockSize,s=r.dataFormat;i.wf.assert(o>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: ".concat(o)}));var c=a.shape[0],u="NHWC"===s?a.shape[1]:a.shape[2],l="NHWC"===s?a.shape[2]:a.shape[3],d="NHWC"===s?a.shape[3]:a.shape[1],f=u*o,p=l*o,h=d/(o*o),b=new ww("NHWC"===s?[c,f,p,h]:[c,h,f,p],o,s);return n.runWebGLProgram(b,[a],a.dtype)}},Sw=function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Object(Yr.a)(this,e),this.variableNames=["x","W"],this.outputShape=t.outShape;var o=t.inHeight,s=t.inWidth,c=t.padInfo.top,u=t.padInfo.left,l=t.strideHeight,d=t.strideWidth,f=t.dilationHeight,p=t.dilationWidth,h=t.filterHeight,b=t.filterWidth,m=t.outChannels/t.inChannels,v="",g="";r&&(v=a?"float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ".concat(r,"\n }"):i?"float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ".concat(r,"\n }"):"\n float activation(float x) {\n ".concat(r,"\n }\n "),g="result = activation(result);");var y=n?"result += getBiasAtOutCoords();":"";n&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),i&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n ".concat(v,"\n\n const ivec2 strides = ivec2(").concat(l,", ").concat(d,");\n const ivec2 pads = ivec2(").concat(c,", ").concat(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 / ").concat(m,";\n int q = d2 - d1 * ").concat(m,";\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 < ").concat(h,"; wR++) {\n int xR = xRCorner + wR * ").concat(f,";\n\n if (xR < 0 || xR >= ").concat(o,") {\n continue;\n }\n\n for (int wC = 0; wC < ").concat(b,"; wC++) {\n int xC = xCCorner + wC * ").concat(p,";\n\n if (xC < 0 || xC >= ").concat(s,") {\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 ").concat(y,"\n ").concat(g,"\n setOutput(result);\n }\n ")},Nw=function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Object(Yr.a)(this,e),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.outShape;for(var s=t.outChannels/t.inChannels,c=t.inHeight,u=t.inWidth,l=t.padInfo.top,d=t.padInfo.left,f=t.strideHeight,p=t.strideWidth,h=t.dilationHeight,b=t.dilationWidth,m=t.filterHeight,v=t.filterWidth,g=v,y="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;",O=0;O=0 && xR < ").concat(c,") {\n ");for(var w=0;w<(g+1)/2;w++){var j=2*w,S=j*b;if(y+="\n xC = xCCorner + ".concat(S,";\n "),1===p){if(j= 0 && xCOffset < ".concat(u," && xTexelC").concat(j,"Ready == 0) {\n xTexelC").concat(j," = 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 >= ").concat(u,") {\n xTexelC").concat(j,".zw = vec2(0.0);\n }\n xTexelC").concat(j,"Ready = 1;\n }\n "),y+=1===b&&S>0?"\n xC".concat(j," = vec4(xTexelC").concat(j-2,".zw, xTexelC").concat(j,".xy);\n "):"\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < ".concat(u,") {\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 >= ").concat(u,") {\n previous.zw = vec2(0.0);\n }\n\n xC").concat(j," = vec4(previous.zw, xTexelC").concat(j,".xy);\n } else {\n xC").concat(j," = vec4(0.0, 0.0, xTexelC").concat(j,".xy);\n }\n ")):y+="\n if (xC >= 0 && xC < ".concat(u," && xTexelC").concat(j,"Ready == 0) {\n xTexelC").concat(j," = getX(batch, xR, xC, d1);\n if (xC + 1 >= ").concat(u,") {\n xTexelC").concat(j,".zw = vec2(0.0);\n }\n xTexelC").concat(j,"Ready = 1;\n }\n\n xC").concat(j," = xTexelC").concat(j,";\n "),S+1= 0 && xCOffset < ").concat(u," && xTexelC").concat(j+1,"Ready == 0) {\n xTexelC").concat(j+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 >= ").concat(u,") {\n xTexelC").concat(j+1,".zw = vec2(0.0);\n }\n xTexelC").concat(j+1,"Ready = 1;\n }\n "),b>1&&(y+="\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < ".concat(u," && xTexelC").concat(j,"Ready == 0) {\n xTexelC").concat(j," = getX(batch, xR, xCOffset, d1);\n xTexelC").concat(j,"Ready = 1;\n }\n ")),y+="\n xC".concat(j+1," = vec4(xTexelC").concat(j,".zw, xTexelC").concat(j+1,".xy);\n ")):y+=1===N?"\n xC".concat(j+1," = xTexelC").concat(j,";\n "):"\n xCOffset = xC + ".concat(N,";\n\n if (xCOffset >= 0 && xCOffset < ").concat(u," && xTexelC").concat(j+1,"Ready == 0) {\n xTexelC").concat(j+1," = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= ").concat(u,") {\n xTexelC").concat(j+1,".zw = vec2(0.0);\n }\n xTexelC").concat(j+1,"Ready = 1;\n }\n\n xC").concat(j+1," = xTexelC").concat(j+1,";\n ")}}else S= 0 && xCOffset < ").concat(u," && xTexelC").concat(j,"Ready == 0) {\n xTexelC").concat(j," = 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 >= ").concat(u,") {\n xTexelC").concat(j,".zw = vec2(0.0);\n }\n xTexelC").concat(j,"Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < ").concat(u," && xTexelC").concat(j+1,"Ready == 0) {\n xTexelC").concat(j+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 >= ").concat(u,") {\n xTexelC").concat(j+1,".zw = vec2(0.0);\n }\n xTexelC").concat(j+1,"Ready = 1;\n }\n\n xC").concat(j," = vec4(xTexelC").concat(j,".zw, xTexelC").concat(j+1,".zw);\n "),S+1= 0 && xCOffset < ").concat(u,") {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC").concat(j+1," = vec4(xTexelC").concat(j+1,".xy, final.xy);\n "))):(y+="\n if(xC >= 0 && xC < ".concat(u," && xTexelC").concat(j,"Ready == 0) {\n xTexelC").concat(j," = getX(batch, xR, xC, d1);\n if (xC + 1 >= ").concat(u,") {\n xTexelC").concat(j,".zw = vec2(0.0);\n }\n xTexelC").concat(j,"Ready = 1;\n }\n\n xCOffset = xC + ").concat(p,";\n if(xCOffset >= 0 && xCOffset < ").concat(u," && xTexelC").concat(j+1,"Ready == 0) {\n xTexelC").concat(j+1," = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= ").concat(u,") {\n xTexelC").concat(j+1,".zw = vec2(0.);\n }\n xTexelC").concat(j+1,"Ready = 1;\n }\n\n xC").concat(j," = vec4(\n xTexelC").concat(j,".xy, xTexelC").concat(j+1,".xy);\n "),S+1= ").concat(t.inHeight,") {\n continue;\n }\n\n for (int yC = 0; yC < ").concat(t.outWidth,"; yC++) {\n int xC = wC + yC * ").concat(r," - ").concat(i,";\n\n if (xC < 0 || xC >= ").concat(t.inWidth,") {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n ")},Tw=function e(t){Object(Yr.a)(this,e),this.variableNames=["dy","W"],this.outputShape=t.inShape;var n=t.filterHeight,r=t.filterWidth,a=t.strideHeight,i=t.strideWidth,o=n-1-t.padInfo.top,s=r-1-t.padInfo.left,c=t.outChannels/t.inChannels;this.userCode="\n const ivec2 pads = ivec2(".concat(o,", ").concat(s,");\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 < ").concat(n,"; wR++) {\n float dyR = float(dyRCorner + wR) / ").concat(a,".0;\n\n if (dyR < 0.0 || dyR >= ").concat(t.outHeight,".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ").concat(n," - 1 - wR;\n\n for (int wC = 0; wC < ").concat(r,"; wC++) {\n float dyC = float(dyCCorner + wC) / ").concat(i,".0;\n\n if (dyC < 0.0 || dyC >= ").concat(t.outWidth,".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ").concat(r," - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < ").concat(c,"; dm++) {\n int d2 = d1 * ").concat(c," + 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 Ew={kernelName:i.P,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.dy,s=r.strides,c=r.dilations,u=r.pad,l=r.dimRoundingMode,d=r.filterShape,f=i.ud.computeConv2DInfo(a.shape,d,s,c,u,l,!0),p=new Cw(f);return n.runWebGLProgram(p,[a,o],"float32")}};var Aw={kernelName:i.Q,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.filter,s=r.strides,c=r.dilations,u=r.pad,l=r.dimRoundingMode,d=r.inputShape,f=i.ud.computeConv2DInfo(d,o.shape,s,c,u,l,!0),p=new Tw(f);return n.runWebGLProgram(p,[a,o],"float32")}},Rw=function e(t){Object(Yr.a)(this,e),this.variableNames=["X"],this.outputShape=[t,t],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "};var Fw={kernelName:i.R,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=[].concat(Object(Vn.a)(r.shape),Object(Vn.a)(r.shape)),o=i.wf.sizeFromShape(r.shape),s=yx({inputs:{x:r},backend:n,attrs:{shape:[o]}}),c=new Rw(o),u=n.runWebGLProgram(c,[s],s.dtype),l=yx({inputs:{x:u},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(u),l}},Dw=function e(t){Object(Yr.a)(this,e),this.variableNames=["x","W"],this.outputShape=t.outShape;var n=t.inHeight,r=t.inWidth,a=t.padInfo,i=t.strideHeight,o=t.strideWidth,s=t.filterHeight,c=t.filterWidth,u=t.dilationHeight,l=t.dilationWidth,d=a.top,f=a.left;this.userCode="\n const ivec2 strides = ivec2(".concat(i,", ").concat(o,");\n const ivec2 pads = ivec2(").concat(d,", ").concat(f,");\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 < ").concat(s,"; h++) {\n int hIn = hBeg + h * ").concat(u,";\n\n if (hIn >= 0 && hIn < ").concat(n,") {\n for (int w = 0; w < ").concat(c,"; w++) {\n int wIn = wBeg + w * ").concat(l,";\n\n if (wIn >= 0 && wIn < ").concat(r,") {\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 _w={kernelName:i.S,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,o=n.x,s=n.filter,c=a.strides,u=a.pad,l=a.dilations,d=i.ud.computeDilation2DInfo(o.shape,s.shape,c,u,"NHWC",l),f=new Dw(d),p=yx({inputs:{x:t=r.runWebGLProgram(f,[o,s],"float32")},backend:r,attrs:{shape:d.outShape}});return r.disposeIntermediateTensorInfo(t),p}};var Mw={kernelName:i.V,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs.equation,a=t,o=i.ud.decodeEinsumEquation(r,a.length),s=o.allDims,c=o.summedDims,u=o.idDims;i.ud.checkEinsumDimSizes(s.length,u,a);for(var l=i.ud.getEinsumComputePath(c,u),d=l.path,f=l.steps,p=f.length,h=null,b=s.length,m=[],v=0;v=0&&(h=Ix({inputs:{x:h},backend:n,attrs:{axis:d[v]-(s.length-b),keepDims:!1}}),m.push(h)),b--)}for(var I=0,C=m;I= 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"}),Lw={kernelName:i.W,backendName:"webgl",kernelFunc:zw},Pw={kernelName:i.X,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.dy,a=t.y,o=Object(i.Ud)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new ZO("\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 QO("return (b >= 1.0) ? a : a * (b + 1.0);",r.shape,a.shape);return n.runWebGLProgram(o,[r,a],r.dtype)}},Bw=lx({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:Uy}),Ww={kernelName:i.Y,backendName:"webgl",kernelFunc:Bw},Uw=ux({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 = '.concat(i.ud.ERF_P,";\n float a1 = ").concat(i.ud.ERF_A1,";\n float a2 = ").concat(i.ud.ERF_A2,";\n float a3 = ").concat(i.ud.ERF_A3,";\n float a4 = ").concat(i.ud.ERF_A4,";\n float a5 = ").concat(i.ud.ERF_A5,";\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")}),Vw={kernelName:i.Z,backendName:"webgl",kernelFunc:Uw},Hw="return exp(x);",Gw=ux({opSnippet:Hw,packedOpSnippet:Hw,cpuKernelImpl:Vy}),qw={kernelName:i.ab,backendName:"webgl",kernelFunc:Gw};function Kw(e){var t=e.inputs,n=e.attrs,r=e.backend,a=n.dim,o=t.input,s=o.shape.length,c=o.shape.slice(),u=a;return a<0&&(i.wf.assert(-(s+1)<=a,(function(){return"Axis must be in the interval [".concat(-(s+1),", ").concat(s,"]")})),u=s+a+1),c.splice(u,0,1),yx({inputs:{x:o},backend:r,attrs:{shape:c}})}var Xw={kernelName:i.bb,backendName:"webgl",kernelFunc:Kw},Yw="return exp(x) - 1.0;",$w=ux({opSnippet:Yw,packedOpSnippet:Yw,cpuKernelImpl:Hy}),Qw={kernelName:i.cb,backendName:"webgl",kernelFunc:$w},Zw=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["real","imag"];var a=n[1];this.outputShape=n;var i,o=r?"2.0 * ".concat(Math.PI):"-2.0 * ".concat(Math.PI),s=r?"".concat(a,".0"):"1.0";if("real"===t)i="return real * expR - imag * expI;";else{if("imag"!==t)throw new Error('FFT component must be either "real" or "imag", got '.concat(t,"."));i="return real * expI + imag * expR;"}this.userCode="\n const float exponentMultiplier = ".concat(o,";\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ").concat(i,"\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(").concat(a,");\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ").concat(a,"; 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) / ").concat(s,";\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n ")};function Jw(e,t,n){var r=n.texData.get(e.dataId),a=i.wf.sizeFromShape(e.shape),o=e.shape[e.shape.length-1],s=yx({inputs:{x:e},backend:n,attrs:{shape:[a/o,o]}}),c=s.shape,u=new Zw("real",c,t),l=new Zw("imag",c,t),d=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:c},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:c}],f=n.runWebGLProgram(u,d,"float32"),p=n.runWebGLProgram(l,d,"float32"),h=tx({inputs:{real:f,imag:p},backend:n});n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p);var b=yx({inputs:{x:h},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(h),b}var ej={kernelName:i.db,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend;return Jw(t.input,!1,n)}},tj=function e(t,n){Object(Yr.a)(this,e),this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=t,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "};function nj(e){var t=e.backend,n=e.attrs,r=n.shape,a=n.value,o=n.dtype;if("string"===(o=o||i.wf.inferDtype(a))){var s=i.wf.getArrayFromDType(o,i.wf.sizeFromShape(r));return s.fill(a),t.makeTensorInfo(r,o,s)}var c=new tj(r,a),u=[[a]];return t.runWebGLProgram(c,[],o,u)}var rj,aj={kernelName:i.eb,backendName:"webgl",kernelFunc:nj},ij=function e(t){Object(Yr.a)(this,e),this.variableNames=["Image"],this.outputShape=[];var n=t[2];this.outputShape=t,this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ".concat(n," - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ").concat(n,") {\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 ")},oj={kernelName:i.fb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.image,a=n,i=new ij(r.shape);return a.runWebGLProgram(i,[r],r.dtype)}},sj="return floor(x);",cj=ux({opSnippet:sj,packedOpSnippet:sj,cpuKernelImpl:Gy}),uj={kernelName:i.gb,backendName:"webgl",kernelFunc:cj},lj=lx({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"}),dj={kernelName:i.hb,backendName:"webgl",kernelFunc:lj},fj=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"];var n=Wg(),r=Object(o.a)(t,2),a=r[0],i=r[1];this.outputShape=t,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(".concat(i,".0, ").concat(a,".0);\n\n vec4 values = ").concat(n.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 ")},pj=function e(t){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var n=Wg(),r=Object(o.a)(t,2),a=r[0],i=r[1];this.outputShape=t,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(".concat(i,".0, ").concat(a,".0);\n vec4 values = ").concat(n.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 ").concat(n.output," = result;\n }\n ")},hj={kernelName:i.ib,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.pixels,s=r.numChannels,c="undefined"!==typeof HTMLVideoElement&&a instanceof HTMLVideoElement,u="undefined"!==typeof HTMLImageElement&&a instanceof HTMLImageElement,l=c?[a.videoWidth,a.videoHeight]:[a.width,a.height],d=Object(o.a)(l,2),f=d[0],p=d[1],h=[p,f],b=[p,f,s];(u||c)&&(null==rj&&(rj=document.createElement("canvas").getContext("2d")),rj.canvas.width=f,rj.canvas.height=p,rj.drawImage(a,0,0,f,p),a=rj.canvas);var m=n.makeTensorInfo(h,"int32");n.texData.get(m.dataId).usage=ag.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(m.dataId),a);var v=Object(i.Ud)().getBool("WEBGL_PACK")?new pj(b):new fj(b),g=n.runWebGLProgram(v,[m],"int32");return n.disposeData(m.dataId),g}};var bj={kernelName:i.kb,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,o=n.x,s=n.filter,c=n.bias,u=n.preluActivationWeights,l=a.strides,d=a.pad,f=a.dataFormat,p=a.dilations,h=a.dimRoundingMode,b=a.activation,m=a.leakyreluAlpha,v=i.ud.convertConv2DDataFormat(f),g=i.ud.computeConv2DInfo(o.shape,s.shape,l,p,d,h,!1,v),y=[];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(Object(i.Ud)().getBool("WEBGL_CONV_IM2COL")&&1===o.shape[0])t=tw({x:o,filter:s,convInfo:g,backend:r,bias:c,activation:b,preluActivationWeights:u,leakyreluAlpha:m});else{var O=null!=c,x=null!=u,k="leakyrelu"===b,w=b?dx(b,!1):null,j=new Qk(g,O,w,x,k),S=[o,s];if(c&&S.push(c),u&&S.push(u),k){var N=r.makeTensorInfo([],"float32",i.wf.createScalarValue(m,"float32"));S.push(N),y.push(N)}t=r.runWebGLProgram(j,S,"float32")}else t=ew({x:o,filter:s,convInfo:g,backend:r,bias:c,activation:b,preluActivationWeights:u,leakyreluAlpha:m});var I=yx({inputs:{x:t},backend:r,attrs:{shape:g.outShape}});return y.push(t),y.forEach((function(e){return r.disposeIntermediateTensorInfo(e)})),I}};var mj={kernelName:i.lb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.filter,s=t.bias,c=t.preluActivationWeights,u=r.strides,l=r.pad,d=r.dilations,f=r.dimRoundingMode,p=r.activation,h=r.leakyreluAlpha,b=[],m=d;null==m&&(m=[1,1]),i.wf.assert(i.ud.eitherStridesOrDilationsAreOne(u,m),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be "+"1. Got strides ".concat(u," and dilations '").concat(m,"'")}));var v,g=i.ud.computeConv2DInfo(a.shape,o.shape,u,m,l,f,!0),y=Object(i.Ud)().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels===1,O=p?dx(p,y):null,x=[a,o],k=null!=s,w=null!=c,j="leakyrelu"===p;if(k&&x.push(s),w&&x.push(c),j){var S=n.makeTensorInfo([],"float32",i.wf.createScalarValue(h,"float32"));x.push(S),b.push(S)}v=y?new Nw(g,k,O,w,j):new Sw(g,k,O,w,j);var N=n.runWebGLProgram(v,x,"float32");return b.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),N}},vj=function e(t,n,r){Object(Yr.a)(this,e),this.sliceDim=t,this.strides=n,this.variableNames=["x","indices"],this.outputShape=r;var a=Cy(n.length),i=Cy(r.length),o=this.sliceDim>1?"strides[j]":"strides";this.userCode="\n ".concat(a," strides = ").concat(a,"(").concat(this.strides,");\n void main() {\n ").concat(i," coords = getOutputCoords();\n int flattenIndex = 0;\n for (int j = 0; j < ").concat(this.sliceDim,"; j++) {\n int index = round(getIndices(coords[0], j));\n flattenIndex += index * ").concat(o,";\n }\n setOutput(getX(flattenIndex, coords[1]));\n }\n ")};var gj={kernelName:i.mb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.params,a=t.indices,s=a.shape,c=s[s.length-1],u=i.wf.sizeFromShape(r.shape),l=i.ud.prepareAndValidate(r,a),d=Object(o.a)(l,4),f=d[0],p=d[1],h=d[2],b=d[3],m=yx({inputs:{x:a},backend:n,attrs:{shape:[p,c]}}),v=yx({inputs:{x:r},backend:n,attrs:{shape:[i.wf.sizeFromShape(r.shape)/h,h]}});if(n.shouldExecuteOnCPU([r,a])||"string"===r.dtype){var g=n.readSync(a.dataId),y=n.bufferSync(r),O=qy(g,y,r.dtype,p,c,h,b,r.shape,u);return n.makeTensorInfo(f,r.dtype,O.values)}var x=new vj(c,b,[p,h]),k=n.runWebGLProgram(x,[v,m],v.dtype),w=yx({inputs:{x:k},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),n.disposeIntermediateTensorInfo(k),w}},yj=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["A","indices"],this.outputShape=n,this.rank=n.length;var r=Cy(this.rank),a=function(e,t){for(var n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[],a=0;a b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:Xy,dtype:"bool"}),wj={kernelName:i.ob,backendName:"webgl",kernelFunc:kj},jj=lx({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:Yy}),Sj={kernelName:i.pb,backendName:"webgl",kernelFunc:jj};var Nj={kernelName:i.qb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend;return Jw(t.input,!0,n)}},Ij=ux({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),Cj={kernelName:i.tb,backendName:"webgl",kernelFunc:Ij},Tj=ux({opSnippet:"return float(isinf(x));",dtype:"bool"}),Ej={kernelName:i.ub,backendName:"webgl",kernelFunc:Tj},Aj=ux({opSnippet:"return float(isnan(x));",dtype:"bool"}),Rj={kernelName:i.vb,backendName:"webgl",kernelFunc:Aj},Fj=lx({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:$y,dtype:"bool"}),Dj={kernelName:i.Ab,backendName:"webgl",kernelFunc:Fj},_j=lx({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:Qy,dtype:"bool"}),Mj={kernelName:i.Bb,backendName:"webgl",kernelFunc:_j};var zj={kernelName:i.Cb,backendName:"webgl",kernelFunc:function(e){var t=e.backend,n=e.attrs,r=n.start,a=n.stop,i=n.num,o=Zy(r,a,i);return t.makeTensorInfo([o.length],"float32",o)}},Lj=ux({opSnippet:"if (x < 0.0) return NAN;\n return log(x);",packedOpSnippet:"\n vec4 result = log(x);\n vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n result.r = isNaN.r == 1.0 ? NAN : result.r;\n result.g = isNaN.g == 1.0 ? NAN : result.g;\n result.b = isNaN.b == 1.0 ? NAN : result.b;\n result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:Jy}),Pj={kernelName:i.Db,backendName:"webgl",kernelFunc:Lj},Bj=ux({opSnippet:"return log(1.0 + x);"}),Wj={kernelName:i.Eb,backendName:"webgl",kernelFunc:Bj},Uj=lx({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"}),Vj={kernelName:i.Fb,backendName:"webgl",kernelFunc:Uj},Hj=ux({opSnippet:"return float(!(x >= 1.0));"}),Gj={kernelName:i.Gb,backendName:"webgl",kernelFunc:Hj},qj=lx({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"}),Kj={kernelName:i.Hb,backendName:"webgl",kernelFunc:qj},Xj=function e(t,n,r,a,i){Object(Yr.a)(this,e),this.variableNames=["x"],this.outputShape=[];var o,s=n,c=t[3]-1;this.outputShape=t;var u="float(".concat(r,") + float(").concat(a,") * sum");o=.5===i?"inversesqrt(".concat(u,")"):1===i?"1.0/(".concat(u,")"):"exp(log(".concat(u,") * float(-").concat(i,"));"),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 = -".concat(s,"; j <= ").concat(s,"; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ").concat(c,") {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ").concat(o,";\n setOutput(val);\n }\n ")},Yj=function e(t,n,r,a,i){Object(Yr.a)(this,e),this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var o,s=n,c=t[3]-1;this.outputShape=t;var u="float(".concat(r,") + float(").concat(a,") * sum");o=.5===i?"inversesqrt(".concat(u,")"):1===i?"1.0/(".concat(u,")"):"exp(log(".concat(u,") * float(-").concat(i,"));"),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 < ".concat(this.outputShape[3],";\n bool hasNextRow = c < ").concat(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 - ").concat(s,";\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 = - ").concat(s,"; j <= ").concat(s,"; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(").concat(c,"));\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 * ").concat(o,";\n setOutput(result);\n }\n ")},$j={kernelName:i.xb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.depthRadius,s=r.bias,c=r.alpha,u=r.beta,l=Object(i.Ud)().getBool("WEBGL_PACK_NORMALIZATION")?new Yj(a.shape,o,s,c,u):new Xj(a.shape,o,s,c,u);return n.runWebGLProgram(l,[a],a.dtype)}},Qj=function e(t,n,r,a,i){Object(Yr.a)(this,e),this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=t,this.depth=t[3],this.depthRadius=n,this.bias=r,this.alpha=a,this.beta=i,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 < ".concat(this.depth,"; ++d) {\n int depthBegin = int(max(0.0, float(d - ").concat(n,")));\n int depthEnd = int(min(float(").concat(this.depth,"),\n float(d + ").concat(n," + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = ").concat(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(").concat(a,") * norm + float(").concat(r,");\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(").concat(a,")\n * float(").concat(i,")\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ").concat(i,");\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 ")},Zj={kernelName:i.yb,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,c=r.bias,u=r.alpha,l=r.beta,d=new Qj(a.shape,s,c,u,l);return n.runWebGLProgram(d,[a,i,o],a.dtype)}};function Jj(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,s=r.reductionIndices,c=r.keepDims,u=a.shape.length,l=i.wf.parseAxisParam(s,a.shape),d=l,f=i.ud.getAxesPermutation(d,u),p=null!=f,h=n.shouldExecuteOnCPU([a]),b=a;if(p){if(h){for(var m=n.texData.get(b.dataId).values,v=new Array(u),g=0;g 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:tO}),nS={kernelName:i.Ob,backendName:"webgl",kernelFunc:tS};var rS={kernelName:i.Jb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;Pg(a,"maxPool");var o=r.filterSize,s=r.strides,c=r.pad,u=r.dimRoundingMode;i.wf.assert(i.ud.eitherStridesOrDilationsAreOne(s,1),(function(){return"Error in maxPool: Either strides or dilations must be 1. "+"Got strides ".concat(s," and dilations '").concat(1,"'")}));var l=i.ud.computePool2DInfo(a.shape,o,s,1,c,u);if(1===l.filterWidth&&1===l.filterHeight&&i.wf.arraysEqual(l.inShape,l.outShape))return JO({inputs:{x:a},backend:n});var d=new lk(l,"max",!1);return n.runWebGLProgram(d,[a],a.dtype)}};var aS={kernelName:i.Kb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.filterSize,s=r.strides,c=r.pad,u=r.dataFormat,l=r.dimRoundingMode,d=i.ud.computePool3DInfo(a.shape,o,s,[1,1,1],c,l,u),f=new dk(d,"max",!1);return n.runWebGLProgram(f,[a],a.dtype)}},iS=function e(t){Object(Yr.a)(this,e),this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var n=t.strideHeight,r=t.strideWidth,a=t.dilationHeight,i=t.effectiveFilterHeight,o=t.effectiveFilterWidth,s=i-1-t.padInfo.top,c=o-1-t.padInfo.left,u=i*o-1;this.userCode="\n const ivec2 pads = ivec2(".concat(s,", ").concat(c,");\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 < ").concat(i,";\n wR += ").concat(a,") {\n float dyR = float(dyRCorner + wR) / ").concat(n,".0;\n\n if (dyR < 0.0 || dyR >= ").concat(t.outHeight,".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ").concat(o,"; wC++) {\n float dyC = float(dyCCorner + wC) / ").concat(r,".0;\n\n if (dyC < 0.0 || dyC >= ").concat(t.outWidth,".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = ").concat(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 * ").concat(o," + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n ")},oS=function e(t){Object(Yr.a)(this,e),this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var n=t.strideDepth,r=t.strideHeight,a=t.strideWidth,i=t.dilationDepth,o=t.dilationHeight,s=t.dilationWidth,c=t.effectiveFilterDepth,u=t.effectiveFilterHeight,l=t.effectiveFilterWidth,d=c-1-t.padInfo.front,f=u-1-t.padInfo.top,p=l-1-t.padInfo.left,h=c*u*l-1;this.userCode="\n const ivec3 pads = ivec3(".concat(d,", ").concat(f,", ").concat(p,");\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 < ").concat(c,";\n wD += ").concat(i,") {\n float dyD = float(dyDCorner + wD) / ").concat(n,".0;\n\n if (dyD < 0.0 || dyD >= ").concat(t.outDepth,".0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ").concat(u,";\n wR += ").concat(o,") {\n float dyR = float(dyRCorner + wR) / ").concat(r,".0;\n\n if (dyR < 0.0 || dyR >= ").concat(t.outHeight,".0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ").concat(l,";\n wC += ").concat(s,") {\n float dyC = float(dyCCorner + wC) / ").concat(a,".0;\n\n if (dyC < 0.0 || dyC >= ").concat(t.outWidth,".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = ").concat(h," -\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 * ").concat(u," * ").concat(l," +\n wR * ").concat(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 sS={kernelName:i.Lb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.input,s=r.filterSize,c=r.strides,u=r.pad,l=r.dimRoundingMode,d=i.ud.computePool3DInfo(o.shape,s,c,[1,1,1],u,l),f=new dk(d,"max",!0),p=n.runWebGLProgram(f,[o],o.dtype),h=new oS(d),b=n.runWebGLProgram(h,[a,p],o.dtype);return n.disposeIntermediateTensorInfo(p),b}};var cS={kernelName:i.Mb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,o=t.input,s=o;Pg([o,t.output],"maxPoolGrad");var c=r.filterSize,u=r.strides,l=r.pad,d=r.dimRoundingMode,f=i.ud.computePool2DInfo(s.shape,c,u,1,l,d),p=new lk(f,"max",!0),h=n.runWebGLProgram(p,[s],s.dtype),b=new iS(f),m=n.runWebGLProgram(b,[a,h],s.dtype);return n.disposeIntermediateTensorInfo(h),m}};var uS={kernelName:i.Nb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,s=n.filterSize,c=n.strides,u=n.pad,l=n.includeBatchInIndex,d=r;i.wf.assert(4===a.shape.length,(function(){return"Error in maxPool: input must be rank 4 but got rank ".concat(a.shape.length,".")}));var f=[1,1];i.wf.assert(i.ud.eitherStridesOrDilationsAreOne(c,f),(function(){return"Error in maxPool: Either strides or dilations must be 1. "+"Got strides ".concat(c," and dilations '").concat(f,"'")}));var p=i.ud.computePool2DInfo(a.shape,s,c,f,u),h=function(e,t,n,r){var a=new lk(n,"max",!1),i=r.runWebGLProgram(a,[e],"float32");return a=new lk(n,"max",!0,!0,t),[i,r.runWebGLProgram(a,[e],"float32")]}(a,l,p,d),b=Object(o.a)(h,2);return[b[0],b[1]]}};var lS={kernelName:i.Pb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,s=n.keepDims,c=n.axis,u=r,l=a.shape.length,d=i.wf.parseAxisParam(c,a.shape),f=d,p=i.ud.getAxesPermutation(f,l),h=null!=p,b=u.shouldExecuteOnCPU([a]),m=[],v=a;if(h){if(b){for(var g=u.texData.get(v.dataId).values,y=new Array(l),O=0;O 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:nO}),pS={kernelName:i.Rb,backendName:"webgl",kernelFunc:fS},hS=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["x"],this.outputShape=n.map((function(e,n){return e[0]+t[n]+e[1]}));var a=t.length,i=Cy(a),o=n.map((function(e){return e[0]})).join(","),s=n.map((function(e,n){return e[0]+t[n]})).join(","),c=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,a),u="reflect"===r?0:1;this.userCode=1!==a?"\n ".concat(i," start = ").concat(i,"(").concat(o,");\n ").concat(i," end = ").concat(i,"(").concat(s,");\n\n void main() {\n ").concat(i," outC = getOutputCoords();\n for (int i = 0; i < ").concat(a,"; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ").concat(u,";\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ").concat(u,";\n }\n }\n ").concat(i," coords = outC - start;\n setOutput(getX(").concat(c,"));\n }\n "):"\n int start = ".concat(o,";\n int end = ").concat(s,";\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ").concat(u,";\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ").concat(u,";\n }\n setOutput(getX(outC - start));\n }\n ")},bS=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n.map((function(e,n){return e[0]+t[n]+e[1]}));var a=t.length,i=Cy(a),o=n.map((function(e){return e[0]})).join(","),s=n.map((function(e,n){return e[0]+t[n]})).join(","),c=jO("rc",a),u=jO("source",a),l="".concat(c[a-1]," < ").concat(this.outputShape[a-1]),d=1===a?"source":"vec2(".concat(u.slice(-2).join(),")"),f="reflect"===r?0:1,p="";if(1===a){var h="\n ".concat(i," source = rc;\n if (source < start) {\n source = start * 2 - source - ").concat(f,";\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ").concat(f,";\n }\n source -= start;\n ");p="\n ".concat(i," rc = outputLoc;\n ").concat(h,"\n result[0] = getChannel(getX(").concat(u.join(),"), ").concat(d,");\n ").concat(c[a-1]," += 1;\n if(").concat(l,") {\n ").concat(h,"\n result[1] = getChannel(getX(").concat(u.join(),"), ").concat(d,");\n }\n ")}else{var b="\n ".concat(i," source = rc;\n ").concat(i," lt = ").concat(i,"(lessThan(source, start));\n ").concat(i," gte = ").concat(i,"(greaterThanEqual(source, end));\n ").concat(i," orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ").concat(f,") +\n gte * ((end - 1) * 2 - source + ").concat(f,");\n source -= start;\n ");p="\n ".concat(i," rc = outputLoc;\n ").concat(b,"\n result[0] = getChannel(getX(").concat(u.join(),"), ").concat(d,");\n ").concat(c[a-1]," += 1;\n if(").concat(l,") {\n ").concat(b,"\n result[1] = getChannel(getX(").concat(u.join(),"), ").concat(d,");\n }\n rc = outputLoc;\n ").concat(c[a-2]," += 1;\n if(").concat(c[a-2]," < ").concat(this.outputShape[a-2],") {\n ").concat(b,"\n result[2] = getChannel(getX(").concat(u.join(),"), ").concat(d,");\n ").concat(c[a-1]," += 1;\n if(").concat(l,") {\n ").concat(b,"\n result[3] = getChannel(getX(").concat(u.join(),"), ").concat(d,");\n }\n }\n ")}this.userCode="\n const ".concat(i," start = ").concat(i,"(").concat(o,");\n const ").concat(i," end = ").concat(i,"(").concat(s,");\n\n void main() {\n ").concat(i," outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ").concat(p,"\n setOutput(result);\n }\n ")},mS={kernelName:i.Sb,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.paddings,s=r.mode,c=Object(i.Ud)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new bS(a.shape,o,s):new hS(a.shape,o,s);return n.runWebGLProgram(c,[a],a.dtype)}},vS=lx({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\n vec4 result = mod(a, b);\n vec4 isNaN = vec4(equal(b, vec4(0.0)));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),gS={kernelName:i.Tb,backendName:"webgl",kernelFunc:vS},yS=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[t,r],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 < ".concat(n-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(").concat(n-1,"));\n }\n ")},OS=lx({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}),xS={kernelName:i.lc,backendName:"webgl",kernelFunc:OS},kS="return a - b;",wS=lx({opSnippet:kS,packedOpSnippet:kS,supportsComplex:!0,cpuKernelImpl:gO}),jS={kernelName:i.Xc,backendName:"webgl",kernelFunc:wS};function SS(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,o=r.dim,s=i.wf.parseAxisParam([o],a.shape),c=Jj({inputs:{x:a},backend:n,attrs:{reductionIndices:s,keepDims:!1}}),u=i.ud.expandShapeToKeepDim(c.shape,s),l=yx({inputs:{x:c},backend:n,attrs:{shape:u}}),d=wS({inputs:{a:a,b:l},backend:n}),f=Gw({inputs:{x:d},backend:n}),p=Ix({inputs:{x:f},backend:n,attrs:{axis:s,keepDims:!1}}),h=yx({inputs:{x:p},backend:n,attrs:{shape:u}}),b=OS({inputs:{a:f,b:h},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),b}var NS={kernelName:i.Gc,backendName:"webgl",kernelFunc:SS};var IS={kernelName:i.Ub,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,c=s?a:SS({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),u=c.shape[0],l=c.shape[1],d=new yS(u,l,i),f=[[o]],p=n.runWebGLProgram(d,[c],"int32",f);return s||n.disposeIntermediateTensorInfo(c),p}},CS="return -x;";var TS={kernelName:i.Wb,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=n.x;if(r.shouldExecuteOnCPU([a])){var s=r.texData.get(a.dataId),c=aO(s.values,a.shape,a.dtype),u=Object(o.a)(c,2),l=u[0],d=u[1];return r.makeTensorInfo(d,a.dtype,l)}return t=Object(i.Ud)().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new GO(a.shape,CS):new AO(a.shape,CS),r.runWebGLProgram(t,[a],a.dtype)}},ES=i.ie.nonMaxSuppressionV3Impl;var AS={kernelName:i.Xb,backendName:"webgl",kernelFunc:function(e){i.ud.warn("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,o=t.scores,s=r.maxOutputSize,c=r.iouThreshold,u=r.scoreThreshold,l=n.readSync(a.dataId),d=n.readSync(o.dataId),f=ES(l,d,s,c,u).selectedIndices;return n.makeTensorInfo([f.length],"int32",new Int32Array(f))}},RS=i.ie.nonMaxSuppressionV4Impl;var FS={kernelName:i.Yb,backendName:"webgl",kernelFunc:function(e){i.ud.warn("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,o=t.scores,s=r.maxOutputSize,c=r.iouThreshold,u=r.scoreThreshold,l=r.padToMaxOutputSize,d=n.readSync(a.dataId),f=n.readSync(o.dataId),p=RS(d,f,s,c,u,l),h=p.selectedIndices,b=p.validOutputs;return[n.makeTensorInfo([h.length],"int32",new Int32Array(h)),n.makeTensorInfo([],"int32",new Int32Array([b]))]}},DS=i.ie.nonMaxSuppressionV5Impl;var _S={kernelName:i.Zb,backendName:"webgl",kernelFunc:function(e){i.ud.warn("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,o=t.scores,s=r.maxOutputSize,c=r.iouThreshold,u=r.scoreThreshold,l=r.softNmsSigma,d=n.readSync(a.dataId),f=n.readSync(o.dataId),p=DS(d,f,s,c,u,l),h=p.selectedIndices,b=p.selectedScores;return[n.makeTensorInfo([h.length],"int32",new Int32Array(h)),n.makeTensorInfo([b.length],"float32",new Float32Array(b))]}},MS=function e(t,n,r,a){Object(Yr.a)(this,e),this.variableNames=["indices"],this.outputShape=[t,n],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(".concat(a,"), float(").concat(r,"),\n float(index == coords.y)));\n }\n ")},zS={kernelName:i.bc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,o=r.depth,s=r.onValue,c=r.offValue,u=i.wf.sizeFromShape(a.shape),l=new MS(u,o,s,c),d=yx({inputs:{x:a},backend:n,attrs:{shape:[u]}}),f=n.runWebGLProgram(l,[d],a.dtype);n.disposeIntermediateTensorInfo(d);var p=yx({inputs:{x:f},backend:n,attrs:{shape:[].concat(Object(Vn.a)(a.shape),[o])}});return n.disposeIntermediateTensorInfo(f),p}};function LS(e){var t=e.inputs,n=e.backend,r=t.x;if("complex64"===r.dtype){var a=Ak({inputs:{input:r},backend:n}),i=LS({inputs:{x:a},backend:n}),o=qk({inputs:{input:r},backend:n}),s=LS({inputs:{x:o},backend:n}),c=tx({inputs:{real:i,imag:s},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),c}return nj({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}var PS={kernelName:i.kd,backendName:"webgl",kernelFunc:LS};var BS={kernelName:i.cc,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=Ak({inputs:{input:a},backend:r}),o=e({inputs:{x:i},backend:r}),s=qk({inputs:{input:a},backend:r}),c=LS({inputs:{x:s},backend:r}),u=tx({inputs:{real:o,imag:c},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(c),u}return nj({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:r})}};var WS={kernelName:i.ec,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs.axis;if(1===t.length)return Kw({inputs:{input:t[0]},backend:n,attrs:{dim:r}});var a=t[0].shape,o=t[0].dtype;t.forEach((function(e){i.wf.assertShapesMatch(a,e.shape,"All tensors passed to stack must have matching shapes"),i.wf.assert(o===e.dtype,(function(){return"All tensors passed to stack must have matching dtypes"}))}));var s=[],c=Yk({inputs:t.map((function(e){var t=Kw({inputs:{input:e},backend:n,attrs:{dim:r}});return s.push(t),t})),backend:n,attrs:{axis:r}});return s.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),c}},US=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=n.map((function(e,n){return e[0]+t[n]+e[1]}));var a=t.length,i=Cy(a),o=n.map((function(e){return e[0]})).join(","),s=n.map((function(e,n){return e[0]+t[n]})).join(","),c=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,a);this.userCode=1!==a?"\n ".concat(i," start = ").concat(i,"(").concat(o,");\n ").concat(i," end = ").concat(i,"(").concat(s,");\n\n void main() {\n ").concat(i," outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ").concat(i," coords = outC - start;\n setOutput(getX(").concat(c,"));\n }\n }\n "):"\n int start = ".concat(o,";\n int end = ").concat(s,";\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 ")},VS=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=n.map((function(e,n){return e[0]+t[n]+e[1]}));for(var a=t.length,i=Cy(a),o=n.map((function(e){return e[0]})).join(","),s=n.map((function(e,n){return e[0]+t[n]})).join(","),c=jO("rc",a),u=jO("source",a),l="".concat(c[a-1]," < ").concat(this.outputShape[a-1]),d=1===a?"source":"vec2(".concat(u.slice(-2).join(),")"),f=["".concat(i," rc = outputLoc;"),"".concat(c[a-1]," += 1;\n if(").concat(l,") {\n "),1===a?"":"}\n rc = outputLoc;\n ".concat(c[a-2]," += 1;\n if(").concat(c[a-2]," < ").concat(this.outputShape[a-2],") {"),1===a?"":" ".concat(c[a-1]," += 1;\n if(").concat(l,") {")],p=1===a?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",h="",b=0,m=1===a?2:4;b 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),KS={kernelName:i.gc,backendName:"webgl",kernelFunc:qS};var XS={kernelName:i.ic,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,s=n.x,c=a.axis,u=a.keepDims,l=s.shape.length,d=[],f=i.wf.parseAxisParam(c,s.shape),p=f,h=i.ud.getAxesPermutation(p,l),b=s;if(null!=h&&(b=Tx({inputs:{x:s},backend:r,attrs:{perm:h}}),p=i.ud.getInnerMostAxes(p.length,l),d.push(b)),i.ud.assertAxesAreInnerMostDims("prod",p,l),r.shouldExecuteOnCPU([b])){var m=r.texData.get(b.dataId).values,v=oO(b.shape,b.dtype,m,p),g=v.outVals,y=v.outShape,O=v.outDtype;t=r.makeTensorInfo(y,O,g)}else{var x=i.ud.computeOutAndReduceShapes(b.shape,p),k=Object(o.a)(x,2),w=k[0],j=k[1],S=i.wf.sizeFromShape(j),N=yx({inputs:{x:b},backend:r,attrs:{shape:[-1,S]}}),I=wx(N,Object(i.jf)(s.dtype),"prod",r);t=yx({inputs:{x:I},backend:r,attrs:{shape:w}}),d.push(N),d.push(I)}if(u){d.push(t);var C=i.ud.expandShapeToKeepDim(t.shape,f);t=yx({inputs:{x:t},backend:r,attrs:{shape:C}})}return d.forEach((function(e){return r.disposeIntermediateTensorInfo(e)})),t}},YS=function(e){var t=e.backend,n=e.attrs,r=n.start,a=n.stop,i=n.step,o=n.dtype,s=sO(r,a,i,o);return t.makeTensorInfo([s.length],o,s)},$S={kernelName:i.jc,backendName:"webgl",kernelFunc:YS},QS=ux({opSnippet:"return 1.0 / x;"}),ZS={kernelName:i.mc,backendName:"webgl",kernelFunc:QS},JS=ux({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"}),eN={kernelName:i.nc,backendName:"webgl",kernelFunc:JS},tN=ux({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"}),nN={kernelName:i.oc,backendName:"webgl",kernelFunc:tN},rN=function e(t,n,r,a,i){Object(Yr.a)(this,e),this.variableNames=["A"],this.outputShape=[];var s=Object(o.a)(t,4),c=s[0],u=s[1],l=s[2],d=s[3];this.outputShape=[c,n,r,d];var f,p=[a&&n>1?u-1:u,a&&r>1?l-1:l],h=[a&&n>1?n-1:n,a&&r>1?r-1:r];f=i?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ".concat(p[0]/h[0],",\n ").concat(p[1]/h[1],");\n const vec2 inputShapeRC = vec2(").concat(u,".0, ").concat(l,".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 = ").concat(f,";\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 ")},aN=function e(t,n,r,a,i){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var s=Object(o.a)(t,4),c=s[0],u=s[1],l=s[2],d=s[3];this.outputShape=[c,n,r,d];var f,p=[a&&n>1?u-1:u,a&&r>1?l-1:l],h=[a&&n>1?n-1:n,a&&r>1?r-1:r];f=i?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ".concat(p[0]/h[0],",\n ").concat(p[1]/h[1],",\n ").concat(p[1]/h[1],");\n const vec3 inputShapeRC = vec3(").concat(u,".0, ").concat(l,".0,\n ").concat(l,".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 = ").concat(f,";\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 < ").concat(d-1,";\n bool hasNextRow = coords.z < ").concat(r-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 iN={kernelName:i.qc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,s=r.alignCorners,c=r.halfPixelCenters,u=r.size,l=Object(o.a)(u,2),d=l[0],f=l[1],p=Object(i.Ud)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new aN(a.shape,d,f,s,c):new rN(a.shape,d,f,s,c);return n.runWebGLProgram(p,[a],"float32")}},oN=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["dy"],this.outputShape=[],this.outputShape=n;var a=Object(o.a)(n,3),i=a[1],s=a[2],c=Object(o.a)(t,3),u=c[1],l=c[2],d=[r&&u>1?i-1:i,r&&l>1?s-1:s],f=[r&&u>1?u-1:u,r&&l>1?l-1:l],p=d[0]/f[0],h=d[1]/f[1],b=1/p,m=1/h,v=2*Math.ceil(b)+2,g=2*Math.ceil(m)+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(".concat(p,");\n const float widthScale = float(").concat(h,");\n\n const float invHeightScale = float(").concat(b,");\n const float invWidthScale = float(").concat(m,");\n\n const int winHeight = int(").concat(v,");\n const int winWidth = int(").concat(g,");\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 >= ").concat(u,") {\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 >= ").concat(l,") {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ").concat(i-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), ").concat(s-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 sN={kernelName:i.rc,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 oN(i.shape,a.shape,o);return n.runWebGLProgram(s,[i],i.dtype)}},cN=function e(t,n,r,a,i){Object(Yr.a)(this,e),this.variableNames=["A"],this.outputShape=[];var s=Object(o.a)(t,4),c=s[0],u=s[1],l=s[2],d=s[3];this.outputShape=[c,n,r,d];var f,p=[a&&n>1?u-1:u,a&&r>1?l-1:l],h=[a&&n>1?n-1:n,a&&r>1?r-1:r],b=a?"0.5":"0.0";f=i?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ".concat(p[0]/h[0],",\n ").concat(p[1]/h[1],");\n const vec2 inputShapeRC = vec2(").concat(u,".0, ").concat(l,".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 = ").concat(f,";\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ").concat(b,")));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n ")},uN=function e(t,n,r,a,i){Object(Yr.a)(this,e),this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var s=Object(o.a)(t,4),c=s[0],u=s[1],l=s[2],d=s[3];this.outputShape=[c,n,r,d];var f,p=[a&&n>1?u-1:u,a&&r>1?l-1:l],h=[a&&n>1?n-1:n,a&&r>1?r-1:r],b=a?"0.5":"0.0";f=i?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ".concat(p[0]/h[0],",\n ").concat(p[1]/h[1],",\n ").concat(p[1]/h[1],");\n const vec3 inputShapeRC = vec3(").concat(u,".0, ").concat(l,".0,\n ").concat(l,".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 = ").concat(f,";\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ").concat(b,")));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ").concat(d-1,";\n bool hasNextRow = coords.z < ").concat(r-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 lN={kernelName:i.sc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,s=r.alignCorners,c=r.halfPixelCenters,u=r.size,l=Object(o.a)(u,2),d=l[0],f=l[1],p=Object(i.Ud)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new uN(a.shape,d,f,s,c):new cN(a.shape,d,f,s,c);return n.runWebGLProgram(p,[a],a.dtype)}},dN=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["dy"],this.outputShape=[],this.outputShape=n;var a=Object(o.a)(n,3),i=a[1],s=a[2],c=Object(o.a)(t,3),u=c[1],l=c[2],d=[r&&u>1?i-1:i,r&&l>1?s-1:s],f=[r&&u>1?u-1:u,r&&l>1?l-1:l],p=d[0]/f[0],h=d[1]/f[1],b=1/p,m=1/h,v=2*Math.ceil(b)+2,g=2*Math.ceil(m)+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(".concat(p,");\n const float widthScale = float(").concat(h,");\n\n const float invHeightScale = float(").concat(b,");\n const float invWidthScale = float(").concat(m,");\n\n const int winHeight = int(").concat(v,");\n const int winWidth = int(").concat(g,");\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 >= ").concat(u,") {\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 >= ").concat(l,") {\n continue;\n }\n\n float sourceFracRow =\n float(").concat(d[0],") *\n (float(dyR) / float(").concat(f[0],"));\n\n float sourceFracCol =\n float(").concat(d[1],") *\n (float(dyC) / float(").concat(f[1],"));\n\n int sourceNearestRow = int(min(\n float(int(").concat(i,") - 1),\n ").concat(r," ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(").concat(s,") - 1),\n ").concat(r," ? 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 fN={kernelName:i.tc,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 dN(i.shape,a.shape,o);return n.runWebGLProgram(s,[i],i.dtype)}},pN=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["x"];var r=t.length;if(r>4)throw new Error("WebGL backend: Reverse of rank-".concat(r," tensor is not yet supported"));if(this.outputShape=t,1!==r){var a=t.map((function(e,r){return function(e){return-1!==n.indexOf(e)&&1!==t[e]?"".concat(t[e]," - coords[").concat(e,"] - 1"):"coords[".concat(e,"]")}(r)})).join(","),i=Cy(r);this.userCode="\n void main() {\n ".concat(i," coords = getOutputCoords();\n setOutput(getX(").concat(a,"));\n }\n ")}else this.userCode="\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(".concat(t[0]," - coord - 1));\n }\n ")},hN=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var r=t.length;if(r>4)throw new Error("WebGL backend: Reverse of rank-".concat(r," tensor is not yet supported"));this.outputShape=t;var a=jO("rc",r),i="".concat(a[r-1]," + 1 < ").concat(this.outputShape[r-1]),o="".concat(a[r-2]," + 1 < ").concat(this.outputShape[r-2]),s=Cy(r);function c(e){var r=t.map((function(r,a){return function(e,r){return-1!==n.indexOf(e)&&1!==t[e]?"".concat(t[e]," - ").concat(r[e]," - 1"):"".concat(r[e])}(a,e)})),a=r.join(","),i=r.slice(-2).join(",");return"getChannel(getX(".concat(a,"), vec2(").concat(i,"))")}this.userCode=1===r?"\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(".concat(t[0]," - rc - 1),\n ").concat(t[0]," - rc - 1);\n if(").concat(i,"){\n result.g = getChannel(getX(").concat(t[0]," - (rc + 1) - 1),\n ").concat(t[0]," - (rc + 1) - 1);\n }\n setOutput(result);\n }\n "):"\n void main() {\n ".concat(s," rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ").concat(function(e){return c(e)}(a.slice()),";\n if(").concat(i,"){\n result.g = ").concat(function(e){return e[r-1]="("+e[r-1]+" + 1)",c(e)}(a.slice()),";\n }\n if(").concat(o,") {\n result.b = ").concat(function(e){return e[r-2]="("+e[r-2]+" + 1)",c(e)}(a.slice()),";\n if(").concat(i,") {\n result.a = ").concat(function(e){return e[r-1]="("+e[r-1]+" + 1)",e[r-2]="("+e[r-2]+" + 1)",c(e)}(a.slice()),";\n }\n }\n setOutput(result);\n }\n ")};var bN={kernelName:i.uc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.dims,s=a.shape.length,c=i.wf.parseAxisParam(o,a.shape);if(0===s)return JO({inputs:{x:a},backend:n});var u=Object(i.Ud)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new hN(a.shape,c):new pN(a.shape,c);return n.runWebGLProgram(u,[a],a.dtype)}},mN=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];var r=t[1],a=t[2];this.outputShape=t;var i="";i="number"===typeof n?"float outputValue = ".concat(n.toFixed(2),";"):"\n vec3 fill = vec3(".concat(n.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 ".concat(i,"\n if(coordX >= 0 && coordX < ").concat(a," && coordY >= 0 && coordY < ").concat(r,") {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n ")},vN={kernelName:i.vc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.image,s=n.radians,c=n.fillValue,u=n.center,l=r,d=new mN(a.shape,c),f=i.ud.getImageCenter(u,a.shape[1],a.shape[2]),p=Object(o.a)(f,2),h=[[p[0],p[1],Math.sin(s),Math.cos(s)]];return l.runWebGLProgram(d,[a],a.dtype,h)}},gN=ux({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"}),yN={kernelName:i.wc,backendName:"webgl",kernelFunc:gN},ON=ux({opSnippet:"return inversesqrt(x);",cpuKernelImpl:cO}),xN={kernelName:i.xc,backendName:"webgl",kernelFunc:ON},kN=function e(t,n,r,a,i,o){Object(Yr.a)(this,e),this.variableNames=["updates","indices","defaultValue"],this.outputShape=o;var s=Cy(i.length),c=Cy(o.length),u="";1===r?u="i":2===r&&(u="i, j");var l="getIndices(".concat(u,")"),d="";1===a?d="i":2===a&&(d="i, coords[1]");var f="getUpdates(".concat(d,")"),p=n>1?"strides[j]":"strides";this.userCode="\n ".concat(s," strides = ").concat(s,"(").concat(i,");\n\n void main() {\n ").concat(c," coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ").concat(t,"; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ").concat(n,"; j++) {\n int index = round(").concat(l,");\n flattenedIndex += index * ").concat(p,";\n }\n if (flattenedIndex == coords[0]) {\n sum += ").concat(f,";\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n ")};var wN={kernelName:i.yc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,o=t.updates,s=r.shape,c=i.ud.calculateShapes(o,a,s),u=c.sliceRank,l=c.numUpdates,d=c.sliceSize,f=c.strides,p=c.outputSize,h=[p/d,d];if(0===p)return n.makeTensorInfo(s,a.dtype);var b=yx({inputs:{x:a},backend:n,attrs:{shape:[l,u]}}),m=yx({inputs:{x:o},backend:n,attrs:{shape:[l,d]}}),v=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new kN(l,u,b.shape.length,m.shape.length,f,h),y=n.runWebGLProgram(g,[m,b,v],m.dtype),O=yx({inputs:{x:y},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(b),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(v),O}},jN=function e(t,n,r){var a,i;if(Object(Yr.a)(this,e),this.variableNames=["c","a","b"],this.outputShape=n,r>4)throw Error("Where for rank ".concat(r," is not yet supported"));if(1===r)i="resRC",a="resRC";else{for(var o=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[],c=[],u=0;u= 1.0) {\n setOutput(getA(").concat(i,"));\n } else {\n setOutput(getB(").concat(i,"));\n }\n }\n ")};var SN={kernelName:i.zc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.condition,a=t.t,o=t.e,s=new jN(r.shape.length,a.shape,a.shape.length);return n.runWebGLProgram(s,[r,a,o],Object(i.vf)(a.dtype,o.dtype))}},NN=ux({opSnippet:"\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ".concat(i.ud.SELU_SCALEALPHA,";\n float scale = ").concat(i.ud.SELU_SCALE,";\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n")}),IN={kernelName:i.Ac,backendName:"webgl",kernelFunc:NN},CN=ux({opSnippet:"return 1.0 / (1.0 + exp(-1.0 * x));"}),TN={kernelName:i.Bc,backendName:"webgl",kernelFunc:CN},EN=ux({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),AN={kernelName:i.Cc,backendName:"webgl",kernelFunc:EN},RN=ux({opSnippet:"if (isnan(x)) return x;\n return sin(x);\n"}),FN={kernelName:i.Dc,backendName:"webgl",kernelFunc:RN},DN=ux({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),_N={kernelName:i.Ec,backendName:"webgl",kernelFunc:DN},MN=ux({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"}),zN={kernelName:i.Hc,backendName:"webgl",kernelFunc:MN},LN={kernelName:i.Ic,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=r.blockShape,s=r.paddings;i.wf.assert(a.shape.length<=4,(function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"}));var c=o.reduce((function(e,t){return e*t})),u=[[0,0]];u.push.apply(u,Object(Vn.a)(s));for(var l=1+o.length;l 0.0 ? 1.0 : float(".concat(n.alpha,");\n "),o=new AO(a.shape,i);return r.runWebGLProgram(o,[a],a.dtype)}},JN=function e(t,n,r){Object(Yr.a)(this,e),this.variableNames=["x"],this.outputShape=r;var a=r.length,i=Cy(r.length),o=Cy(r.length),s="";if(1===a)s="coords * strides + begin";else{var c=0;s=r.map((function(e,t){return c++,1===r.length?"coords * strides[".concat(t,"] + begin[").concat(t,"]"):"coords[".concat(c-1,"] * strides[").concat(t,"] + begin[").concat(t,"]")})).join(",")}this.userCode="\n ".concat(i," begin = ").concat(i,"(").concat(t,");\n ").concat(i," strides = ").concat(i,"(").concat(n,");\n\n void main() {\n ").concat(o," coords = getOutputCoords();\n setOutput(getX(").concat(s,"));\n }\n ")};var eI={kernelName:i.Tc,backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,o=n.x,s=a.begin,c=a.end,u=a.strides,l=a.beginMask,d=a.endMask,f=a.ellipsisMask,p=a.newAxisMask,h=a.shrinkAxisMask,b=i.af.sliceInfo(o.shape,s,c,u,l,d,f,p,h),m=b.nonStrided,v=b.$begin,g=b.$strides,y=b.size,O=b.newShape,x=b.outShape,k=yx({inputs:{x:o},backend:r,attrs:{shape:O}});if(m){var w=Sk({inputs:{x:k},backend:r,attrs:{begin:v,size:y}});t=yx({inputs:{x:w},backend:r,attrs:{shape:x}}),r.disposeIntermediateTensorInfo(w)}else if(x.some((function(e){return 0===e})))t=r.makeTensorInfo(x,o.dtype,[]);else{if(r.shouldExecuteOnCPU([k])){var j=r.texData.get(k.dataId).values,S=Object(i.zd)(k.shape,k.dtype,j),N=hO(x,S,g,v);t=r.makeTensorInfo(x,k.dtype,N.values)}else{var I=new JN(v,g,x);t=r.runWebGLProgram(I,[k],k.dtype)}}var C=yx({inputs:{x:t},backend:r,attrs:{shape:x}});return r.disposeIntermediateTensorInfo(k),r.disposeIntermediateTensorInfo(t),C}};var tI={kernelName:i.Uc,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=r.separator,i=r.nGramWidths,s=r.leftPad,c=r.rightPad,u=r.padWidth,l=r.preserveShortSequences,d=t.data,f=t.dataSplits,p=n.readSync(d.dataId),h=n.readSync(f.dataId),b=bO(p,h,a,i,s,c,u,l),m=Object(o.a)(b,2),v=m[0],g=m[1];return[n.makeTensorInfo([v.length],"string",v),n.makeTensorInfo(f.shape,"int32",g)]}};var nI={kernelName:i.Vc,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: ".concat(a.shape));if(0!==i.shape.length)throw new Error("Delimiter must be a scalar, got shape: ".concat(i.shape));var s=n.readSync(a.dataId),c=n.readSync(i.dataId)[0],u=mO(s,c,r),l=Object(o.a)(u,3),d=l[0],f=l[1],p=l[2],h=f.length;return[n.makeTensorInfo([h,2],"int32",d),n.makeTensorInfo([h],"string",f),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};var rI={kernelName:i.Wc,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=vO(i,r);return n.makeTensorInfo(a.shape,"int32",o)}},aI=ux({opSnippet:"return tan(x);"}),iI={kernelName:i.Zc,backendName:"webgl",kernelFunc:aI},oI=ux({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),sI={kernelName:i.ad,backendName:"webgl",kernelFunc:oI},cI=function e(t,n){Object(Yr.a)(this,e),this.variableNames=["A"];for(var r=new Array(t.length),a=0;a5)throw Error("Tile for rank ".concat(t," is not yet supported"));if(1===t)return"imod(resRC, ".concat(e[0],")");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],a=0;a5){var s=n.readSync(a.dataId),c="string"===a.dtype?s.map((function(e){return i.wf.decodeString(e)})):s,u=Object(i.zd)(a.shape,a.dtype,c),l=yO(u,o);return n.makeTensorInfo(l.shape,l.dtype,l.values)}var d=new cI(a.shape,o);return n.runWebGLProgram(d,[a],a.dtype)}var lI={kernelName:i.dd,backendName:"webgl",kernelFunc:uI},dI=function e(t){Object(Yr.a)(this,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=t,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 "},fI=function e(t){Object(Yr.a)(this,e),this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=t,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 pI(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function hI(e){for(var t=1;tl){var p=n.readSync(a.dataId),h=OO(p,d,a.dtype,s,c),b=Object(o.a)(h,2),m=b[0],v=b[1];return[n.makeTensorInfo(m.shape,m.dtype,m.values),n.makeTensorInfo(v.shape,v.dtype,v.values)]}if(0===s)return d[d.length-1]=0,[n.makeTensorInfo(d,a.dtype,[]),n.makeTensorInfo(d,"int32",[])];if(1===f)return[a,nj({attrs:{shape:d,dtype:"int32",value:0},backend:n})];var g=n.texData.get(a.dataId),y=null!==g&&g.isPacked,O=y?n.unpackTensor(a):a,x=i.wf.sizeFromShape(d)/f,k=yx({inputs:{x:O},attrs:{shape:[x,f]},backend:n});y&&pI(n,O);for(var w=hI(s),j=hI(f),S=null,N=function(){return null===S?[k,k]:[k,S]},I=function(e,t,r){var a=N(),i=new dI(r),o=[[f],[null===S?1:0],[Number.NEGATIVE_INFINITY],[e],[t]],s=S;S=n.runWebGLProgram(i,a,"int32",o),pI(n,s)},C=1;C=1;E/=2)I(T,E,[x,j]);for(var A=j;A>w;A/=2){var R=N(),F=new fI([x,A/2]),D=[[f],[null===S?1:0],[w]],_=S;S=n.runWebGLProgram(F,R,"int32",D),pI(n,_);for(var M=w/2,z=2*M,L=M;L>=1;L/=2)I(z,L,S.shape)}var P=S;S=Sk({inputs:{x:S},backend:n,attrs:{begin:0,size:[x,s]}}),pI(n,P);var B=Oj({inputs:{x:k,indices:S},backend:n,attrs:{axis:1,batchDims:1}});pI(n,k);var W=d.slice(0,-1);W.push(s),P=S,S=yx({inputs:{x:S},attrs:{shape:W},backend:n}),pI(n,P);var U=B;return B=yx({inputs:{x:B},attrs:{shape:W},backend:n}),pI(n,U),[B,S]}},mI=function e(t,n,r,a,i,o){Object(Yr.a)(this,e),this.variableNames=["Image","Transforms"],this.outputShape=o;var s,c="nearest"===r?1:2;switch(a){case"constant":s=1;break;case"reflect":s=2;break;case"wrap":s=3;break;case"nearest":s=4;break;default:s=1}this.userCode="\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(".concat(s," == 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 (").concat(s," == 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 (").concat(s," == 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 < ").concat(t," && 0 <= coordX && coordX < ").concat(n,") {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(").concat(i,");\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(").concat(i,");\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(").concat(n,"));\n float mapY = mapCoord(inY, float(").concat(t,"));\n\n if (").concat(c," == 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 vI={kernelName:i.fd,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.image,i=t.transforms,s=r.interpolation,c=r.fillMode,u=r.fillValue,l=r.outputShape,d=Object(o.a)(a.shape,4),f=d[0],p=d[1],h=d[2],b=d[3],m=null!=l?l:[p,h],v=Object(o.a)(m,2),g=v[0],y=v[1],O=new mI(p,h,s,c,u,[f,g,y,b]);return n.runWebGLProgram(O,[a,i],"float32")}};var gI={kernelName:i.hd,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=n.axis,i=t.x;Pg(i,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");var o=r.readSync(i.dataId),s=kO(o,a,i.shape,i.dtype),c=s.outputValues,u=s.outputShape,l=s.indices;return[r.makeTensorInfo(u,i.dtype,c),r.makeTensorInfo([l.length],"int32",l)]}};var yI={kernelName:i.id,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,c=a.shape[i],u=new Array(s-1),l=0,d=0;d0&&(d="\n if (inIdx < 0 || inIdx >= ".concat(i,") {\n return initializationValue;\n }\n "));var f="";i%r>0&&(f="\n if (inIdx < 0 || inIdx >= ".concat(i,") {\n return -1.0;\n }\n ")),this.userCode="\n const float initializationValue = ".concat("0.0",";\n\n float getValue(int batch, int inIdx) {\n ").concat(d,"\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ").concat(f,"\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 ").concat(o,")) * float(").concat(r,"));\n int currentSeg = int(mod(float(outIdx), float(").concat(o,")));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ").concat(c,"; 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 ").concat(l,"\n }\n\n int inIdx = inOffset + ").concat(c,";\n if (").concat(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 ").concat(l,"\n } else if (").concat(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 ").concat(l,"\n } else if (").concat(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 ").concat(l,"\n }\n setOutput(").concat("sumValue",");\n }\n ")};for(var xI=0,kI=[$j,Zj,Rx,Dx,Mx,Lx,Wx,Hx,Gx,qx,Zx,Jx,tk,rk,sk,ik,uk,pk,fk,mk,vk,gk,xk,Ik,Ck,Fk,Mk,Pk,Uk,nx,$k,sw,cw,nw,lw,dw,uw,pw,bw,vw,xw,kw,jw,Ew,Aw,Iw,Fw,_w,Mw,Lw,Pw,Ww,Vw,qw,Xw,Qw,ej,aj,oj,uj,dj,hj,bj,mj,gj,xj,wj,Sj,ex,Nj,Kk,Cj,Ej,Rj,ix,Dj,Mj,zj,Wj,Pj,Vj,Gj,Kj,eS,aS,rS,sS,cS,uS,nS,lS,dS,pS,mS,gS,IS,gx,TS,AS,FS,_S,Ek,zS,BS,WS,GS,KS,cx,XS,$S,Rk,xS,ZS,nN,eN,Ox,iN,sN,lN,fN,bN,vN,yN,xN,wN,SN,IN,TN,AN,FN,_N,Nk,NS,zN,LN,PN,BN,WN,UN,VN,HN,qN,XN,QN,ZN,eI,tI,nI,rI,jS,Cx,iI,sI,lI,bI,vI,Ex,gI,yI,{kernelName:i.jd,backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,o=t.segmentIds,s=r.numSegments,c=a.shape.length,u=[],l=0,d=i.ud.getAxesPermutation([l],c),f=a;null!=d&&(f=Tx({inputs:{x:a},backend:n,attrs:{perm:d}}),u.push(f),l=i.ud.getInnerMostAxes(1,c)[0]);var p=i.ud.segment_util.computeOutShape(f.shape,l,s),h=i.wf.sizeFromShape([f.shape[l]]),b=yx({inputs:{x:f},backend:n,attrs:{shape:[-1,h]}});u.push(b);var m=yx({inputs:{x:function e(t,r,a,o,s){var c=t.shape[0],l=t.shape[1],d=i.ud.segment_util.segOpComputeOptimalWindowSize(l,s),f=new OI({windowSize:d,inSize:l,batchSize:c,numSegments:s},r),p=n.compileAndRun(f,[t,a],o);if(u.push(p),p.shape[1]===s)return p;var h=YS({backend:n,attrs:{start:0,stop:s,step:1,dtype:"float32"}}),b=uI({inputs:{x:h},backend:n,attrs:{reps:[l/d]}});return u.push(h),u.push(b),e(p,r,b,o,s)}(b,"unsortedSegmentSum",o,Object(i.jf)(a.dtype),s)},backend:n,attrs:{shape:p}}),v=m;if(null!=d){u.push(m);var g=i.ud.getUndoAxesPermutation(d);v=Tx({inputs:{x:v},backend:n,attrs:{perm:g}})}return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),v}},PS];xI0,(function(){return"variableGrads() expects at least one of the input variables to "+"be trainable, but none of the ".concat(c," variables is ")+"trainable."}));var u=r.a.gradients(e,t,null,!0),l=u.value,d=u.grads;i.b(d.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()."})),i.b(0===l.rank,(function(){return"The f passed in variableGrads(f) must return a scalar, but it "+"returned a rank-".concat(l.rank," tensor")}));var f={};return t.forEach((function(e,t){null!=d[t]&&(f[e.name]=d[t])})),null!=s&&s.forEach((function(e){return f[e.name]=null})),{value:l,grads:f}}function s(e){return r.a.customGrad(e)}},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(r||(r={}))},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({sqrt_:function(e){var t={x:Object(i.a)(e,"x","sqrt")};return r.a.runKernel(a.Oc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return O})),n.d(t,"b",(function(){return j})),n.d(t,"c",(function(){return b})),n.d(t,"d",(function(){return E})),n.d(t,"e",(function(){return h})),n.d(t,"f",(function(){return w})),n.d(t,"g",(function(){return R})),n.d(t,"h",(function(){return F}));var r=n(63),a=n(4),i=n.n(a),o=(n(30),n(96)),s=n(242),c=n(88),u=n(14),l=n(243),d=n.n(l),f=(n(140),n(75)),p=(n(168),function(e){var t=Object(s.a)();return t.displayName=e,t}("Router-History")),h=function(e){var t=Object(s.a)();return t.displayName=e,t}("Router"),b=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={location:t.history.location},n._isMounted=!1,n._pendingLocation=null,t.staticContext||(n.unlisten=t.history.listen((function(e){n._isMounted?n.setState({location:e}):n._pendingLocation=e}))),n}Object(r.a)(t,e),t.computeRootMatch=function(e){return{path:"/",url:"/",params:{},isExact:"/"===e}};var n=t.prototype;return n.componentDidMount=function(){this._isMounted=!0,this._pendingLocation&&this.setState({location:this._pendingLocation})},n.componentWillUnmount=function(){this.unlisten&&this.unlisten()},n.render=function(){return i.a.createElement(h.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},i.a.createElement(p.Provider,{children:this.props.children||null,value:this.props.history}))},t}(i.a.Component);i.a.Component;var m=function(e){function t(){return e.apply(this,arguments)||this}Object(r.a)(t,e);var n=t.prototype;return n.componentDidMount=function(){this.props.onMount&&this.props.onMount.call(this,this)},n.componentDidUpdate=function(e){this.props.onUpdate&&this.props.onUpdate.call(this,this,e)},n.componentWillUnmount=function(){this.props.onUnmount&&this.props.onUnmount.call(this,this)},n.render=function(){return null},t}(i.a.Component);var v={},g=0;function y(e,t){return void 0===e&&(e="/"),void 0===t&&(t={}),"/"===e?e:function(e){if(v[e])return v[e];var t=d.a.compile(e);return g<1e4&&(v[e]=t,g++),t}(e)(t,{pretty:!0})}function O(e){var t=e.computedMatch,n=e.to,r=e.push,a=void 0!==r&&r;return i.a.createElement(h.Consumer,null,(function(e){e||Object(c.a)(!1);var r=e.history,s=e.staticContext,l=a?r.push:r.replace,d=Object(o.c)(t?"string"===typeof n?y(n,t.params):Object(u.a)({},n,{pathname:y(n.pathname,t.params)}):n);return s?(l(d),null):i.a.createElement(m,{onMount:function(){l(d)},onUpdate:function(e,t){var n=Object(o.c)(t.to);Object(o.f)(n,Object(u.a)({},d,{key:n.key}))||l(d)},to:n})}))}var x={},k=0;function w(e,t){void 0===t&&(t={}),("string"===typeof t||Array.isArray(t))&&(t={path:t});var n=t,r=n.path,a=n.exact,i=void 0!==a&&a,o=n.strict,s=void 0!==o&&o,c=n.sensitive,u=void 0!==c&&c;return[].concat(r).reduce((function(t,n){if(!n&&""!==n)return null;if(t)return t;var r=function(e,t){var n=""+t.end+t.strict+t.sensitive,r=x[n]||(x[n]={});if(r[e])return r[e];var a=[],i={regexp:d()(e,a,t),keys:a};return k<1e4&&(r[e]=i,k++),i}(n,{end:i,strict:s,sensitive:u}),a=r.regexp,o=r.keys,c=a.exec(e);if(!c)return null;var l=c[0],f=c.slice(1),p=e===l;return i&&!p?null:{path:n,url:"/"===n&&""===l?"/":l,isExact:p,params:o.reduce((function(e,t,n){return e[t.name]=f[n],e}),{})}}),null)}var j=function(e){function t(){return e.apply(this,arguments)||this}return Object(r.a)(t,e),t.prototype.render=function(){var e=this;return i.a.createElement(h.Consumer,null,(function(t){t||Object(c.a)(!1);var n=e.props.location||t.location,r=e.props.computedMatch?e.props.computedMatch:e.props.path?w(n.pathname,e.props):t.match,a=Object(u.a)({},t,{location:n,match:r}),o=e.props,s=o.children,l=o.component,d=o.render;return Array.isArray(s)&&0===s.length&&(s=null),i.a.createElement(h.Provider,{value:a},a.match?s?"function"===typeof s?s(a):s:l?i.a.createElement(l,a):d?d(a):null:"function"===typeof s?s(a):null)}))},t}(i.a.Component);function S(e){return"/"===e.charAt(0)?e:"/"+e}function N(e,t){if(!e)return t;var n=S(e);return 0!==t.pathname.indexOf(n)?t:Object(u.a)({},t,{pathname:t.pathname.substr(n.length)})}function I(e){return"string"===typeof e?e:Object(o.e)(e)}function C(e){return function(){Object(c.a)(!1)}}function T(){}i.a.Component;var E=function(e){function t(){return e.apply(this,arguments)||this}return Object(r.a)(t,e),t.prototype.render=function(){var e=this;return i.a.createElement(h.Consumer,null,(function(t){t||Object(c.a)(!1);var n,r,a=e.props.location||t.location;return i.a.Children.forEach(e.props.children,(function(e){if(null==r&&i.a.isValidElement(e)){n=e;var o=e.props.path||e.props.from;r=o?w(a.pathname,Object(u.a)({},e.props,{path:o})):t.match}})),r?i.a.cloneElement(n,{location:a,computedMatch:r}):null}))},t}(i.a.Component);var A=i.a.useContext;function R(){return A(p)}function F(){return A(h).location}},function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return i})),n.d(t,"d",(function(){return o})),n.d(t,"e",(function(){return s})),n.d(t,"a",(function(){return c})),n.d(t,"f",(function(){return u})),n.d(t,"h",(function(){return l})),n.d(t,"g",(function(){return d}));var r=n(15);function a(e,t){for(var n=0;n0&&(n=Object(p.a)(n,a)),Object(l.a)(n,e.shape)}function m(e,t,n,r){if("linear"===t)return e;if("relu"===t)return Object(c.a)(e);if("elu"===t)return Object(a.a)(e);if("relu6"===t)return Object(u.a)(e);if("prelu"===t)return Object(s.a)(e,n);if("leakyrelu"===t)return Object(i.a)(e,r);if("sigmoid"===t)return Object(d.a)(e);throw new Error("Unknown fused activation ".concat(t,"."))}var v=function(e,t){return!(e>0)||"linear"===t}},function(e,t,n){"use strict";n.d(t,"f",(function(){return y})),n.d(t,"e",(function(){return O})),n.d(t,"d",(function(){return x})),n.d(t,"g",(function(){return k})),n.d(t,"a",(function(){return j})),n.d(t,"b",(function(){return _})),n.d(t,"c",(function(){return w}));var r=n(20),a=n(16),i=n(17),o=n(5),s=n.n(o),c=n(12),u=n(7),l=n(11),d=n(0),f=n(109),p=n(95);function h(e){return e instanceof d.bd?{value:e.clone(),recurse:!1}:Object(p.e)(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}var b=n(28),m=n(26),v=function(){function e(t){if(Object(u.a)(this,e),this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return Object(l.a)(e,[{key:"wrap",value:function(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}},{key:"get",value:function(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}},{key:"set",value:function(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t}},{key:"length",value:function(){var e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e}},{key:"isFull",value:function(){return this.length()===this.capacity}},{key:"isEmpty",value:function(){return 0===this.length()}},{key:"push",value:function(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)}},{key:"pushAll",value:function(e){var t,n=Object(r.a)(e);try{for(n.s();!(t=n.n()).done;){var a=t.value;this.push(a)}}catch(i){n.e(i)}finally{n.f()}}},{key:"pop",value: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}},{key:"unshift",value:function(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}},{key:"shift",value: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}},{key:"shuffleExcise",value: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}(),g=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(){return Object(u.a)(this,n),t.call(this,n.INITIAL_CAPACITY)}return Object(l.a)(n,[{key:"isFull",value:function(){return!1}},{key:"push",value:function(e){Object(b.a)(Object(m.a)(n.prototype),"isFull",this).call(this)&&this.expand(),Object(b.a)(Object(m.a)(n.prototype),"push",this).call(this,e)}},{key:"unshift",value:function(e){Object(b.a)(Object(m.a)(n.prototype),"isFull",this).call(this)&&this.expand(),Object(b.a)(Object(m.a)(n.prototype),"unshift",this).call(this,e)}},{key:"expand",value:function(){for(var e=2*this.capacity,t=new Array(e),n=this.length(),r=0;r1&&void 0!==arguments[1]?arguments[1]:w.FAIL;return new L(e,t)}g.INITIAL_CAPACITY=32;var w,j=function(){function e(){Object(u.a)(this,e)}return Object(l.a)(e,[{key:"toArray",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t,n;return s.a.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)}}()},{key:"toArrayForTest",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t,n,r;return s.a.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)}}()},{key:"resolveFully",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t;return s.a.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)}}()},{key:"resolveWhile",value:function(){var e=Object(c.a)(s.a.mark((function e(t){var n,r;return s.a.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)}}()},{key:"handleErrors",value:function(e){return new F(this,e)}},{key:"filter",value:function(e){return new A(this,e)}},{key:"map",value:function(e){return new R(this,e)}},{key:"mapAsync",value:function(e){return new D(this,e)}},{key:"serialMapAsync",value:function(e){return new D(this,e).serial()}},{key:"flatmap",value:function(e){return new M(this,e)}},{key:"forEachAsync",value:function(){var e=Object(c.a)(s.a.mark((function e(t){return s.a.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)}}()},{key:"serialForEach",value:function(){var e=Object(c.a)(s.a.mark((function e(t){return s.a.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)}}()},{key:"rowMajorBatch",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new E(this,e,t)}},{key:"columnMajorBatch",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p.f,r=this.rowMajorBatch(e,t);return r.map((function(e){return Object(p.d)(e,n)}))}},{key:"concatenate",value:function(e,t){return new z(y([this,e]),t)}},{key:"take",value:function(e){return e<0||null==e?this:new T(this,e)}},{key:"skip",value:function(e){return e<0||null==e?this:new C(this,e)}},{key:"prefetch",value:function(e){return new P(this,e)}},{key:"shuffle",value:function(e,t){return new B(this,e,t)}},{key:"serial",value:function(){return new I(this)}}]),e}(),S=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e){var r;return Object(u.a)(this,n),(r=t.call(this)).items=e,r.trav=0,r}return Object(l.a)(n,[{key:"summary",value:function(){return"Array of ".concat(this.items.length," items")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t;return s.a.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:(n=t,Object(p.b)(n,h)),done:!1});case 5:case"end":return e.stop()}var n}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),n}(j),N=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e){var r;return Object(u.a)(this,n),(r=t.call(this)).nextFn=e,r}return Object(l.a)(n,[{key:"summary",value:function(){return"Function call"}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){return s.a.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: ".concat(e.t0.message),e.t0;case 8:case"end":return e.stop()}}),e,this,[[0,4]])})));return function(){return e.apply(this,arguments)}}()}]),n}(j),I=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e){var r;return Object(u.a)(this,n),(r=t.call(this)).upstream=e,r.lastRead=Promise.resolve({value:null,done:!1}),r}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> Serial")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t=this;return s.a.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)}}()},{key:"serialNext",value:function(){var e=Object(c.a)(s.a.mark((function e(){return s.a.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)}}()}]),n}(j),C=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a;return Object(u.a)(this,n),(a=t.call(this)).upstream=e,a.maxCount=r,a.count=0,a.lastRead=Promise.resolve({value:null,done:!1}),a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> Skip")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t=this;return s.a.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)}}()},{key:"serialNext",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.count++ Take")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){return s.a.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)}}()}]),n}(j),E=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return Object(u.a)(this,n),(a=t.call(this)).upstream=e,a.batchSize=r,a.enableSmallLastBatch=i,a.lastRead=Promise.resolve({value:null,done:!1}),a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> RowMajorBatch")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t=this;return s.a.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)}}()},{key:"serialNext",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t,n;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[];case 1:if(!(t.length0)){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)}}()}]),n}(j),A=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a;return Object(u.a)(this,n),(a=t.call(this)).upstream=e,a.predicate=r,a.lastRead=Promise.resolve({value:null,done:!1}),a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> Filter")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t=this;return s.a.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)}}()},{key:"serialNext",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t;return s.a.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:d.Pd(t.value),e.next=0;break;case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),n}(j),R=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a;return Object(u.a)(this,n),(a=t.call(this)).upstream=e,a.transform=r,a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> Map")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t,n,a,i,o,c,u;return s.a.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:n=d.of.getTensorsInContainer(t.value),a=this.transform(t.value),i=d.of.getTensorsInContainer(a),o=Object(r.a)(n);try{for(o.s();!(c=o.n()).done;)u=c.value,d.of.isTensorInList(u,i)||u.dispose()}catch(s){o.e(s)}finally{o.f()}return e.abrupt("return",{value:a,done:!1});case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),n}(j),F=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a;return Object(u.a)(this,n),(a=t.call(this)).upstream=e,a.handler=r,a.count=0,a.lastRead=Promise.resolve({value:null,done:!1}),a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> handleErrors")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t=this;return s.a.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)}}()},{key:"serialNext",value:function(){var e=Object(c.a)(s.a.mark((function e(){return s.a.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)}}()}]),n}(j),D=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a;return Object(u.a)(this,n),(a=t.call(this)).upstream=e,a.transform=r,a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> AsyncMap")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t,n,a,i,o,c,u;return s.a.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=d.of.getTensorsInContainer(t.value),e.next=8,this.transform(t.value);case 8:a=e.sent,i=d.of.getTensorsInContainer(a),o=Object(r.a)(n);try{for(o.s();!(c=o.n()).done;)u=c.value,d.of.isTensorInList(u,i)||u.dispose()}catch(s){o.e(s)}finally{o.f()}return e.abrupt("return",{value:a,done:!1});case 13:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),n}(j),_=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(){var e;return Object(u.a)(this,n),(e=t.call(this)).outputQueue=new g,e.lastRead=Promise.resolve({value:null,done:!1}),e}return Object(l.a)(n,[{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t=this;return s.a.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)}}()},{key:"serialNext",value:function(){var e=Object(c.a)(s.a.mark((function e(){return s.a.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)}}()}]),n}(j),M=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a;return Object(u.a)(this,n),(a=t.call(this)).upstream=e,a.transform=r,a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> Flatmap")}},{key:"pump",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t,n,a,i,o,c,u;return s.a.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:n=d.of.getTensorsInContainer(t.value),a=this.transform(t.value),i=d.of.getTensorsInContainer(a),this.outputQueue.pushAll(a),o=Object(r.a)(n);try{for(o.s();!(c=o.n()).done;)u=c.value,d.of.isTensorInList(u,i)||u.dispose()}catch(s){o.e(s)}finally{o.f()}return e.abrupt("return",!0);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),n}(_),z=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a;return Object(u.a)(this,n),(a=t.call(this)).baseErrorHandler=r,a.lastRead=null,a.iterator=null,a.moreIterators=e,a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat("TODO: fill in upstream of chained summaries"," -> Chained")}},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){return s.a.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)}}()},{key:"readFromChain",value:function(){var e=Object(c.a)(s.a.mark((function e(t){var n,r;return s.a.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)}}()}]),n}(j);!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(w||(w={}));var L=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:w.FAIL;return Object(u.a)(this,n),(r=t.call(this)).iterators=e,r.mismatchMode=a,r.count=0,r.currentPromise=null,r}return Object(l.a)(n,[{key:"summary",value:function(){return"{".concat("TODO: fill in upstream of zip summaries","} -> Zip")}},{key:"nextState",value:function(){var e=Object(c.a)(s.a.mark((function e(t){var n,r,a,i;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=function(e){return e instanceof j?{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,Object(p.c)(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===w.FAIL?14:e.t0===w.SHORTEST?15:(e.t0,w.LONGEST,16);break;case 14:throw new Error("Zipped streams should have the same length. "+"Mismatched at element ".concat(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)}}()},{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){return s.a.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)}}()}]),n}(j),P=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r){var a;return Object(u.a)(this,n),(a=t.call(this)).upstream=e,a.bufferSize=r,a.buffer=new v(r),a}return Object(l.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> Prefetch")}},{key:"refill",value:function(){for(;!this.buffer.isFull();){var e=this.upstream.next();this.buffer.push(e)}}},{key:"next",value:function(){return this.refill(),this.buffer.shift()}}]),n}(j),B=function(e){Object(a.a)(n,e);var t=Object(i.a)(n);function n(e,r,a){var i;return Object(u.a)(this,n),(i=t.call(this,e,r)).upstream=e,i.windowSize=r,i.upstreamExhausted=!1,i.random=f.alea(a||d.wf.now().toString()),i.lastRead=Promise.resolve({value:null,done:!1}),i}return Object(l.a)(n,[{key:"next",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t=this;return s.a.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)}}()},{key:"randomInt",value:function(e){return Math.floor(this.random()*e)}},{key:"chooseIndex",value:function(){return this.randomInt(this.buffer.length())}},{key:"serialNext",value:function(){var e=Object(c.a)(s.a.mark((function e(){var t,n;return s.a.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)}}()}]),n}(P)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(10),a=n(15);function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"float32",n=arguments.length>2?arguments[2]:void 0;return t=t||"float32",a.c(e),new r.b(e,t,n)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({reverse_:function(e,t){var n={x:Object(i.a)(e,"x","reverse")},o={dims:t};return r.a.runKernel(a.tc,n,o)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),a=n(15),i=n(71);function o(e,t){Object(a.d)(e);var n=Object(r.c)(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Object(i.a)(e,null,n,t)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(9),a=n(15),i=n(19);function o(e,t,n,o){if(null==o&&(o=Object(a.r)(e)),"complex64"===o)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Object(a.A)(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){Object(a.c)(t);var s=Object(a.O)(t),c=Object(a.O)(n);Object(a.b)(s===c,(function(){return"Based on the provided shape, [".concat(t,"], the tensor should have ")+"".concat(s," values but has ").concat(c)}));for(var u=0;u1&&void 0!==arguments[1]?arguments[1]:"float32";if("complex64"===t){var n=s(e,"float32"),c=Object(o.a)(e,"float32");return Object(i.a)(n,c)}var u=Object(a.D)(Object(a.O)(e),t);return r.a.makeTensor(u,e,t)}},function(e,t,n){"use strict";function r(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r=0||(a[n]=e[n]);return a}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(34),u=n(8);var l=Object(u.b)({lessEqual_:function(e,t){var n=Object(s.a)(e,"a","lessEqual","string_or_numeric"),u=Object(s.a)(t,"b","lessEqual","string_or_numeric"),l=Object(o.makeTypesMatch)(n,u),d=Object(r.a)(l,2);n=d[0],u=d[1],Object(c.a)(n.shape,u.shape);var f={a:n,b:u};return a.a.runKernel(i.Ab,f)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({pad_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=Object(i.a)(e,"x","pad");if(0===o.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var s={paddings:t,constantValue:n},c={x:o};return r.a.runKernel(a.ec,c,s)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({transpose_:function(e,t){var n=Object(i.a)(e,"x","transpose");if(null==t&&(t=n.shape.map((function(e,t){return t})).reverse()),o.b(n.rank===t.length,(function(){return"Error in transpose: rank of input ".concat(n.rank," ")+"must match length of perm ".concat(t,".")})),t.forEach((function(e){o.b(e>=0&&e1&&void 0!==arguments[1]?arguments[1]:{},a=e.node,i=[],o=[],s=[],c=a.reduce((function(e,n){return e[n.name]=t.mapNode(n),n.op.startsWith("Placeholder")?i.push(e[n.name]):"Const"===n.op?o.push(e[n.name]):null!=n.input&&0!==n.input.length||s.push(e[n.name]),e}),{}),u=[],d=[],f={},p={};null!=n&&(f=this.mapSignatureEntries(n.inputs),p=this.mapSignatureEntries(n.outputs));var h=Object.keys(c);h.forEach((function(e){var t=c[e];t.inputNames.forEach((function(e,n){var a=Object(l.b)(e),i=Object(r.a)(a,3),o=i[0],s=i[2],u=c[o];if(null!=u.outputs){var d=u.outputs.indexOf(s);if(-1!==d){var f="".concat(o,":").concat(d);t.inputNames[n]=f}}t.inputs.push(u),u.children.push(t)}))})),0===Object.keys(p).length?h.forEach((function(e){var t=c[e];0===t.children.length&&d.push(t)})):Object.keys(p).forEach((function(e){var t=Object(l.b)(e),n=Object(r.a)(t,1)[0],a=c[n];null!=a&&(a.signatureKey=p[e],d.push(a))})),Object.keys(f).length>0?Object.keys(f).forEach((function(e){var t=Object(l.b)(e),n=Object(r.a)(t,1)[0],a=c[n];a&&(a.signatureKey=f[e],u.push(a))})):u=i;var b={};null!=e.library&&null!=e.library.function&&(b=e.library.function.reduce((function(e,n){return e[n.signature.name]=t.mapFunction(n),e}),{}));var m={nodes:c,inputs:u,outputs:d,weights:o,placeholders:i,signature:n,functions:b};return s.length>0&&(m.initNodes=s),m}},{key:"mapSignatureEntries",value:function(e){return Object.keys(e||{}).reduce((function(t,n){return t[e[n].name]=n,t}),{})}},{key:"mapNode",value:function(e){var t=Object(u.a)(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.substr(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=R(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=R(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":void 0===(a=U(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=U(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":void 0===(a=D(e.attr,n.tfName,n.defaultValue||0))&&n.tfDeprecatedName&&(a=D(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":void 0===(a=W(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=W(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":void 0===(a=F(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=F(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":void 0===(a=H(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=H(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":void 0===(a=B(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=B(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":void 0===(a=V(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=V(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":void 0===(a=z(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=z(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":void 0===(a=L(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=L(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":void 0===(a=M(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=M(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: ".concat(n.type," for op: ").concat(e.op))}return t[n.name]={value:a,type:r},t}),{})),n}},{key:"mapFunction",value:function(e){var t=this,n=e.nodeDef,a=[],i={};null!=n&&(i=n.reduce((function(e,n){return e[n.name]=t.mapNode(n),"Const"===n.op&&a.push(e[n.name]),e}),{}));var o=[],s=[];e.signature.inputArg.forEach((function(e){var t=Object(l.b)(e.name),n=Object(r.a)(t,1)[0],a={name:n,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:_(e.type),type:"dtype"}},children:[]};a.signatureKey=e.name,o.push(a),i[n]=a})),Object.keys(i).forEach((function(e){var t=i[e];t.inputNames.forEach((function(e,n){var a=Object(l.b)(e),o=Object(r.a)(a,3),s=o[0],c=o[2],u=i[s];if(null!=u.outputs){var d=u.outputs.indexOf(c);if(-1!==d){var f="".concat(s,":").concat(d);t.inputNames[n]=f}}t.inputs.push(u),u.children.push(t)}))}));var c=e.ret;e.signature.outputArg.forEach((function(e){var t=Object(l.b)(c[e.name]),n=Object(r.a)(t,2),a=n[0],o=n[1],u=i[a];null!=u&&(u.defaultOutput=o,s.push(u))}));var u=this.mapArgsToSignature(e);return{nodes:i,inputs:o,outputs:s,weights:a,placeholders:[],signature:u}}},{key:"mapArgsToSignature",value: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}),{})}}},{key:"mapArgToTensorInfo",value:function(e,t){var n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}],[{key:"Instance",get:function(){return this._instance||(this._instance=new this)}}]),e}();function A(t,n){var r=Array.isArray(t)?String.fromCharCode.apply(null,t):function(t){var n=Object(s.Ud)().global;if("undefined"!==typeof n.atob)return n.atob(t);if("undefined"!==typeof e)return new e(t,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(t);return n?r:r.toLowerCase()}function R(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e[t];return null!=a?A(a.s,r):n}function F(e,t,n){var r=e[t];return r?r.b:n}function D(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 _(e){switch("string"===typeof e&&(e=c.a[e]),e){case c.a.DT_FLOAT:return"float32";case c.a.DT_INT32:case c.a.DT_INT64:case c.a.DT_INT8:case c.a.DT_UINT8:return"int32";case c.a.DT_BOOL:return"bool";case c.a.DT_DOUBLE:return"float32";case c.a.DT_STRING:return"string";default:return null}}function M(e,t,n){var r=e[t];return r&&r.func?r.func.name:n}function z(e,t,n){var r=e[t];return r&&r.type?_(r.type):n}function L(e,t,n){var r=e[t];return r&&r.list&&r.list.type?r.list.type.map((function(e){return _(e)})):n}function P(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 B(e,t,n){var r=e[t];return r&&r.shape?P(r.shape):n}function W(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 U(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e[t];return a&&a.list&&a.list.s?a.list.s.map((function(e){return A(e,r)})):n}function V(e,t,n){var r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((function(e){return P(e)})):n}function H(e,t,n){var r=e[t];return r&&r.list&&r.list.b?r.list.b:n}}).call(this,n(239).Buffer)},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({complex_:function(e,t){var n=Object(i.a)(e,"real","complex"),s=Object(i.a)(t,"imag","complex");o.e(n.shape,s.shape,"real and imag shapes, ".concat(n.shape," and ").concat(s.shape,", ")+"must match in call to tf.complex().");var c={real:n,imag:s};return r.a.runKernel(a.z,c)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(34),s=n(8);var c=Object(s.b)({logicalAnd_:function(e,t){var n=Object(i.a)(e,"a","logicalAnd","bool"),s=Object(i.a)(t,"b","logicalAnd","bool");Object(o.a)(n.shape,s.shape);var c={a:n,b:s};return r.a.runKernel(a.Fb,c)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({split_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=Object(i.a)(e,"x","split"),s={x:o},c={numOrSizeSplits:t,axis:n};return r.a.runKernel(a.Nc,s,c)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({stack_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Object(i.b)(e,"tensors","stack","string_or_numeric");o.b(n.length>=1,(function(){return"Pass at least one tensor to tf.stack"})),n.length>0&&o.b(t<=n[0].rank,(function(){return"Axis must be <= rank of the tensor"}));var s=n,c={axis:t};return r.a.runKernel(a.dc,s,c)}})},function(e,t,n){"use strict";n.d(t,"b",(function(){return c})),n.d(t,"a",(function(){return u})),n.d(t,"c",(function(){return l})),n.d(t,"e",(function(){return d})),n.d(t,"d",(function(){return f}));var r=n(6),a=n(38),i=n(136),o=Object(i.a)("kernelRegistry",(function(){return new Map})),s=Object(i.a)("gradRegistry",(function(){return new Map}));function c(e,t){var n=p(e,t);return o.get(n)}function u(e){return s.get(e)}function l(e){for(var t=o.entries(),n=[];;){var a=t.next(),i=a.done,s=a.value;if(i)break;var c=Object(r.a)(s,2),u=c[0],l=c[1],d=u.split("_");Object(r.a)(d,1)[0]===e&&n.push(l)}return n}function d(e){var t=e.kernelName,n=e.backendName,r=p(t,n);o.has(r)&&console.warn("The kernel '".concat(t,"' for backend ")+"'".concat(n,"' is already registered")),o.set(r,e)}function f(e){var t=e.kernelName;s.has(t)&&Object(a.b)().getBool("DEBUG")&&console.warn("Overriding the gradient for '".concat(t,"'")),s.set(t,e)}function p(e,t){return"".concat(t,"_").concat(e)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({expandDims_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Object(i.a)(e,"x","expandDims","string_or_numeric");o.b(t<=n.rank,(function(){return"Axis must be <= rank of the tensor"}));var s={input:n},c={dim:t};return r.a.runKernel(a.bb,s,c)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return f}));var r=n(14),a=n(4),i=n.n(a),o=n(23),s=(n(30),n(25)),c=n(35),u=n(42),l=a.forwardRef((function(e,t){var n=e.children,i=e.classes,c=e.className,l=e.color,d=void 0===l?"inherit":l,f=e.component,p=void 0===f?"svg":f,h=e.fontSize,b=void 0===h?"default":h,m=e.htmlColor,v=e.titleAccess,g=e.viewBox,y=void 0===g?"0 0 24 24":g,O=Object(o.a)(e,["children","classes","className","color","component","fontSize","htmlColor","titleAccess","viewBox"]);return a.createElement(p,Object(r.a)({className:Object(s.a)(i.root,c,"inherit"!==d&&i["color".concat(Object(u.a)(d))],"default"!==b&&i["fontSize".concat(Object(u.a)(b))]),focusable:"false",viewBox:y,color:m,"aria-hidden":!v||void 0,role:v?"img":void 0,ref:t},O),n,v?a.createElement("title",null,v):null)}));l.muiName="SvgIcon";var d=Object(c.a)((function(e){return{root:{userSelect:"none",width:"1em",height:"1em",display:"inline-block",fill:"currentColor",flexShrink:0,fontSize:e.typography.pxToRem(24),transition:e.transitions.create("fill",{duration:e.transitions.duration.shorter})},colorPrimary:{color:e.palette.primary.main},colorSecondary:{color:e.palette.secondary.main},colorAction:{color:e.palette.action.active},colorError:{color:e.palette.error.main},colorDisabled:{color:e.palette.action.disabled},fontSizeInherit:{fontSize:"inherit"},fontSizeSmall:{fontSize:e.typography.pxToRem(20)},fontSizeLarge:{fontSize:e.typography.pxToRem(35)}}}),{name:"MuiSvgIcon"})(l);function f(e,t){var n=function(t,n){return i.a.createElement(d,Object(r.a)({ref:n},t),e)};return n.muiName=d.muiName,i.a.memo(i.a.forwardRef(n))}},function(e,t,n){"use strict";var r="Invariant failed";t.a=function(e,t){if(!e)throw new Error(r)}},function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(48),c=n(8),u=n(13);var l=Object(c.b)({conv2d_:function(e,t,n,c){var l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"NHWC",d=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[1,1],f=arguments.length>6?arguments[6]:void 0,p=Object(i.a)(e,"x","conv2d"),h=Object(i.a)(t,"filter","conv2d"),b=p,m=!1;3===p.rank&&(m=!0,b=Object(u.a)(p,[1,p.shape[0],p.shape[1],p.shape[2]])),o.b(4===b.rank,(function(){return"Error in conv2d: input must be rank 4, but got rank ".concat(b.rank,".")})),o.b(4===h.rank,(function(){return"Error in conv2d: filter must be rank 4, but got rank "+"".concat(h.rank,".")})),null!=f&&o.b(o.v(c),(function(){return"Error in conv2d: pad must be an integer when using, "+"dimRoundingMode ".concat(f," but got pad ").concat(c,".")}));var v="NHWC"===l?b.shape[3]:b.shape[1];o.b(v===h.shape[2],(function(){return"Error in conv2d: depth of input (".concat(v,") must match ")+"input depth for filter ".concat(h.shape[2],".")})),o.b(s.h(n,d),(function(){return"Error in conv2D: Either strides or dilations must be 1. "+"Got strides ".concat(n," and dilations '").concat(d,"'")}));var g={x:b,filter:h},y={strides:n,pad:c,dataFormat:l,dilations:d,dimRoundingMode:f},O=r.a.runKernel(a.C,g,y);return m?Object(u.a)(O,[O.shape[1],O.shape[2],O.shape[3]]):O}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(34),u=n(8);var l=Object(u.b)({greaterEqual_:function(e,t){var n=Object(s.a)(e,"a","greaterEqual","string_or_numeric"),u=Object(s.a)(t,"b","greaterEqual","string_or_numeric"),l=Object(o.makeTypesMatch)(n,u),d=Object(r.a)(l,2);n=d[0],u=d[1],Object(c.a)(n.shape,u.shape);var f={a:n,b:u};return a.a.runKernel(i.pb,f)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({clone_:function(e){var t={x:Object(i.a)(e,"x","clone","string_or_numeric")};return r.a.runKernel(a.rb,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({sigmoid_:function(e){var t={x:Object(i.a)(e,"x","sigmoid")};return r.a.runKernel(a.Ac,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({max_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=Object(i.a)(e,"x","max"),s={x:o},c={reductionIndices:t,keepDims:n};return r.a.runKernel(a.Ib,s,c)}})},function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"d",(function(){return u})),n.d(t,"f",(function(){return d})),n.d(t,"c",(function(){return f})),n.d(t,"e",(function(){return h})),n.d(t,"a",(function(){return b}));var r=n(5),a=n.n(r),i=n(12),o=n(0);function s(e,t){return c(e,t)}function c(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Set;if(null==e)return null;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(h(e)){var i=Array.isArray(e)?[]:{};for(var o in r.add(e),e){var s=e[o],u=c(s,t,n,r);i[o]=u}return r.delete(e),i}throw new Error("Can't recurse into non-iterable type: ".concat(e))}return n.set(e,a.value),a.value}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;return l(e,t)}function l(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,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(h(r)){var i=Array.isArray(r)?[]:{};n.add(r);var o=function(r){var a=l(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: ".concat(r))}return a.value}function d(e){return null===e?null:h(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}function f(e,t){return p.apply(this,arguments)}function p(){return(p=Object(i.a)(a.a.mark((function e(t,n){var r,i,s,u,l,d,f;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Map,c(t,n,r),i=0,s=Array.from(r.keys());case 3:if(!(i=0;f--){var p=o[f];"."===p?i(o,f):".."===p?(i(o,f),d++):d&&(i(o,f),d--)}if(!u)for(;d--;d)o.unshift("..");!u||""===o[0]||o[0]&&a(o[0])||o.unshift("");var h=o.join("/");return n&&"/"!==h.substr(-1)&&(h+="/"),h};function s(e){return e.valueOf?e.valueOf():Object.prototype.valueOf.call(e)}var c=function e(t,n){if(t===n)return!0;if(null==t||null==n)return!1;if(Array.isArray(t))return Array.isArray(n)&&t.length===n.length&&t.every((function(t,r){return e(t,n[r])}));if("object"===typeof t||"object"===typeof n){var r=s(t),a=s(n);return r!==t||a!==n?e(r,a):Object.keys(Object.assign({},t,n)).every((function(r){return e(t[r],n[r])}))}return!1},u=n(88);function l(e){return"/"===e.charAt(0)?e:"/"+e}function d(e){return"/"===e.charAt(0)?e.substr(1):e}function f(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function p(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function h(e){var t=e.pathname,n=e.search,r=e.hash,a=t||"/";return n&&"?"!==n&&(a+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(a+="#"===r.charAt(0)?r:"#"+r),a}function b(e,t,n,a){var i;"string"===typeof e?(i=function(e){var t=e||"/",n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substr(a),t=t.substr(0,a));var i=t.indexOf("?");return-1!==i&&(n=t.substr(i),t=t.substr(0,i)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e)).state=t:(void 0===(i=Object(r.a)({},e)).pathname&&(i.pathname=""),i.search?"?"!==i.search.charAt(0)&&(i.search="?"+i.search):i.search="",i.hash?"#"!==i.hash.charAt(0)&&(i.hash="#"+i.hash):i.hash="",void 0!==t&&void 0===i.state&&(i.state=t));try{i.pathname=decodeURI(i.pathname)}catch(s){throw s instanceof URIError?new URIError('Pathname "'+i.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):s}return n&&(i.key=n),a?i.pathname?"/"!==i.pathname.charAt(0)&&(i.pathname=o(i.pathname,a.pathname)):i.pathname=a.pathname:i.pathname||(i.pathname="/"),i}function m(e,t){return e.pathname===t.pathname&&e.search===t.search&&e.hash===t.hash&&e.key===t.key&&c(e.state,t.state)}function v(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,a){if(null!=e){var i="function"===typeof e?e(t,n):e;"string"===typeof i?"function"===typeof r?r(i,a):a(!0):a(!1!==i)}else a(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;rt?n.splice(t,n.length-t,a):n.push(a),d({action:r,location:a,index:t,entries:n})}}))},replace:function(e,t){var r="REPLACE",a=b(e,t,f(),O.location);l.confirmTransitionTo(a,r,n,(function(e){e&&(O.entries[O.index]=a,d({action:r,location:a}))}))},go:y,goBack:function(){y(-1)},goForward:function(){y(1)},canGo:function(e){var t=O.index+e;return t>=0&&t>>1)]);s>0?r=i+1:(a=i,o=!s)}return o?r:-r-1}(e,t,n||i)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function i(e,t){return e>t?1:e6&&void 0!==arguments[6]&&arguments[6],u=arguments.length>7&&void 0!==arguments[7]&&arguments[7],p=arguments.length>8&&void 0!==arguments[8]&&arguments[8],h=[],b=0;bo&&h.push({score:t[b],boxIndex:b,suppressBeginIndex:0});h.sort(f);for(var m=s>0?-.5/s:0,v=[],g=[];v.length0;){var y=h.pop(),O=y.score,x=y.boxIndex,k=y.suppressBeginIndex;if(O=k;--j){var S=l(e,x,v[j]);if(S>=i){w=!0;break}if(y.score=y.score*d(i,m,S),y.score<=o)break}y.suppressBeginIndex=v.length,w||(y.score===O?(v.push(x),g.push(y.score)):y.score>o&&a(h,y,f))}var N=v.length,I=n-N;u&&I>0&&(v.push.apply(v,Object(r.a)(new Array(I).fill(0))),g.push.apply(g,Object(r.a)(new Array(I).fill(0))));var C={selectedIndices:v};return c&&(C.selectedScores=g),p&&(C.validOutputs=N),C}function l(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]),c=Math.max(r[1],r[3]),u=Math.min(a[0],a[2]),l=Math.min(a[1],a[3]),d=Math.max(a[0],a[2]),f=Math.max(a[1],a[3]),p=(s-i)*(c-o),h=(d-u)*(f-l);if(p<=0||h<=0)return 0;var b=Math.max(i,u),m=Math.max(o,l),v=Math.min(s,d),g=Math.min(c,f),y=Math.max(v-b,0)*Math.max(g-m,0);return y/(p+h-y)}function d(e,t,n){var r=Math.exp(t*n*n);return n<=e?r:0}function f(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(9),a=n(15),i=n(81);function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"float32";if("complex64"===t){var n=o(e,"float32"),s=o(e,"float32");return Object(i.a)(n,s)}var c=Object(a.F)(Object(a.O)(e),t);return r.a.makeTensor(c,e,t)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({relu_:function(e){var t={x:Object(i.a)(e,"x","relu")};return r.a.runKernel(a.mc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({step_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Object(i.a)(e,"x","step"),o={x:n},s={alpha:t};return r.a.runKernel(a.Rc,o,s)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({unstack_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Object(i.a)(e,"x","unstack","string_or_numeric");o.b(t>=-n.shape.length&&t1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=Object(i.a)(e,"x","mean"),s={x:o},c={axis:t,keepDims:n};return r.a.runKernel(a.Pb,s,c)}})},function(e,t,n){"use strict";function r(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:166;function r(){for(var r=arguments.length,a=new Array(r),i=0;i=1+t.length,(function(){return"input rank is ".concat(s.rank," but should be > than blockShape.length ").concat(t.length)})),o.b(n.length===t.length,(function(){return"crops.length is ".concat(n.length," but should be equal to blockShape.length ").concat(t.length)})),o.b(s.shape[0]%c===0,(function(){return"input tensor batch is ".concat(s.shape[0]," but is not divisible by the product of ")+"the elements of blockShape ".concat(t.join(" * ")," === ").concat(c)}));var u={x:s},l={blockShape:t,crops:n};return r.a.runKernel(a.t,u,l)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8),c=n(13);var u=Object(s.b)({depthwiseConv2d_:function(e,t,n,s){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"NHWC",l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[1,1],d=arguments.length>6?arguments[6]:void 0,f=Object(i.a)(e,"x","depthwiseConv2d"),p=Object(i.a)(t,"filter","depthwiseConv2d"),h=f,b=!1;3===f.rank&&(b=!0,h=Object(c.a)(f,[1,f.shape[0],f.shape[1],f.shape[2]])),o.b(4===h.rank,(function(){return"Error in depthwiseConv2d: input must be rank 4, but got "+"rank ".concat(h.rank,".")})),o.b(4===p.rank,(function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+"".concat(p.rank,".")})),o.b(h.shape[3]===p.shape[2],(function(){return"Error in depthwiseConv2d: number of input channels "+"(".concat(h.shape[3],") must match the inChannels dimension in ")+"filter ".concat(p.shape[2],".")})),null!=d&&o.b(o.v(s),(function(){return"Error in depthwiseConv2d: pad must be an integer when using, "+"dimRoundingMode ".concat(d," but got pad ").concat(s,".")}));var m={x:h,filter:p},v={strides:n,pad:s,dataFormat:u,dilations:l,dimRoundingMode:d},g=r.a.runKernel(a.O,m,v);return b?Object(c.a)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(34),u=n(8);var l=Object(u.b)({equal_:function(e,t){var n=Object(s.a)(e,"a","equal","string_or_numeric"),u=Object(s.a)(t,"b","equal","string_or_numeric"),l=Object(o.makeTypesMatch)(n,u),d=Object(r.a)(l,2);n=d[0],u=d[1],Object(c.a)(n.shape,u.shape);var f={a:n,b:u};return a.a.runKernel(i.Y,f)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(9),a=n(3);function i(e,t,n){var i={shape:e,value:t,dtype:n};return r.a.runKernel(a.eb,{},i)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({gather_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=Object(i.a)(e,"x","gather"),c=Object(i.a)(t,"indices","gather","int32"),u={x:s,indices:c},l={axis:n,batchDims:o};return r.a.runKernel(a.nb,u,l)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({logicalNot_:function(e){var t={x:Object(i.a)(e,"x","logicalNot","bool")};return r.a.runKernel(a.Gb,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(34),u=n(24),l=n(8);var d=Object(l.b)({maximum_:function(e,t){var n=Object(s.a)(e,"a","maximum"),l=Object(s.a)(t,"b","maximum"),d=Object(o.makeTypesMatch)(n,l),f=Object(r.a)(d,2);n=f[0],l=f[1],"bool"===n.dtype&&(n=Object(u.a)(n,"int32"),l=Object(u.a)(l,"int32")),Object(c.a)(n.shape,l.shape);var p={a:n,b:l};return a.a.runKernel(i.Ob,p)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({spaceToBatchND_:function(e,t,n){var s=Object(i.a)(e,"x","spaceToBatchND");o.b(s.rank>=1+t.length,(function(){return"input rank ".concat(s.rank," should be > than [blockShape] ").concat(t.length)})),o.b(n.length===t.length,(function(){return"paddings.shape[0] ".concat(n.length," must be equal to [blockShape] ").concat(t.length)})),o.b(s.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 ".concat(s.shape.slice(1)," with paddings ").concat(n.toString()," must be divisible by blockShapes ").concat(t.toString())}));var c={x:s},u={blockShape:t,paddings:n};return r.a.runKernel(a.Hc,c,u)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(2),a=n(15),i=n(8),o=n(13);var s=Object(i.b)({squeeze_:function(e,t){var n=Object(r.a)(e,"x","squeeze");return Object(o.a)(n,Object(a.Q)(n.shape,t).newShape)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(182);function a(e,t){if(e){if("string"===typeof e)return Object(r.a)(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)?Object(r.a)(e,t):void 0}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),a=n(3),i=n(2),o=n(92),s=n(8),c=n(13);var u=Object(s.b)({broadcastTo_:function(e,t){var n=Object(i.a)(e,"broadcastTo","x"),s=n.shape;if(t.some((function(e){return!(e>0)||e%1!==0})))throw new Error("broadcastTo(): Invalid broadcast shape [".concat(t,"]."));if(t.lengthn.rank){for(var u=n.shape.slice();u.length=0;f--)if(l[f]===t[f])d[f]=1;else if(1!==n.shape[f])throw new Error("broadcastTo(): [".concat(s,"] cannot be broadcast to [").concat(t,"]."));if(0===d.map((function(e,t){return e>1?t:-1})).filter((function(e){return e>=0})).length)return Object(o.a)(n);var p={x:n},h={reps:d};return r.a.runKernel(a.ad,p,h)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s})),n.d(t,"c",(function(){return c}));var r=n(7),a=n(11),i=n(109),o=(n(166),function(){function e(t,n,a,o,s){Object(r.a)(this,e),this.mean=t,this.stdDev=n,this.dtype=a,this.nextVal=NaN,this.truncated=o,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);var c=s||Math.random();this.random=i.alea(c.toString())}return Object(a.a)(e,[{key:"nextValue",value: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)}},{key:"convertValue",value:function(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}},{key:"isValidTruncated",value:function(e){return e<=this.upper&&e>=this.lower}}]),e}()),s=function(){function e(t,n,a,s){Object(r.a)(this,e),this.alpha=t,this.beta=1/n,this.dtype=a;var c=s||Math.random();this.randu=i.alea(c.toString()),this.randn=new o(0,1,a,!1,this.randu()),this.d=t<1?t+2/3:t-1/3,this.c=1/Math.sqrt(9*this.d)}return Object(a.a)(e,[{key:"nextValue",value: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())0&&void 0!==arguments[0]?arguments[0]:0,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;if(Object(r.a)(this,e),this.canReturnFloat=function(){return null==t.dtype||"float32"===t.dtype},this.min=n,this.range=a-n,this.dtype=o,null==s&&(s=Math.random()),"number"===typeof s&&(s=s.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error("The difference between ".concat(n," - ").concat(a," <= 1 and dtype is not float"));this.random=i.alea(s)}return Object(a.a)(e,[{key:"convertValue",value:function(e){return this.canReturnFloat()?e:Math.round(e)}},{key:"nextValue",value:function(){return this.convertValue(this.min+this.range*this.random())}}]),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(9),a=n(3);function i(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"float32";if(0===n)throw new Error("Cannot have a step of zero");var o={start:e,stop:t,step:n,dtype:i};return r.a.runKernel(a.ic,{},o)}},function(e,t,n){"use strict";var r=n(353);t.a=function(e,t){return t?Object(r.a)(e,t,{clone:!1}):e}},function(e,t,n){"use strict";var r=n(57),a=n(23),i=n(353),o=n(14),s=["xs","sm","md","lg","xl"];function c(e){var t=e.values,n=void 0===t?{xs:0,sm:600,md:960,lg:1280,xl:1920}:t,r=e.unit,i=void 0===r?"px":r,c=e.step,u=void 0===c?5:c,l=Object(a.a)(e,["values","unit","step"]);function d(e){var t="number"===typeof n[e]?n[e]:e;return"@media (min-width:".concat(t).concat(i,")")}function f(e,t){var r=s.indexOf(t);return r===s.length-1?d(e):"@media (min-width:".concat("number"===typeof n[e]?n[e]:e).concat(i,") and ")+"(max-width:".concat((-1!==r&&"number"===typeof n[s[r+1]]?n[s[r+1]]:t)-u/100).concat(i,")")}return Object(o.a)({keys:s,values:n,up:d,down:function(e){var t=s.indexOf(e)+1,r=n[s[t]];return t===s.length?d("xs"):"@media (max-width:".concat(("number"===typeof r&&t>0?r:e)-u/100).concat(i,")")},between:f,only:function(e){return f(e,e)},width:function(e){return n[e]}},l)}function u(e,t,n){var a;return Object(o.a)({gutters:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object(o.a)({paddingLeft:t(2),paddingRight:t(2)},n,Object(r.a)({},e.up("sm"),Object(o.a)({paddingLeft:t(3),paddingRight:t(3)},n[e.up("sm")])))},toolbar:(a={minHeight:56},Object(r.a)(a,"".concat(e.up("xs")," and (orientation: landscape)"),{minHeight:48}),Object(r.a)(a,e.up("sm"),{minHeight:64}),a)},n)}var l=n(312),d={black:"#000",white:"#fff"},f={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#d5d5d5",A200:"#aaaaaa",A400:"#303030",A700:"#616161"},p={50:"#e8eaf6",100:"#c5cae9",200:"#9fa8da",300:"#7986cb",400:"#5c6bc0",500:"#3f51b5",600:"#3949ab",700:"#303f9f",800:"#283593",900:"#1a237e",A100:"#8c9eff",A200:"#536dfe",A400:"#3d5afe",A700:"#304ffe"},h={50:"#fce4ec",100:"#f8bbd0",200:"#f48fb1",300:"#f06292",400:"#ec407a",500:"#e91e63",600:"#d81b60",700:"#c2185b",800:"#ad1457",900:"#880e4f",A100:"#ff80ab",A200:"#ff4081",A400:"#f50057",A700:"#c51162"},b={50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c",A100:"#ff8a80",A200:"#ff5252",A400:"#ff1744",A700:"#d50000"},m={50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100",A100:"#ffd180",A200:"#ffab40",A400:"#ff9100",A700:"#ff6d00"},v={50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1",A100:"#82b1ff",A200:"#448aff",A400:"#2979ff",A700:"#2962ff"},g={50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20",A100:"#b9f6ca",A200:"#69f0ae",A400:"#00e676",A700:"#00c853"},y=n(47),O={text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.54)",disabled:"rgba(0, 0, 0, 0.38)",hint:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:d.white,default:f[50]},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}},x={text:{primary:d.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",hint:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:f[800],default:"#303030"},action:{active:d.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}};function k(e,t,n,r){var a=r.light||r,i=r.dark||1.5*r;e[t]||(e.hasOwnProperty(n)?e[t]=e[n]:"light"===t?e.light=Object(y.e)(e.main,a):"dark"===t&&(e.dark=Object(y.a)(e.main,i)))}function w(e){var t=e.primary,n=void 0===t?{light:p[300],main:p[500],dark:p[700]}:t,r=e.secondary,s=void 0===r?{light:h.A200,main:h.A400,dark:h.A700}:r,c=e.error,u=void 0===c?{light:b[300],main:b[500],dark:b[700]}:c,w=e.warning,j=void 0===w?{light:m[300],main:m[500],dark:m[700]}:w,S=e.info,N=void 0===S?{light:v[300],main:v[500],dark:v[700]}:S,I=e.success,C=void 0===I?{light:g[300],main:g[500],dark:g[700]}:I,T=e.type,E=void 0===T?"light":T,A=e.contrastThreshold,R=void 0===A?3:A,F=e.tonalOffset,D=void 0===F?.2:F,_=Object(a.a)(e,["primary","secondary","error","warning","info","success","type","contrastThreshold","tonalOffset"]);function M(e){return Object(y.d)(e,x.text.primary)>=R?x.text.primary:O.text.primary}var z=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:300,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:700;if(!(e=Object(o.a)({},e)).main&&e[t]&&(e.main=e[t]),!e.main)throw new Error(Object(l.a)(4,t));if("string"!==typeof e.main)throw new Error(Object(l.a)(5,JSON.stringify(e.main)));return k(e,"light",n,D),k(e,"dark",r,D),e.contrastText||(e.contrastText=M(e.main)),e},L={dark:x,light:O};return Object(i.a)(Object(o.a)({common:d,type:E,primary:z(n),secondary:z(s,"A400","A200","A700"),error:z(u),warning:z(j),info:z(N),success:z(C),grey:f,contrastThreshold:R,getContrastText:M,augmentColor:z,tonalOffset:D},L[E]),_)}function j(e){return Math.round(1e5*e)/1e5}var S={textTransform:"uppercase"},N='"Roboto", "Helvetica", "Arial", sans-serif';function I(e,t){var n="function"===typeof t?t(e):t,r=n.fontFamily,s=void 0===r?N:r,c=n.fontSize,u=void 0===c?14:c,l=n.fontWeightLight,d=void 0===l?300:l,f=n.fontWeightRegular,p=void 0===f?400:f,h=n.fontWeightMedium,b=void 0===h?500:h,m=n.fontWeightBold,v=void 0===m?700:m,g=n.htmlFontSize,y=void 0===g?16:g,O=n.allVariants,x=n.pxToRem,k=Object(a.a)(n,["fontFamily","fontSize","fontWeightLight","fontWeightRegular","fontWeightMedium","fontWeightBold","htmlFontSize","allVariants","pxToRem"]);var w=u/14,I=x||function(e){return"".concat(e/y*w,"rem")},C=function(e,t,n,r,a){return Object(o.a)({fontFamily:s,fontWeight:e,fontSize:I(t),lineHeight:n},s===N?{letterSpacing:"".concat(j(r/t),"em")}:{},a,O)},T={h1:C(d,96,1.167,-1.5),h2:C(d,60,1.2,-.5),h3:C(p,48,1.167,0),h4:C(p,34,1.235,.25),h5:C(p,24,1.334,0),h6:C(b,20,1.6,.15),subtitle1:C(p,16,1.75,.15),subtitle2:C(b,14,1.57,.1),body1:C(p,16,1.5,.15),body2:C(p,14,1.43,.15),button:C(b,14,1.75,.4,S),caption:C(p,12,1.66,.4),overline:C(p,12,2.66,1,S)};return Object(i.a)(Object(o.a)({htmlFontSize:y,pxToRem:I,round:j,fontFamily:s,fontSize:u,fontWeightLight:d,fontWeightRegular:p,fontWeightMedium:b,fontWeightBold:v},T),k,{clone:!1})}function C(){return["".concat(arguments.length<=0?void 0:arguments[0],"px ").concat(arguments.length<=1?void 0:arguments[1],"px ").concat(arguments.length<=2?void 0:arguments[2],"px ").concat(arguments.length<=3?void 0:arguments[3],"px rgba(0,0,0,").concat(.2,")"),"".concat(arguments.length<=4?void 0:arguments[4],"px ").concat(arguments.length<=5?void 0:arguments[5],"px ").concat(arguments.length<=6?void 0:arguments[6],"px ").concat(arguments.length<=7?void 0:arguments[7],"px rgba(0,0,0,").concat(.14,")"),"".concat(arguments.length<=8?void 0:arguments[8],"px ").concat(arguments.length<=9?void 0:arguments[9],"px ").concat(arguments.length<=10?void 0:arguments[10],"px ").concat(arguments.length<=11?void 0:arguments[11],"px rgba(0,0,0,").concat(.12,")")].join(",")}var T=["none",C(0,2,1,-1,0,1,1,0,0,1,3,0),C(0,3,1,-2,0,2,2,0,0,1,5,0),C(0,3,3,-2,0,3,4,0,0,1,8,0),C(0,2,4,-1,0,4,5,0,0,1,10,0),C(0,3,5,-1,0,5,8,0,0,1,14,0),C(0,3,5,-1,0,6,10,0,0,1,18,0),C(0,4,5,-2,0,7,10,1,0,2,16,1),C(0,5,5,-3,0,8,10,1,0,3,14,2),C(0,5,6,-3,0,9,12,1,0,3,16,2),C(0,6,6,-3,0,10,14,1,0,4,18,3),C(0,6,7,-4,0,11,15,1,0,4,20,3),C(0,7,8,-4,0,12,17,2,0,5,22,4),C(0,7,8,-4,0,13,19,2,0,5,24,4),C(0,7,9,-4,0,14,21,2,0,5,26,4),C(0,8,9,-5,0,15,22,2,0,6,28,5),C(0,8,10,-5,0,16,24,2,0,6,30,5),C(0,8,11,-5,0,17,26,2,0,6,32,5),C(0,9,11,-5,0,18,28,2,0,7,34,6),C(0,9,12,-6,0,19,29,2,0,7,36,6),C(0,10,13,-6,0,20,31,3,0,8,38,7),C(0,10,13,-6,0,21,33,3,0,8,40,7),C(0,10,14,-6,0,22,35,3,0,8,42,7),C(0,11,14,-7,0,23,36,3,0,9,44,8),C(0,11,15,-7,0,24,38,3,0,9,46,8)],E={borderRadius:4},A=n(400);function R(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;if(e.mui)return e;var t=Object(A.a)({spacing:e}),n=function(){for(var e=arguments.length,n=new Array(e),r=0;r0&&void 0!==arguments[0]?arguments[0]:["all"],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.duration,r=void 0===n?D.standard:n,i=t.easing,o=void 0===i?F.easeInOut:i,s=t.delay,c=void 0===s?0:s;Object(a.a)(t,["duration","easing","delay"]);return(Array.isArray(e)?e:[e]).map((function(e){return"".concat(e," ").concat("string"===typeof r?r:_(r)," ").concat(o," ").concat("string"===typeof c?c:_(c))})).join(",")},getAutoHeightDuration:function(e){if(!e)return 0;var t=e/36;return Math.round(10*(4+15*Math.pow(t,.25)+t/5))}},z=n(238);var L=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.breakpoints,n=void 0===t?{}:t,r=e.mixins,o=void 0===r?{}:r,s=e.palette,l=void 0===s?{}:s,d=e.spacing,f=e.typography,p=void 0===f?{}:f,h=Object(a.a)(e,["breakpoints","mixins","palette","spacing","typography"]),b=w(l),m=c(n),v=R(d),g=Object(i.a)({breakpoints:m,direction:"ltr",mixins:u(m,v,o),overrides:{},palette:b,props:{},shadows:T,typography:I(b,p),spacing:v,shape:E,transitions:M,zIndex:z.a},h),y=arguments.length,O=new Array(y>1?y-1:0),x=1;x1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=Object(i.a)(e,"x","min"),s={x:o},c={axis:t,keepDims:n};return r.a.runKernel(a.Qb,s,c)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({real_:function(e){var t={input:Object(i.a)(e,"input","real")};return r.a.runKernel(a.jc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(15),o=n(8);var s=Object(o.b)({ifft_:function(e){Object(i.b)("complex64"===e.dtype,(function(){return"The dtype for tf.spectral.ifft() must be complex64 "+"but got ".concat(e.dtype,".")}));var t={input:e};return r.a.runKernel(a.qb,t)}})},function(e,t,n){"use strict";function r(e){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";(function(e,r){var a;function i(){if(null==a){var t;if("undefined"!==typeof window)t=window;else if("undefined"!==typeof e)t=e;else if("undefined"!==typeof r)t=r;else{if("undefined"===typeof self)throw new Error("Could not find a global object");t=self}a=t}return a}function o(e,t){var n=function(){var e=i();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);var r=t();return n.set(e,r),n.get(e)}n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return o}))}).call(this,n(137),n(187))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(r){"object"===typeof window&&(n=window)}e.exports=n},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,n){"use strict";e.exports=n(350)},function(e,t,n){"use strict";n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return s}));var r=n(21),a=n(15);function i(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: ".concat(n.shape)+", indices.shape: ".concat(t.shape,", shape: ").concat(e)+", sliceDim: ".concat(r,", and batchDim: ").concat(a,".");if(n.rank1?t.shape[i-1]:1,s=n.length,c=1,u=o;u0;)1&e&&t.push(n),e/=2,n++;return t}function s(e,t,n){for(var r=[],a=0;a0){var y=t[0],O=n+1;d=f(o,y,O,r,e),v=p(s,y,O,a,e),g=c(i,y,O,e)}else for(var x=0;x-1)o[c]=0;else{var d=u(t,n,c),f=a[d];e&1<-1)s[d]=Number.MAX_SAFE_INTEGER;else{var f=u(t,n,d),p=i[f];e&1<0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);var u=r[i];return s<0&&(s+=u),s=a.i(0,s,u-1)}function m(e,t,n,r,i,o){var s=t[i],c=n[i]||1;(e&1<0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);var u=r[i];return s<0&&(s+=u),s=c>0?a.i(0,s,u):a.i(-1,s,u-1)}function v(e,t,n){for(var r=n.length,a=0;a1){r=a;break}for(var i=r+1;i0||n[i]!==e[i])return!1;return!0}function g(e,t){for(var n=e.length>0?e[e.length-1]:1,r=0;r=0?t:(a.b(-1===t,(function(){return"Negative size values should be exactly -1 but got "+"".concat(t," for the slice() size at index ").concat(n,".")})),e.shape[n]-i[n])})),[i,o]}function O(e,t,n,r,a,i,c,u,l){var f=t.slice(),p=n.slice(),h=r;null==r&&(h=new Array(f.length));var b=o(c);if(b.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(0!==c&&0!==u)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(0!==c&&0!==l)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");var m=e.length-f.length,v=o(u),g=e.slice();v.forEach((function(e){f[e]=0,p[e]=1,g.splice(e,0,1)}));var y=d(g,b,m,f,p,h,a,i,c),O=y.begin,x=y.end,k=y.strides;f=O,p=x,h=k;var w=o(l);w.forEach((function(e){p[e]=f[e]+1,h[e]=1}));var j=s(f,p,h),S=j.filter((function(e,t){return-1===w.indexOf(t)}));return{nonStrided:h.every((function(e){return 1===e})),$begin:f,$end:p,$strides:h,size:j,newShape:g,outShape:S}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(24),c=n(48),u=n(8),l=n(13);var d=Object(u.b)({avgPool_:function(e,t,n,u,d){var f=Object(i.a)(e,"x","avgPool","float32");o.b(c.h(n,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. "+"Got strides ".concat(n," and dilations '").concat(1,"'")}));var p=f,h=!1;3===f.rank&&(h=!0,p=Object(l.a)(f,[1,f.shape[0],f.shape[1],f.shape[2]])),o.b(4===p.rank,(function(){return"Error in avgPool: x must be rank 4 but got rank ".concat(p.rank,".")})),null!=d&&o.b(o.v(u),(function(){return"Error in avgPool: pad must be an integer when using, "+"dimRoundingMode ".concat(d," but got pad ").concat(u,".")}));var b={x:p},m={filterSize:t,strides:n,pad:u,dimRoundingMode:d},v=r.a.runKernel(a.o,b,m);return v=Object(s.a)(v,f.dtype),h?Object(l.a)(v,[v.shape[1],v.shape[2],v.shape[3]]):v}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({cos_:function(e){var t={x:Object(i.a)(e,"x","cos")};return r.a.runKernel(a.I,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({cumsum_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=Object(i.a)(e,"x","cumsum"),c={x:s},u={axis:t,exclusive:n,reverse:o};return r.a.runKernel(a.L,c,u)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(8);var u=Object(c.b)({floorDiv_:function(e,t){var n=Object(s.a)(e,"a","floorDiv"),c=Object(s.a)(t,"b","floorDiv"),u=Object(o.makeTypesMatch)(n,c),l=Object(r.a)(u,2),d={a:n=l[0],b:c=l[1]};return a.a.runKernel(i.hb,d)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({elu_:function(e){var t={x:Object(i.a)(e,"x","elu")};return r.a.runKernel(a.W,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({floor_:function(e){var t={x:Object(i.a)(e,"x","floor")};return r.a.runKernel(a.gb,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({imag_:function(e){var t={input:Object(i.a)(e,"input","imag")};return r.a.runKernel(a.sb,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({leakyRelu_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.2,n=Object(i.a)(e,"x","leakyRelu"),o={x:n},s={alpha:t};return r.a.runKernel(a.yb,o,s)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(34),u=n(8);var l=Object(u.b)({less_:function(e,t){var n=Object(s.a)(e,"a","less","string_or_numeric"),u=Object(s.a)(t,"b","less","string_or_numeric"),l=Object(o.makeTypesMatch)(n,u),d=Object(r.a)(l,2);n=d[0],u=d[1],Object(c.a)(n.shape,u.shape);var f={a:n,b:u};return a.a.runKernel(i.zb,f)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var r=n(2),a=n(15),i=n(27),o=n(60),s=n(61),c=n(97),u=n(94),l=n(8),d=n(13),f=n(29),p=n(32);var h=Object(l.b)({logSumExp_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=Object(r.a)(e,"x","logSumExp"),h=Object(a.I)(t,l.shape),b=Object(u.a)(l,h,!0),m=Object(f.a)(l,b),v=Object(s.a)(m),g=Object(p.a)(v,h),y=Object(c.a)(g),O=Object(i.a)(Object(d.a)(b,y.shape),y);if(n){var x=Object(o.e)(O.shape,h);return Object(d.a)(O,x)}return O}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(34),s=n(8);var c=Object(s.b)({logicalOr_:function(e,t){var n=Object(i.a)(e,"a","logicalOr","bool"),s=Object(i.a)(t,"b","logicalOr","bool");Object(o.a)(n.shape,s.shape);var c={a:n,b:s};return r.a.runKernel(a.Hb,c)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(48),c=n(8),u=n(13);var l=Object(c.b)({maxPool_:function(e,t,n,c,l){var d=Object(i.a)(e,"x","maxPool"),f=d,p=!1;3===d.rank&&(p=!0,f=Object(u.a)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),o.b(4===f.rank,(function(){return"Error in maxPool: input must be rank 4 but got rank ".concat(f.rank,".")})),o.b(s.h(n,1),(function(){return"Error in maxPool: Either strides or dilations must be 1. "+"Got strides ".concat(n," and dilations '").concat(1,"'")})),null!=l&&o.b(o.v(c),(function(){return"Error in maxPool: pad must be an integer when using, "+"dimRoundingMode ".concat(l," but got pad ").concat(c,".")}));var h={x:f},b={filterSize:t,strides:n,pad:c,dimRoundingMode:l},m=r.a.runKernel(a.Jb,h,b);return p?Object(u.a)(m,[m.shape[1],m.shape[2],m.shape[3]]):m}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(34),u=n(24),l=n(8);var d=Object(l.b)({minimum_:function(e,t){var n=Object(s.a)(e,"a","minimum"),l=Object(s.a)(t,"b","minimum"),d=Object(o.makeTypesMatch)(n,l),f=Object(r.a)(d,2);n=f[0],l=f[1],"bool"===n.dtype&&(n=Object(u.a)(n,"int32"),l=Object(u.a)(l,"int32")),Object(c.a)(n.shape,l.shape);var p={a:n,b:l};return a.a.runKernel(i.Rb,p)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(34),u=n(8);var l=Object(u.b)({notEqual_:function(e,t){var n=Object(s.a)(e,"a","notEqual","string_or_numeric"),u=Object(s.a)(t,"b","notEqual","string_or_numeric"),l=Object(o.makeTypesMatch)(n,u),d=Object(r.a)(l,2);n=d[0],u=d[1],Object(c.a)(n.shape,u.shape);var f={a:n,b:u};return a.a.runKernel(i.ac,f)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({prelu_:function(e,t){var n={x:Object(i.a)(e,"x","prelu"),alpha:Object(i.a)(t,"alpha","prelu")};return r.a.runKernel(a.gc,n)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({relu6_:function(e){var t={x:Object(i.a)(e,"x","relu6")};return r.a.runKernel(a.nc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(15),o=n(8);var s=Object(o.b)({fft_:function(e){Object(i.b)("complex64"===e.dtype,(function(){return"The dtype for tf.spectral.fft() must be complex64 "+"but got ".concat(e.dtype,".")}));var t={input:e};return r.a.runKernel(a.db,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var r=n(15),a=n(81),i=n(49),o=n(149),s=n(8),c=n(133),u=n(13),l=n(43),d=n(83),f=n(100),p=n(36),h=n(159);var b=Object(s.b)({rfft_:function(e,t){Object(r.b)("float32"===e.dtype,(function(){return"The dtype for rfft() must be real value but got ".concat(e.dtype)}));var n,s=e.shape[e.shape.length-1],b=e.size/s;if(null!=t&&ts){var g=e.shape.map((function(e){return e}));g[e.shape.length-1]=t-s,n=Object(i.a)([e,Object(f.a)(g)],e.shape.length-1),s=t}else n=e;var y=Object(p.a)(n),O=Object(u.a)(Object(a.a)(n,y),[b,s]),x=Object(h.a)(O),k=Math.floor(s/2)+1,w=Object(c.a)(x),j=Object(o.a)(x),S=Object(d.a)(w,[k,s-k],w.shape.length-1),N=Object(d.a)(j,[k,s-k],j.shape.length-1),I=n.shape.slice();return I[n.shape.length-1]=k,Object(u.a)(Object(a.a)(S[0],N[0]),I)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(34),u=n(8);var l=Object(u.b)({squaredDifference_:function(e,t){var n=Object(s.a)(e,"a","squaredDifference"),u=Object(s.a)(t,"b","squaredDifference"),l=Object(o.makeTypesMatch)(n,u),d=Object(r.a)(l,2);n=d[0],u=d[1],Object(c.a)(n.shape,u.shape);var f={a:n,b:u};return a.a.runKernel(i.Qc,f,{})}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({unsortedSegmentSum_:function(e,t,n){var s=Object(i.a)(e,"x","unsortedSegmentSum"),c=Object(i.a)(t,"segmentIds","unsortedSegmentSum","int32");Object(o.b)(Object(o.v)(n),(function(){return"numSegments must be of dtype int"}));var u={x:s,segmentIds:c},l={numSegments:n};return r.a.runKernel(a.gd,u,l)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return v}));var r=n(2),a=n(15),i=n(65),o=n(60),s=n(94),c=n(132),u=n(8),l=n(73),d=n(13),f=n(33),p=n(58),h=n(40),b=n(32);function m(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(0===e.rank)return Object(i.a)(e);if(1!==e.rank&&null===n)return m(Object(d.a)(e,[-1]),t,n);if(1===e.rank||"number"===typeof n||Array.isArray(n)&&1===n.length){if(1===t)return Object(b.a)(Object(i.a)(e),n);if(t===1/0)return Object(s.a)(Object(i.a)(e),n);if(t===-1/0)return Object(c.a)(Object(i.a)(e),n);if("euclidean"===t||2===t)return Object(p.a)(Object(b.a)(Object(l.a)(Object(i.a)(e),Object(f.a)(2,"int32")),n));throw new Error("Error in norm: invalid ord value: ".concat(t))}if(Array.isArray(n)&&2===n.length){if(1===t)return Object(s.a)(Object(b.a)(Object(i.a)(e),n[0]),n[1]-1);if(t===1/0)return Object(s.a)(Object(b.a)(Object(i.a)(e),n[1]),n[0]);if(t===-1/0)return Object(c.a)(Object(b.a)(Object(i.a)(e),n[1]),n[0]);if("fro"===t||"euclidean"===t)return Object(p.a)(Object(b.a)(Object(h.a)(e),n));throw new Error("Error in norm: invalid ord value: ".concat(t))}throw new Error("Error in norm: invalid axis: ".concat(n))}var v=Object(u.b)({norm_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"euclidean",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=m(e=Object(r.a)(e,"x","norm"),t,n),c=s.shape;if(i){var u=Object(a.I)(n,e.shape);c=o.e(s.shape,u)}return Object(d.a)(s,c)}})},function(e,t,n){"use strict";function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(15),o=n(8),s=n(13);var c=Object(o.b)({conv2DBackpropInput_:function(e,t,n,o,c){var u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"NHWC",l=arguments.length>6?arguments[6]:void 0;i.b(e.length===t.rank,(function(){return"Length of inShape "+"(".concat(e.length,") and rank of dy (").concat(t.rank,") must match")}));var d=e,f=t,p=!1;3===t.rank&&(p=!0,f=Object(s.a)(t,[1,t.shape[0],t.shape[1],t.shape[2]]),d=[1,e[0],e[1],e[2]]),i.b(4===d.length,(function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+"".concat(d.length,".")})),i.b(4===f.rank,(function(){return"Error in conv2dDerInput: dy must be rank 4, but got "+"rank ".concat(f.rank)})),i.b(4===n.rank,(function(){return"Error in conv2dDerInput: filter must be rank 4, but got "+"rank ".concat(n.rank)}));var h="NHWC"===u?d[3]:d[1],b="NHWC"===u?f.shape[3]:f.shape[1];i.b(h===n.shape[2],(function(){return"Error in conv2dDerInput: depth of input (".concat(h,") must ")+"match input depth for filter ".concat(n.shape[2],".")})),i.b(b===n.shape[3],(function(){return"Error in conv2dDerInput: depth of output (".concat(b,") must ")+"match output depth for filter ".concat(n.shape[3],".")})),null!=l&&i.b(i.v(c),(function(){return"Error in conv2dDerInput: pad must be an integer when using, "+"dimRoundingMode ".concat(l," but got pad ").concat(c,".")}));var m={dy:f,filter:n},v={strides:o,pad:c,dataFormat:u,dimRoundingMode:l,inputShape:d},g=r.a.runKernel(a.E,m,v);return p?Object(s.a)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}})},function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return i}));var r=n(9);n(2),n(15),n(19);function a(){return 32===r.a.backend.floatPrecision()?.001:.1}function i(e,t,n){if(null==n&&(n=a()),!o(e,t,n))throw new Error("Numbers differ: actual === ".concat(e,", expected === ").concat(t))}function o(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(15),o=n(8),s=n(13);var c=Object(o.b)({conv2DBackpropFilter_:function(e,t,n,o,c){var u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"NHWC",l=arguments.length>6?arguments[6]:void 0,d=e;3===e.rank&&(d=Object(s.a)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var f=t;3===f.rank&&(f=Object(s.a)(t,[1,t.shape[0],t.shape[1],t.shape[2]])),i.b(4===d.rank,(function(){return"Error in conv2dDerFilter: input must be rank 4, but got shape "+"".concat(d.shape,".")})),i.b(4===f.rank,(function(){return"Error in conv2dDerFilter: dy must be rank 4, but got shape "+"".concat(f.shape,".")})),i.b(4===n.length,(function(){return"Error in conv2dDerFilter: filterShape must be length 4, but got "+"".concat(n,".")}));var p="NHWC"===u?d.shape[3]:d.shape[1],h="NHWC"===u?f.shape[3]:f.shape[1];i.b(p===n[2],(function(){return"Error in conv2dDerFilter: depth of input ".concat(p,") must ")+"match input depth in filter (".concat(n[2],".")})),i.b(h===n[3],(function(){return"Error in conv2dDerFilter: depth of dy (".concat(h,") must ")+"match output depth for filter (".concat(n[3],").")})),null!=l&&i.b(i.v(c),(function(){return"Error in conv2dDerFilter: pad must be an integer when using, "+"dimRoundingMode ".concat(l," but got pad ").concat(c,".")}));var b={x:d,dy:f},m={strides:o,pad:c,dataFormat:u,dimRoundingMode:l,filterShape:n};return r.a.runKernel(a.D,b,m)}})},function(e,t,n){"use strict";var r=n(140),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},i={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},o={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function c(e){return r.isMemo(e)?o:s[e.$$typeof]||a}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=o;var u=Object.defineProperty,l=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,f=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,h=Object.prototype;e.exports=function e(t,n,r){if("string"!==typeof n){if(h){var a=p(n);a&&a!==h&&e(t,a,r)}var o=l(n);d&&(o=o.concat(d(n)));for(var s=c(t),b=c(n),m=0;me.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n1)for(var n=1;n1&&void 0!==arguments[1]&&arguments[1];console.log(e.toString(t))}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({all_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=Object(i.a)(e,"x","all","bool"),s={x:o},c={axis:t,keepDims:n};return r.a.runKernel(a.f,s,c)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({any_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=Object(i.a)(e,"x","any","bool"),s={x:o},c={axis:t,keepDims:n};return r.a.runKernel(a.g,s,c)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({argMax_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Object(i.a)(e,"x","argMax"),o={x:n},s={axis:t};return r.a.runKernel(a.h,o,s)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({argMin_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Object(i.a)(e,"x","argMin"),o={x:n},s={axis:t};return r.a.runKernel(a.i,o,s)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(6),a=n(9),i=n(3),o=n(39),s=n(2),c=n(8);var u=Object(c.b)({atan2_:function(e,t){var n=Object(s.a)(e,"a","atan2"),c=Object(s.a)(t,"b","atan2"),u=Object(o.makeTypesMatch)(n,c),l=Object(r.a)(u,2),d={a:n=l[0],b:c=l[1]};return a.a.runKernel(i.m,d)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({bincount_:function(e,t,n){var s=Object(i.a)(e,"x","bincount"),c=Object(i.a)(t,"weights","bincount");o.b("int32"===s.dtype,(function(){return"Error in bincount: input "+"dtype must be int32, but got ".concat(s.dtype)})),o.b(n>=0,(function(){return"size must be non-negative, but got ".concat(n,".")})),o.b(c.size===s.size||0===c.size,(function(){return"Error in bincount: weights must have the same size as input or"+"0-length, but got input shape: ".concat(s.shape,", weights shape: ")+"".concat(c.shape,".")}));var u={x:s,weights:c},l={size:n};return r.a.runKernel(a.u,u,l)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(2),a=n(15),i=n(90),o=n(48),s=n(8),c=n(13);var u=Object(s.b)({conv1d_:function(e,t,n,s){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"NWC",l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,d=arguments.length>6?arguments[6]:void 0,f=Object(r.a)(e,"x","conv1d"),p=Object(r.a)(t,"filter","conv1d"),h=f,b=!1;2===f.rank&&(b=!0,h=Object(c.a)(f,[1,f.shape[0],f.shape[1]])),a.b(3===h.rank,(function(){return"Error in conv1d: input must be rank 3, but got rank ".concat(h.rank,".")})),a.b(3===p.rank,(function(){return"Error in conv1d: filter must be rank 3, but got rank "+"".concat(p.rank,".")})),null!=d&&a.b(a.v(s),(function(){return"Error in conv1d: pad must be an integer when using, "+"dimRoundingMode ".concat(d," but got pad ").concat(s,".")})),a.b(h.shape[2]===p.shape[1],(function(){return"Error in conv1d: depth of input (".concat(h.shape[2],") must match ")+"input depth for filter ".concat(p.shape[1],".")})),a.b(o.h(n,l),(function(){return"Error in conv1D: Either stride or dilation must be 1. "+"Got stride ".concat(n," and dilation '").concat(l,"'")})),a.b("NWC"===u,(function(){return"Error in conv1d: got dataFormat of ".concat(u," but only NWC is currently supported.")}));var m=Object(c.a)(p,[1,p.shape[0],p.shape[1],p.shape[2]]),v=Object(c.a)(h,[h.shape[0],1,h.shape[1],h.shape[2]]),g=[1,n],y=[1,l],O="NHWC",x=Object(i.a)(v,m,g,s,O,y,d);return b?Object(c.a)(x,[x.shape[2],x.shape[3]]):Object(c.a)(x,[x.shape[0],x.shape[2],x.shape[3]])}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),a=n(165),i=n(8);var o=Object(i.b)({conv2dTranspose_:function(e,t,n,i,o,s){var c=Object(r.a)(e,"x","conv2dTranspose"),u=Object(r.a)(t,"filter","conv2dTranspose");return Object(a.a)(n,c,u,i,o,"NHWC",s)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({cosh_:function(e){var t={x:Object(i.a)(e,"x","cosh")};return r.a.runKernel(a.J,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({depthToSpace_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"NHWC",s=Object(i.a)(e,"x","depthToSpace"),c="NHWC"===n?s.shape[1]:s.shape[2],u="NHWC"===n?s.shape[2]:s.shape[3],l="NHWC"===n?s.shape[3]:s.shape[1];o.b(c*t>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n ".concat(c," and ").concat(t," for depthToSpace with input shape\n ").concat(s.shape)})),o.b(u*t>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n ".concat(u," and ").concat(t," for depthToSpace with input shape\n ").concat(s.shape)})),o.b(l%(t*t)===0,(function(){return"Dimension size must be evenly divisible by ".concat(t*t," but is ").concat(l," for depthToSpace with input shape ").concat(s.shape)}));var d={x:s},f={blockSize:t,dataFormat:n};return r.a.runKernel(a.N,d,f)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8),c=n(13);var u=Object(s.b)({dilation2d_:function(e,t,n,s){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[1,1],l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"NHWC",d=Object(i.a)(e,"x","dilation2d"),f=Object(i.a)(t,"filter","dilation2d");o.b(3===d.rank||4===d.rank,(function(){return"Error in dilation2d: input must be rank 3 or 4, but got rank "+"".concat(d.rank,".")})),o.b(3===f.rank,(function(){return"Error in dilation2d: filter must be rank 3, but got rank "+"".concat(f.rank,".")})),o.b("NHWC"===l,(function(){return"Error in dilation2d: Only NHWC is currently supported, "+"but got dataFormat of ".concat(l)}));var p=d,h=!1;3===d.rank&&(p=Object(c.a)(d,[1,d.shape[0],d.shape[1],d.shape[2]]),h=!0);var b={x:p,filter:f},m={strides:n,pad:s,dilations:u},v=r.a.runKernel(a.S,b,m);return h?Object(c.a)(v,[v.shape[1],v.shape[2],v.shape[3]]):v}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(6),a=n(39),i=n(2),o=n(31),s=n(117),c=n(8),u=n(51),l=n(36);var d=Object(c.b)({divNoNan_:function(e,t){var n=Object(i.a)(e,"a","div"),c=Object(i.a)(t,"b","div"),d=Object(a.makeTypesMatch)(n,c),f=Object(r.a)(d,2);n=f[0],c=f[1];var p=Object(o.a)(n,c),h=Object(l.a)(p),b=Object(s.a)(c,h);return Object(u.a)(b,h,p)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(2),a=n(15),i=n(41),o=n(8),s=n(13);var c=Object(o.b)({dot_:function(e,t){var n=Object(r.a)(e,"t1","dot"),o=Object(r.a)(t,"t2","dot");a.b((1===n.rank||2===n.rank)&&(1===o.rank||2===o.rank),(function(){return"Error in dot: inputs must all be rank 1 or 2, but got ranks "+"".concat(n.rank," and ").concat(o.rank,".")}));var c=1===n.rank?n.size:n.shape[1],u=1===o.rank?o.size:o.shape[0];if(a.b(c===u,(function(){return"Error in dot: inner dimensions of inputs must match, but got "+"".concat(c," and ").concat(u,".")})),1===n.rank&&1===o.rank){var l=Object(s.a)(n,[1,-1]),d=Object(s.a)(o,[-1,1]),f=Object(i.a)(l,d);return Object(s.a)(f,[])}if(1===n.rank&&2===o.rank){var p=Object(s.a)(n,[1,-1]),h=Object(s.a)(o,[o.shape[0],o.shape[1]]),b=Object(i.a)(p,h);return Object(s.a)(b,[b.size])}if(2===n.rank&&1===o.rank){var m=Object(s.a)(o,[-1,1]),v=Object(i.a)(n,m);return Object(s.a)(v,[v.size])}var g=Object(s.a)(o,[o.shape[0],o.shape[1]]);return Object(i.a)(n,g)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8),c=n(13);var u=Object(s.b)({localResponseNormalization_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.5,l=Object(i.a)(e,"x","localResponseNormalization");o.b(4===l.rank||3===l.rank,(function(){return"Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ".concat(l.rank,".")})),o.b(o.v(t),(function(){return"Error in localResponseNormalization: depthRadius must be an "+"integer but got depthRadius ".concat(t,".")}));var d=l,f=!1;3===l.rank&&(f=!0,d=Object(c.a)(l,[1,l.shape[0],l.shape[1],l.shape[2]]));var p={x:d},h={depthRadius:t,bias:n,alpha:s,beta:u},b=r.a.runKernel(a.wb,p,h);return f?Object(c.a)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({log1p_:function(e){var t={x:Object(i.a)(e,"x","log1p")};return r.a.runKernel(a.Db,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({softplus_:function(e){var t={x:Object(i.a)(e,"x","softplus")};return r.a.runKernel(a.Gc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(2),a=n(34),i=n(82),o=n(120),s=n(153),c=n(8);var u=Object(c.b)({logicalXor_:function(e,t){var n=Object(r.a)(e,"a","logicalXor","bool"),c=Object(r.a)(t,"b","logicalXor","bool");return Object(a.a)(n.shape,c.shape),Object(i.a)(Object(s.a)(e,t),Object(o.a)(Object(i.a)(e,t)))}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({mirrorPad_:function(e,t,n){o.b("reflect"===n||"symmetric"===n,(function(){return"Invalid mode. Mode must be either reflect or symmetric. "+"Got ".concat(n,".")}));var s=Object(i.a)(e,"x","mirrorPad");if(0===s.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");o.b(t.length===s.rank,(function(){return"Padding doesn't match input. Must be ".concat(s.rank,". ")+"Got ".concat(t.length,".")}));for(var c="reflect"===n?1:0,u=function(e){o.b(2===t[e].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),o.b(t[e][0]>=0&&t[e][0]<=s.shape[e]-c&&t[e][1]>=0&&t[e][1]<=s.shape[e]-c,(function(){return"Padding in dimension ".concat(e," cannot be greater than or equal ")+"to ".concat(s.shape[e]-c," or less than 0 for input of ")+"shape ".concat(s.shape)}))},l=0;l2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(t<2)throw new Error("Error in oneHot: depth must be >=2, but it is ".concat(t));var s=Object(i.a)(e,"indices","oneHot","int32"),c={indices:s},u={depth:t,onValue:n,offValue:o};return r.a.runKernel(a.bc,c,u)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return p}));var r=n(6),a=n(2),i=n(15),o=n(143),s=n(115),c=n(48),u=n(154),l=n(8),d=n(13),f=n(122);var p=Object(l.b)({pool_:function(e,t,n,l,p,h){null==p&&(p=[1,1]),null==h&&(h=1),0===l&&(l="valid");var b=Object(a.a)(e,"x","maxPool"),m=b,v=!1;3===b.rank&&(v=!0,m=Object(d.a)(b,[1,b.shape[0],b.shape[1],b.shape[2]])),i.b(c.h(h,p),(function(){return"Error in pool: Either strides or dilations must be 1. "+"Got strides ".concat(h," and dilations '").concat(p,"'")}));var g,y=c.e(m.shape,t,h,p,l),O=[y.dilationHeight,y.dilationWidth];g="same"===l?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]]}))}([y.filterHeight,y.filterWidth],O):[[0,0],[0,0]];var x=1===O[0]&&1===O[1],k=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]})),c=t.map((function(e,t){return[r[t],s[t]]})),u=t.map((function(e,t){return[0,o[t]]}));return[c,u]}([y.inHeight,y.inWidth],O,g),w=Object(r.a)(k,2),j=w[0],S=w[1],N=x?l:"valid",I=x?m:Object(f.a)(m,O,j),C=("avg"===n?function(){return Object(o.a)(I,t,h,N)}:function(){return Object(u.a)(I,t,h,N)})(),T=x?C:Object(s.a)(C,O,S);return v?Object(d.a)(T,[T.shape[1],T.shape[2],T.shape[3]]):T}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(24),s=n(8);var c=Object(s.b)({prod_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=Object(i.a)(e,"x","prod");"bool"===s.dtype&&(s=Object(o.a)(s,"int32"));var c={x:s},u={axis:t,keepDims:n};return r.a.runKernel(a.hc,c,u)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(68),a=n(8),i=n(126);var o=Object(a.b)({randomUniform_:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"float32",o=arguments.length>4?arguments[4]:void 0,s=Object(r.a)(e,a),c=new i.c(t,n,null,o),u=0;u5&&void 0!==arguments[5]?arguments[5]:[1,1],d=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"NHWC",f=Object(r.a)(e,"x","separableConv2d"),p=Object(r.a)(t,"depthwiseFilter","separableConv2d"),h=Object(r.a)(n,"pointwiseFilter","separableConv2d"),b=f,m=!1;if(3===f.rank&&(m=!0,b=Object(c.a)(f,[1,f.shape[0],f.shape[1],f.shape[2]])),"NCHW"===d)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");a.b(4===b.rank,(function(){return"Error in separableConv2d: input must be rank 4, but got "+"rank ".concat(b.rank,".")})),a.b(4===p.rank,(function(){return"Error in separableConv2d: depthwise filter must be rank 4, but "+"got rank ".concat(p.rank,".")})),a.b(4===h.rank,(function(){return"Error in separableConv2d: pointwise filter must be rank 4, but "+"got rank ".concat(p.rank,".")})),a.b(1===h.shape[0],(function(){return"Error in separableConv2d: the first dimension of pointwise filter "+" must be 1, but got ".concat(h.shape[0],".")})),a.b(1===h.shape[1],(function(){return"Error in separableConv2d: the second dimension of pointwise "+"filter must be 1, but got ".concat(h.shape[1],".")}));var v=p.shape[2],g=p.shape[3];a.b(h.shape[2]===v*g,(function(){return"Error in separableConv2d: the third dimension of pointwise filter "+"must be ".concat(v*g,", ")+"but got ".concat(h.shape[2],".")}));var y=Object(o.a)(b,p,s,u,d,l),O=1,x=Object(i.a)(y,h,O,"valid",d);return m?Object(c.a)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({sin_:function(e){var t={x:Object(i.a)(e,"x","sin")};return r.a.runKernel(a.Cc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({sinh_:function(e){var t={x:Object(i.a)(e,"x","sinh")};return r.a.runKernel(a.Dc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var r=n(81),a=n(49),i=n(149),o=n(18),s=n(8),c=n(133),u=n(13),l=n(69),d=n(33),f=n(43),p=n(134);var h=Object(s.b)({irfft_:function(e){var t,n=e.shape[e.shape.length-1],s=e.size/n;if(n<=2){var h=Object(u.a)(e,[s,n]);t=Object(p.a)(h)}else{var b=[s,2*(n-1)],m=Object(u.a)(Object(c.a)(e),[s,n]),v=Object(u.a)(Object(i.a)(e),[s,n]),g=Object(l.a)(Object(f.a)(m,[0,1],[s,n-2]),1),y=Object(o.a)(Object(l.a)(Object(f.a)(v,[0,1],[s,n-2]),1),Object(d.a)(-1)),O=Object(a.a)([m,g],1),x=Object(a.a)([v,y],1),k=Object(u.a)(Object(r.a)(O,x),[b[0],b[1]]);t=Object(p.a)(k)}if(t=Object(c.a)(t),3===e.rank&&0!==e.shape[0]){var w=t,j=e.shape[0];t=Object(u.a)(t,[j,t.shape[0]/j,t.shape[1]]),w.dispose()}return t}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),a=n(15),i=n(71);function o(e,t,n){if(Object(a.d)(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");var o=Object(r.c)(e,n);if(3!==o.length&&1!==o.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===o.length&&null==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Object(i.a)(e,t,o,n)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(6),a=n(9),i=n(3),o=n(2),s=n(8);var c=Object(s.b)({topk_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=Object(o.a)(e,"x","topk");if(0===s.rank)throw new Error("topk() expects the input to be of rank 1 or higher");var c=s.shape[s.shape.length-1];if(t<0)throw new Error("'k' passed to topk() must be >= 0 but got ".concat(t));if(t>c)throw new Error("'k' passed to topk() must be <= the last dimension (".concat(c,") ")+"but got ".concat(t));var u={x:s},l={k:t,sorted:n},d=a.a.runKernel(i.bd,u,l),f=Object(r.a)(d,2),p=f[0],h=f[1];return{values:p,indices:h}}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(6),a=n(9),i=n(3),o=n(2),s=n(15),c=n(8);var u=Object(c.b)({unique_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Object(o.a)(e,"x","unique","string_or_numeric");Object(s.b)(n.rank>0,(function(){return"The input tensor must be at least 1D"}));var c={x:n},u={axis:t},l=a.a.runKernel(i.ed,c,u),d=Object(r.a)(l,2),f=d[0],p=d[1];return{values:f,indices:p}}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(5),a=n.n(r),i=n(12),o=n(224),s=n(2);function c(){return(c=Object(i.a)(a.a.mark((function e(t){var n,r,i;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Object(s.a)(t,"condition","whereAsync","bool"),e.next=3,n.data();case 3:return r=e.sent,i=Object(o.a)(n.shape,r),t!==n&&n.dispose(),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var u=function(e){return c.apply(this,arguments)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(68);function a(e,t){for(var n=[],a=0;a2&&void 0!==arguments[2]&&arguments[2],c=arguments.length>3&&void 0!==arguments[3]&&arguments[3],l=Object(o.a)(e,"images","resizeNearestNeighbor");s.b(3===l.rank||4===l.rank,(function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got "+"rank ".concat(l.rank,".")})),s.b(2===t.length,(function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+"".concat(t,".")})),s.b("float32"===l.dtype||"int32"===l.dtype,(function(){return"`images` must have `int32` or `float32` as dtype"})),s.b(!1===c||!1===n,(function(){return"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."}));var d=l,f=!1;3===l.rank&&(f=!0,d=Object(u.a)(l,[1,l.shape[0],l.shape[1],l.shape[2]])),Object(r.a)(t);var p={images:d},h={alignCorners:n,halfPixelCenters:c,size:t},b=a.a.runKernel(i.rc,p,h);return f?Object(u.a)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(225),a=n(227),i=n(124),o=n(226);function s(e){return Object(r.a)(e)||Object(a.a)(e)||Object(i.a)(e)||Object(o.a)()}},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(231),a=n(9),i=n(3),o=n(2),s=n(15),c=n(8),u=n(13);var l=Object(c.b)({resizeBilinear_:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],c=arguments.length>3&&void 0!==arguments[3]&&arguments[3],l=Object(o.a)(e,"images","resizeBilinear");s.b(3===l.rank||4===l.rank,(function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got "+"rank ".concat(l.rank,".")})),s.b(2===t.length,(function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+"".concat(t,".")})),s.b(!1===c||!1===n,(function(){return"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."}));var d=l,f=!1;3===l.rank&&(f=!0,d=Object(u.a)(l,[1,l.shape[0],l.shape[1],l.shape[2]])),Object(r.a)(t);var p={images:d},h={alignCorners:n,halfPixelCenters:c,size:t},b=a.a.runKernel(i.pc,p,h);return f?Object(u.a)(b,[b.shape[1],b.shape[2],b.shape[3]]):b}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(8),o=n(13);var s=Object(i.b)({depthwiseConv2dNativeBackpropInput_:function(e,t,n,i,s){var c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[1,1],u=arguments.length>6?arguments[6]:void 0,l=t,d=!1;3===t.rank&&(d=!0,l=Object(o.a)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var f={dy:l,filter:n},p={strides:i,pad:s,dimRoundingMode:u,dilations:c,inputShape:e},h=r.a.runKernel(a.Q,f,p);return d?Object(o.a)(h,[h.shape[1],h.shape[2],h.shape[3]]):h}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(8),o=n(13);var s=Object(i.b)({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,i,s){var c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[1,1],u=arguments.length>6?arguments[6]:void 0,l=e;3===e.rank&&(l=Object(o.a)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var d=t;3===d.rank&&(d=Object(o.a)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var f={x:l,dy:d},p={strides:i,pad:s,dimRoundingMode:u,dilations:c,filterShape:n};return r.a.runKernel(a.P,f,p)}})},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return de}));var r=n(30),a=n.n(r),i=n(306),o=n.n(i),s=n(307),c=n.n(s),u=n(4),l=n.n(u),d=n(177),f=n.n(d),p="bodyAttributes",h="htmlAttributes",b="titleAttributes",m={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title"},v=(Object.keys(m).map((function(e){return m[e]})),"charset"),g="cssText",y="href",O="http-equiv",x="innerHTML",k="itemprop",w="name",j="property",S="rel",N="src",I="target",C={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},T="defaultTitle",E="defer",A="encodeSpecialCharacters",R="onChangeClientState",F="titleTemplate",D=Object.keys(C).reduce((function(e,t){return e[C[t]]=t,e}),{}),_=[m.NOSCRIPT,m.SCRIPT,m.STYLE],M="data-react-helmet",z="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},P=function(){function e(e,t){for(var n=0;n=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},U=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t},V=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return!1===t?String(e):String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},H=function(e){var t=Y(e,m.TITLE),n=Y(e,F);if(n&&t)return n.replace(/%s/g,(function(){return Array.isArray(t)?t.join(""):t}));var r=Y(e,T);return t||r||void 0},G=function(e){return Y(e,R)||function(){}},q=function(e,t){return t.filter((function(t){return"undefined"!==typeof t[e]})).map((function(t){return t[e]})).reduce((function(e,t){return B({},e,t)}),{})},K=function(e,t){return t.filter((function(e){return"undefined"!==typeof e[m.BASE]})).map((function(e){return e[m.BASE]})).reverse().reduce((function(t,n){if(!t.length)for(var r=Object.keys(n),a=0;a=0;n--){var r=e[n];if(r.hasOwnProperty(t))return r[t]}return null},$=function(){var e=Date.now();return function(t){var n=Date.now();n-e>16?(e=n,t(n)):setTimeout((function(){$(t)}),0)}}(),Q=function(e){return clearTimeout(e)},Z="undefined"!==typeof window?window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||$:e.requestAnimationFrame||$,J="undefined"!==typeof window?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||Q:e.cancelAnimationFrame||Q,ee=function(e){return console&&"function"===typeof console.warn&&console.warn(e)},te=null,ne=function(e,t){var n=e.baseTag,r=e.bodyAttributes,a=e.htmlAttributes,i=e.linkTags,o=e.metaTags,s=e.noscriptTags,c=e.onChangeClientState,u=e.scriptTags,l=e.styleTags,d=e.title,f=e.titleAttributes;ie(m.BODY,r),ie(m.HTML,a),ae(d,f);var p={baseTag:oe(m.BASE,n),linkTags:oe(m.LINK,i),metaTags:oe(m.META,o),noscriptTags:oe(m.NOSCRIPT,s),scriptTags:oe(m.SCRIPT,u),styleTags:oe(m.STYLE,l)},h={},b={};Object.keys(p).forEach((function(e){var t=p[e],n=t.newTags,r=t.oldTags;n.length&&(h[e]=n),r.length&&(b[e]=p[e].oldTags)})),t&&t(),c(e,h,b)},re=function(e){return Array.isArray(e)?e.join(""):e},ae=function(e,t){"undefined"!==typeof e&&document.title!==e&&(document.title=re(e)),ie(m.TITLE,t)},ie=function(e,t){var n=document.getElementsByTagName(e)[0];if(n){for(var r=n.getAttribute(M),a=r?r.split(","):[],i=[].concat(a),o=Object.keys(t),s=0;s=0;d--)n.removeAttribute(i[d]);a.length===i.length?n.removeAttribute(M):n.getAttribute(M)!==o.join(",")&&n.setAttribute(M,o.join(","))}},oe=function(e,t){var n=document.head||document.querySelector(m.HEAD),r=n.querySelectorAll(e+"["+"data-react-helmet]"),a=Array.prototype.slice.call(r),i=[],o=void 0;return t&&t.length&&t.forEach((function(t){var n=document.createElement(e);for(var r in t)if(t.hasOwnProperty(r))if(r===x)n.innerHTML=t.innerHTML;else if(r===g)n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText));else{var s="undefined"===typeof t[r]?"":t[r];n.setAttribute(r,s)}n.setAttribute(M,"true"),a.some((function(e,t){return o=t,n.isEqualNode(e)}))?a.splice(o,1):i.push(n)})),a.forEach((function(e){return e.parentNode.removeChild(e)})),i.forEach((function(e){return n.appendChild(e)})),{oldTags:a,newTags:i}},se=function(e){return Object.keys(e).reduce((function(t,n){var r="undefined"!==typeof e[n]?n+'="'+e[n]+'"':""+n;return t?t+" "+r:r}),"")},ce=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).reduce((function(t,n){return t[C[n]||n]=e[n],t}),t)},ue=function(e,t,n){switch(e){case m.TITLE:return{toComponent:function(){return function(e,t,n){var r,a=((r={key:t})[M]=!0,r),i=ce(n,a);return[l.a.createElement(m.TITLE,i,t)]}(0,t.title,t.titleAttributes)},toString:function(){return function(e,t,n,r){var a=se(n),i=re(t);return a?"<"+e+' data-react-helmet="true" '+a+">"+V(i,r)+"":"<"+e+' data-react-helmet="true">'+V(i,r)+""}(e,t.title,t.titleAttributes,n)}};case p:case h:return{toComponent:function(){return ce(t)},toString:function(){return se(t)}};default:return{toComponent:function(){return function(e,t){return t.map((function(t,n){var r,a=((r={key:n})[M]=!0,r);return Object.keys(t).forEach((function(e){var n=C[e]||e;if(n===x||n===g){var r=t.innerHTML||t.cssText;a.dangerouslySetInnerHTML={__html:r}}else a[n]=t[e]})),l.a.createElement(e,a)}))}(e,t)},toString:function(){return function(e,t,n){return t.reduce((function(t,r){var a=Object.keys(r).filter((function(e){return!(e===x||e===g)})).reduce((function(e,t){var a="undefined"===typeof r[t]?t:t+'="'+V(r[t],n)+'"';return e?e+" "+a:a}),""),i=r.innerHTML||r.cssText||"",o=-1===_.indexOf(e);return t+"<"+e+' data-react-helmet="true" '+a+(o?"/>":">"+i+"")}),"")}(e,t,n)}}}},le=function(e){var t=e.baseTag,n=e.bodyAttributes,r=e.encode,a=e.htmlAttributes,i=e.linkTags,o=e.metaTags,s=e.noscriptTags,c=e.scriptTags,u=e.styleTags,l=e.title,d=void 0===l?"":l,f=e.titleAttributes;return{base:ue(m.BASE,t,r),bodyAttributes:ue(p,n,r),htmlAttributes:ue(h,a,r),link:ue(m.LINK,i,r),meta:ue(m.META,o,r),noscript:ue(m.NOSCRIPT,s,r),script:ue(m.SCRIPT,c,r),style:ue(m.STYLE,u,r),title:ue(m.TITLE,{title:d,titleAttributes:f},r)}},de=function(e){var t,n;return n=t=function(t){function n(){return L(this,n),U(this,t.apply(this,arguments))}return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(n,t),n.prototype.shouldComponentUpdate=function(e){return!c()(this.props,e)},n.prototype.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case m.SCRIPT:case m.NOSCRIPT:return{innerHTML:t};case m.STYLE:return{cssText:t}}throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")},n.prototype.flattenArrayTypeChildren=function(e){var t,n=e.child,r=e.arrayTypeChildren,a=e.newChildProps,i=e.nestedChildren;return B({},r,((t={})[n.type]=[].concat(r[n.type]||[],[B({},a,this.mapNestedChildrenToProps(n,i))]),t))},n.prototype.mapObjectTypeChildren=function(e){var t,n,r=e.child,a=e.newProps,i=e.newChildProps,o=e.nestedChildren;switch(r.type){case m.TITLE:return B({},a,((t={})[r.type]=o,t.titleAttributes=B({},i),t));case m.BODY:return B({},a,{bodyAttributes:B({},i)});case m.HTML:return B({},a,{htmlAttributes:B({},i)})}return B({},a,((n={})[r.type]=B({},i),n))},n.prototype.mapArrayTypeChildrenToProps=function(e,t){var n=B({},t);return Object.keys(e).forEach((function(t){var r;n=B({},n,((r={})[t]=e[t],r))})),n},n.prototype.warnOnInvalidChildren=function(e,t){return!0},n.prototype.mapChildrenToProps=function(e,t){var n=this,r={};return l.a.Children.forEach(e,(function(e){if(e&&e.props){var a=e.props,i=a.children,o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).reduce((function(t,n){return t[D[n]||n]=e[n],t}),t)}(W(a,["children"]));switch(n.warnOnInvalidChildren(e,i),e.type){case m.LINK:case m.META:case m.NOSCRIPT:case m.SCRIPT:case m.STYLE:r=n.flattenArrayTypeChildren({child:e,arrayTypeChildren:r,newChildProps:o,nestedChildren:i});break;default:t=n.mapObjectTypeChildren({child:e,newProps:t,newChildProps:o,nestedChildren:i})}}})),t=this.mapArrayTypeChildrenToProps(r,t)},n.prototype.render=function(){var t=this.props,n=t.children,r=W(t,["children"]),a=B({},r);return n&&(a=this.mapChildrenToProps(n,a)),l.a.createElement(e,a)},P(n,null,[{key:"canUseDOM",set:function(t){e.canUseDOM=t}}]),n}(l.a.Component),t.propTypes={base:a.a.object,bodyAttributes:a.a.object,children:a.a.oneOfType([a.a.arrayOf(a.a.node),a.a.node]),defaultTitle:a.a.string,defer:a.a.bool,encodeSpecialCharacters:a.a.bool,htmlAttributes:a.a.object,link:a.a.arrayOf(a.a.object),meta:a.a.arrayOf(a.a.object),noscript:a.a.arrayOf(a.a.object),onChangeClientState:a.a.func,script:a.a.arrayOf(a.a.object),style:a.a.arrayOf(a.a.object),title:a.a.string,titleAttributes:a.a.object,titleTemplate:a.a.string},t.defaultProps={defer:!0,encodeSpecialCharacters:!0},t.peek=e.peek,t.rewind=function(){var t=e.rewind();return t||(t=le({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),t},n}(o()((function(e){return{baseTag:K([y,I],e),bodyAttributes:q(p,e),defer:Y(e,E),encode:Y(e,A),htmlAttributes:q(h,e),linkTags:X(m.LINK,[S,y],e),metaTags:X(m.META,[w,v,O,j,k],e),noscriptTags:X(m.NOSCRIPT,[x],e),onChangeClientState:G(e),scriptTags:X(m.SCRIPT,[N,x],e),styleTags:X(m.STYLE,[g],e),title:H(e),titleAttributes:q(b,e)}}),(function(e){te&&J(te),e.defer?te=Z((function(){ne(e,(function(){te=null}))})):(ne(e),te=null)}),le)((function(){return null})));de.renderStatic=de.rewind}).call(this,n(137))},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(184);function a(e,t){if(e){if("string"===typeof e)return Object(r.a)(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)?Object(r.a)(e,t):void 0}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));n(108),n(14);var r=n(135),a=(n(30),n(128),{xs:0,sm:600,md:960,lg:1280,xl:1920}),i={keys:["xs","sm","md","lg","xl"],up:function(e){return"@media (min-width:".concat(a[e],"px)")}};function o(e,t,n){if(Array.isArray(t)){var a=e.theme.breakpoints||i;return t.reduce((function(e,r,i){return e[a.up(a.keys[i])]=n(t[i]),e}),{})}if("object"===Object(r.a)(t)){var o=e.theme.breakpoints||i;return Object.keys(t).reduce((function(e,r){return e[o.up(r)]=n(t[r]),e}),{})}return n(t)}},function(e,t,n){"use strict";t.a={mobileStepper:1e3,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500}},function(e,t,n){"use strict";(function(e){var r=n(329),a=n(330),i=n(331);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function h(e,t){if(c.isBuffer(e))return e.length;if("undefined"!==typeof ArrayBuffer&&"function"===typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!==typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return U(e).length;default:if(r)return W(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return E(this,t,n);case"utf8":case"utf-8":return N(this,t,n);case"ascii":return C(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return S(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function m(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,a){if(0===e.length)return-1;if("string"===typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if("string"===typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:g(e,t,n,r,a);if("number"===typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"===typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):g(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function g(e,t,n,r,a){var i,o=1,s=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,s/=2,c/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(a){var l=-1;for(i=n;is&&(n=s-c),i=n;i>=0;i--){for(var d=!0,f=0;fa&&(r=a):r=a;var i=t.length;if(i%2!==0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var o=0;o>8,a=n%256,i.push(a),i.push(r);return i}(t,e.length-n),e,n,r)}function S(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function N(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a239?4:u>223?3:u>191?2:1;if(a+d<=n)switch(d){case 1:u<128&&(l=u);break;case 2:128===(192&(i=e[a+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[a+1],o=e[a+2],128===(192&i)&&128===(192&o)&&(c=(15&u)<<12|(63&i)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[a+1],o=e[a+2],s=e[a+3],128===(192&i)&&128===(192&o)&&128===(192&s)&&(c=(15&u)<<18|(63&i)<<12|(63&o)<<6|63&s)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),a+=d}return function(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},c.prototype.compare=function(e,t,n,r,a){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(a>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),s=Math.min(i,o),u=this.slice(r,a),l=e.slice(t,n),d=0;da)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return y(this,e,t,n);case"utf8":case"utf-8":return O(this,e,t,n);case"ascii":return x(this,e,t,n);case"latin1":case"binary":return k(this,e,t,n);case"base64":return w(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function C(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;ar)&&(n=r);for(var a="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function F(e,t,n,r,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||te.length)throw new RangeError("Index out of range")}function D(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a>>8*(r?a:1-a)}function _(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a>>8*(r?a:3-a)&255}function M(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function z(e,t,n,r,i){return i||M(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function L(e,t,n,r,i){return i||M(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(a*=256);)r+=this[e+--t]*a;return r},c.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e],a=1,i=0;++i=(a*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||F(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+a]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):_(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);F(this,e,t,n,a-1,-a)}var i=0,o=1,s=0;for(this[t]=255&e;++i>0)-s&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);F(this,e,t,n,a-1,-a)}var i=n-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o>>0)-s&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):_(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return z(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return z(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return L(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return L(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--a)e[a+t]=this[a+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(a=0;a>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"===typeof e)for(i=t;i55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function U(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(P,"")).length<2)return"";for(;e.length%4!==0;)e+="=";return e}(e))}function V(e,t,n,r){for(var a=0;a=t.length||a>=e.length);++a)t[a+n]=e[a];return a}}).call(this,n(137))},function(e,t){e.exports=r;var n=null;try{n=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(N){}function r(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function a(e){return!0===(e&&e.__isLong__)}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=a;var i={},o={};function s(e,t){var n,r,a;return t?(a=0<=(e>>>=0)&&e<256)&&(r=o[e])?r:(n=u(e,(0|e)<0?-1:0,!0),a&&(o[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(r=i[e])?r:(n=u(e,e<0?-1:0,!1),a&&(i[e]=n),n)}function c(e,t){if(isNaN(e))return t?g:v;if(t){if(e<0)return g;if(e>=h)return w}else{if(e<=-b)return j;if(e+1>=b)return k}return e<0?c(-e,t).neg():u(e%p|0,e/p|0,t)}function u(e,t,n){return new r(e,t,n)}r.fromInt=s,r.fromNumber=c,r.fromBits=u;var l=Math.pow;function d(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return v;if("number"===typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||360)throw Error("interior hyphen");if(0===r)return d(e.substring(1),t,n).neg();for(var a=c(l(n,8)),i=v,o=0;o>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*p+(this.low>>>0):this.high*p+(this.low>>>0)},S.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((i=s).isZero())return u+o;for(;u.length<6;)u="0"+u;o=""+u+o}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(j)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},S.isOdd=function(){return 1===(1&this.low)},S.isEven=function(){return 0===(1&this.low)},S.equals=function(e){return a(e)||(e=f(e)),(this.unsigned===e.unsigned||this.high>>>31!==1||e.high>>>31!==1)&&(this.high===e.high&&this.low===e.low)},S.eq=S.equals,S.notEquals=function(e){return!this.eq(e)},S.neq=S.notEquals,S.ne=S.notEquals,S.lessThan=function(e){return this.comp(e)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(e){return this.comp(e)<=0},S.lte=S.lessThanOrEqual,S.le=S.lessThanOrEqual,S.greaterThan=function(e){return this.comp(e)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(e){return this.comp(e)>=0},S.gte=S.greaterThanOrEqual,S.ge=S.greaterThanOrEqual,S.compare=function(e){if(a(e)||(e=f(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},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(j)?j:this.not().add(y)},S.neg=S.negate,S.add=function(e){a(e)||(e=f(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=e.high>>>16,s=65535&e.high,c=e.low>>>16,l=0,d=0,p=0,h=0;return p+=(h+=i+(65535&e.low))>>>16,d+=(p+=r+c)>>>16,l+=(d+=n+s)>>>16,l+=t+o,u((p&=65535)<<16|(h&=65535),(l&=65535)<<16|(d&=65535),this.unsigned)},S.subtract=function(e){return a(e)||(e=f(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return v;if(a(e)||(e=f(e)),n)return u(n.mul(this.low,this.high,e.low,e.high),n.get_high(),this.unsigned);if(e.isZero())return v;if(this.eq(j))return e.isOdd()?j:v;if(e.eq(j))return this.isOdd()?j:v;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(m)&&e.lt(m))return c(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,i=this.low>>>16,o=65535&this.low,s=e.high>>>16,l=65535&e.high,d=e.low>>>16,p=65535&e.low,h=0,b=0,g=0,y=0;return g+=(y+=o*p)>>>16,b+=(g+=i*p)>>>16,g&=65535,b+=(g+=o*d)>>>16,h+=(b+=r*p)>>>16,b&=65535,h+=(b+=i*d)>>>16,b&=65535,h+=(b+=o*l)>>>16,h+=t*p+r*d+i*l+o*s,u((g&=65535)<<16|(y&=65535),(h&=65535)<<16|(b&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(a(e)||(e=f(e)),e.isZero())throw Error("division by zero");var t,r,i;if(n)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?n.div_u:n.div_s)(this.low,this.high,e.low,e.high),n.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?g:v;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return g;if(e.gt(this.shru(1)))return O;i=g}else{if(this.eq(j))return e.eq(y)||e.eq(x)?j:e.eq(j)?y:(t=this.shr(1).div(e).shl(1)).eq(v)?e.isNegative()?y:x:(r=this.sub(e.mul(t)),i=t.add(r.div(e)));if(e.eq(j))return this.unsigned?g:v;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();i=v}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),s=o<=48?1:l(2,o-48),d=c(t),p=d.mul(e);p.isNegative()||p.gt(r);)p=(d=c(t-=s,this.unsigned)).mul(e);d.isZero()&&(d=y),i=i.add(d),r=r.sub(p)}return i},S.div=S.divide,S.modulo=function(e){return a(e)||(e=f(e)),n?u((this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,e.low,e.high),n.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},S.mod=S.modulo,S.rem=S.modulo,S.not=function(){return u(~this.low,~this.high,this.unsigned)},S.and=function(e){return a(e)||(e=f(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return a(e)||(e=f(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return a(e)||(e=f(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},S.shiftLeft=function(e){return a(e)&&(e=e.toInt()),0===(e&=63)?this:e<32?u(this.low<>>32-e,this.unsigned):u(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(e){if(a(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?u(this.low>>>e|t<<32-e,t>>>e,this.unsigned):u(32===e?t:t>>>e-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.shr_u=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},S.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},S.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]},S.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]},r.fromBytes=function(e,t,n){return n?r.fromBytesLE(e,t):r.fromBytesBE(e,t)},r.fromBytesLE=function(e,t){return new r(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},r.fromBytesBE=function(e,t){return new r(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},function(e,t,n){var r;!function(){"use strict";var n={}.hasOwnProperty;function a(){for(var e=[],t=0;t=1,(function(){return"Must pass at least one tensor to tf.addN(), but got "+"".concat(e.length)}));var t=e.map((function(e,t){return Object(i.a)(e,"tensors".concat(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(!o.a(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));var s=t;return r.a.runKernel(a.e,s)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({asin_:function(e){var t={x:Object(i.a)(e,"x","asin")};return r.a.runKernel(a.j,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({asinh_:function(e){var t={x:Object(i.a)(e,"x","asinh")};return r.a.runKernel(a.k,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({atan_:function(e){var t={x:Object(i.a)(e,"x","atan")};return r.a.runKernel(a.l,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({atanh_:function(e){var t={x:Object(i.a)(e,"x","atanh")};return r.a.runKernel(a.n,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(24),c=n(8),u=n(13);var l=Object(c.b)({avgPool3d_:function(e,t,n,c,l){var d=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"NDHWC",f=Object(i.a)(e,"x","avgPool3d","float32"),p=f,h=!1;4===f.rank&&(h=!0,p=Object(u.a)(f,[1,f.shape[0],f.shape[1],f.shape[2],f.shape[3]])),o.b(5===p.rank,(function(){return"Error in avgPool3d: x must be rank 5 but got rank ".concat(p.rank,".")})),o.b("NDHWC"===d,(function(){return"Error in avgPool3d: Only NDHWC is currently supported, "+"but got dataFormat of ".concat(d)})),null!=l&&o.b(o.v(c),(function(){return"Error in avgPool3d: pad must be an integer when using, "+"dimRoundingMode ".concat(l," but got pad ").concat(c,".")}));var b={x:p},m={filterSize:t,strides:n,pad:c,dimRoundingMode:l,dataFormat:d},v=r.a.runKernel(a.p,b,m);return v=Object(s.a)(v,p.dtype),h?Object(u.a)(v,[v.shape[1],v.shape[2],v.shape[3],v.shape[4]]):v}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({ceil_:function(e){var t={x:Object(i.a)(e,"x","ceil")};return r.a.runKernel(a.x,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({clipByValue_:function(e,t,n){var s=Object(i.a)(e,"x","clipByValue");o.b(t<=n,(function(){return"Error in clip: min (".concat(t,") must be ")+"less than or equal to max (".concat(n,").")}));var c={x:s},u={clipValueMin:t,clipValueMax:n};return r.a.runKernel(a.y,c,u)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(48),c=n(8),u=n(13);var l=Object(c.b)({conv3d_:function(e,t,n,c){var l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"NDHWC",d=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[1,1,1],f=Object(i.a)(e,"x","conv3d"),p=Object(i.a)(t,"filter","conv3d"),h=f,b=!1;4===f.rank&&(b=!0,h=Object(u.a)(f,[1,f.shape[0],f.shape[1],f.shape[2],f.shape[3]])),o.b(5===h.rank,(function(){return"Error in conv3d: input must be rank 5, but got rank ".concat(h.rank,".")})),o.b(5===p.rank,(function(){return"Error in conv3d: filter must be rank 5, but got rank "+"".concat(p.rank,".")})),o.b(h.shape[4]===p.shape[3],(function(){return"Error in conv3d: depth of input (".concat(h.shape[4],") must match ")+"input depth for filter ".concat(p.shape[3],".")})),o.b(Object(s.h)(n,d),(function(){return"Error in conv3D: Either strides or dilations must be 1. "+"Got strides ".concat(n," and dilations '").concat(d,"'")})),o.b("NDHWC"===l,(function(){return"Error in conv3d: got dataFormat of ".concat(l," but only NDHWC is currently supported.")}));var m={x:h,filter:p},v={strides:n,pad:c,dataFormat:l,dilations:d},g=r.a.runKernel(a.F,m,v);return b?Object(u.a)(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8);var c=Object(s.b)({denseBincount_:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],c=Object(i.a)(e,"x","denseBincount"),u=Object(i.a)(t,"weights","denseBincount");o.b("int32"===c.dtype,(function(){return"Error in denseBincount: input "+"dtype must be int32, but got ".concat(c.dtype)})),o.b(c.rank<=2,(function(){return"Error in denseBincount: input must be at most rank 2, but got "+"rank ".concat(c.rank,".")})),o.b(n>=0,(function(){return"size must be non-negative, but got ".concat(n,".")})),o.b(u.size===c.size||0===u.size,(function(){return"Error in denseBincount: weights must have the same shape as x or "+"0-length, but got x shape: ".concat(c.shape,", weights shape: ")+"".concat(u.shape,".")}));var l={x:c,weights:u},d={size:n,binaryOutput:s};return r.a.runKernel(a.M,l,d)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({einsum_:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:-1,n=Object(i.a)(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 ".concat(n.rank," and axis was ").concat(t));var d=Object(a.a)((function(e,n){var a=Object(u.a)(e,t,!0),i=Object(f.a)(e,a),d=Object(f.a)(Object(o.a)(i,"float32"),Object(c.a)(Object(p.a)(Object(s.a)(i),t,!0)));n([d]);return{value:d,gradFunc:function(e,n){var a=Object(r.a)(n,1)[0],i=Object(s.a)(a);return Object(f.a)(e,Object(l.a)(Object(p.a)(e,t,!0),i))}}}));return d(n)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(9),a=n(3),i=n(2),o=n(15),s=n(8),c=n(13);var u=Object(s.b)({maxPool3d_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[1,1,1],n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,u=arguments.length>4?arguments[4]:void 0,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"NDHWC",d=Object(i.a)(e,"x","maxPool3d"),f=d,p=!1;4===d.rank&&(p=!0,f=Object(c.a)(d,[1,d.shape[0],d.shape[1],d.shape[2],d.shape[3]])),o.b(5===f.rank,(function(){return"Error in maxPool3d: x must be rank 5 but got rank ".concat(f.rank,".")})),o.b("NDHWC"===l,(function(){return"Error in maxPool3d: Only NDHWC is currently supported, "+"but got dataFormat of ".concat(l)})),null!=u&&o.b(o.v(s),(function(){return"Error in maxPool3d: pad must be an integer when using, "+"dimRoundingMode ".concat(u," but got pad ").concat(s,".")}));var h={x:f},b={filterSize:t,strides:n,pad:s,dimRoundingMode:u,dataFormat:l},m=r.a.runKernel(a.Kb,h,b);return p?Object(c.a)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({maxPoolWithArgmax_:function(e,t,n,o){var s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],c=Object(i.a)(e,"x","maxPoolWithArgmax"),u={x:c},l={filterSize:t,strides:n,pad:o,includeBatchInIndex:s},d=r.a.runKernel(a.Nb,u,l);return{result:d[0],indexes:d[1]}}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),a=n(3),i=n(2),o=n(8),s=n(13);var c=Object(o.b)({multinomial_:function(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],c=Object(i.a)(e,"logits","multinomial"),u=c.size,l=c.rank;if(u<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+"".concat(u,"."));if(l>2)throw new Error("Rank of probabilities must be 1 or 2, but is ".concat(l));n=n||Math.random();var d=1===l?Object(s.a)(c,[1,-1]):c,f={logits:d},p={numSamples:t,seed:n,normalized:o},h=r.a.runKernel(a.Ub,f,p);return 1===l?Object(s.a)(h,[h.size]):h}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({onesLike_:function(e){var t={x:Object(i.a)(e,"x","onesLike")};return r.a.runKernel(a.cc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({reciprocal_:function(e){var t={x:Object(i.a)(e,"x","reciprocal")};return r.a.runKernel(a.lc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(5),a=n.n(r),i=n(12),o=n(10),s=n(2),c=n(15);function u(){return(u=Object(i.a)(a.a.mark((function e(t,n){var r,i,u,l,d,f,p,h,b,m,v;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Object(s.a)(t,"x","setdiff1d"),i=Object(s.a)(n,"y","setdiff1d"),c.b(r.dtype===i.dtype,(function(){return"x and y should have the same dtype, but got x (".concat(r.dtype,") and y (").concat(i.dtype,").")})),c.b(1===r.rank,(function(){return"x should be 1D tensor, but got x (".concat(r.shape,").")})),c.b(1===i.rank,(function(){return"y should be 1D tensor, but got y (".concat(i.shape,").")})),e.next=7,r.data();case 7:return u=e.sent,e.next=10,i.data();case 10:for(l=e.sent,d=new Set(l),f=0,p=0;p1&&void 0!==arguments[1]?arguments[1]:-1,n=Object(i.a)(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 ".concat(n.rank," and dim was ").concat(t));var o={logits:n},s={dim:t};return r.a.runKernel(a.Fc,o,s)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({stridedSlice_:function(e,t,n,o){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,d=arguments.length>8&&void 0!==arguments[8]?arguments[8]:0,f=Object(i.a)(e,"x","stridedSlice","string_or_numeric"),p={x:f},h={begin:t,end:n,strides:o,beginMask:s,endMask:c,ellipsisMask:u,newAxisMask:l,shrinkAxisMask:d};return r.a.runKernel(a.Sc,p,h)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(9),a=n(3),i=n(2),o=n(8);var s=Object(o.b)({tan_:function(e){var t={x:Object(i.a)(e,"x","tan")};return r.a.runKernel(a.Yc,t)}})},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(68),a=n(8),i=n(126);var o=Object(a.b)({truncatedNormal_:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if(null!=a&&"bool"===a)throw new Error("Unsupported data type $ { dtype }");for(var s=new i.a(t,n,a,!0,o),c=Object(r.a)(e,a),u=0;u2)throw new Error("sparseIndices should be a scalar, vector, or matrix,"+" but got shape ".concat(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:,"+" ".concat(n.length,", should be: ").concat(i,"."));var o=t.size;if(0!==t.rank&&(1!==t.rank||o!==a))throw new Error("sparseValues has incorrect shape "+"".concat(t.shape,", should be [] or [").concat(a,"]"));if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}var o=n(2),s=n(8);var c=Object(s.b)({sparseToDense_:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,c=Object(o.a)(e,"sparseIndices","sparseToDense","int32"),u=Object(o.a)(t,"sparseValues","sparseToDense"),l=Object(o.a)(s,"defaultValue","sparseToDense",u.dtype);i(c,u,n,l);var d={sparseIndices:c,sparseValues:u,defaultValue:l},f={outputShape:n};return r.a.runKernel(a.Mc,d,f)}})},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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:"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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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"}]},{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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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:"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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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:"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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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"}]}]},function(e,t,n){"use strict";n.r(t),n.d(t,"json",(function(){return r}));var r=[{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:[]}]},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return p}));var r=n(5),a=n.n(r),i=n(12),o=n(7),s=n(11),c=n(16),u=n(17),l=n(0),d=n(67),f=n(305),p=function(e){Object(c.a)(n,e);var t=Object(u.a)(n);function n(){return Object(o.a)(this,n),t.apply(this,arguments)}return Object(s.a)(n,[{key:"decodeUTF8",value:function(){return new h(this)}}]),n}(d.a),h=function(e){Object(c.a)(n,e);var t=Object(u.a)(n);function n(e){var r;return Object(o.a)(this,n),(r=t.call(this)).upstream=e,r.impl=new b(e),r}return Object(s.a)(n,[{key:"summary",value:function(){return this.impl.summary()}},{key:"next",value:function(){var e=Object(i.a)(a.a.mark((function e(){return a.a.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)}}()}]),n}(f.a),b=function(t){Object(c.a)(d,t);var r=Object(u.a)(d);function d(e){var t;if(Object(o.a)(this,d),(t=r.call(this)).upstream=e,Object(l.Ud)().get("IS_BROWSER"))t.decoder=new TextDecoder("utf-8");else{var a=n(345).StringDecoder;t.decoder=new a("utf8")}return t}return Object(s.a)(d,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> Utf8")}},{key:"pump",value:function(){var t=Object(i.a)(a.a.mark((function t(){var n,r,i;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.upstream.next();case 2:if(!(n=t.sent).done){t.next=7;break}return t.abrupt("return",!1);case 7:r=n.value;case 8:return i=Object(l.Ud)().get("IS_BROWSER")?this.decoder.decode(r,{stream:!0}):this.decoder.write(e.from(r.buffer)),this.outputQueue.push(i),t.abrupt("return",!0);case 11:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}()}]),d}(d.b)}).call(this,n(239).Buffer)},function(e,t,n){"use strict";n.d(t,"a",(function(){return f}));var r=n(20),a=n(5),i=n.n(a),o=n(12),s=n(7),c=n(11),u=n(16),l=n(17),d=n(67),f=function(e){Object(u.a)(n,e);var t=Object(l.a)(n);function n(){return Object(s.a)(this,n),t.apply(this,arguments)}return Object(c.a)(n,[{key:"split",value:function(e){return new p(this,e)}}]),n}(d.a),p=function(e){Object(u.a)(n,e);var t=Object(l.a)(n);function n(e,r){var a;return Object(s.a)(this,n),(a=t.call(this)).upstream=e,a.impl=new h(e,r),a}return Object(c.a)(n,[{key:"summary",value:function(){return this.impl.summary()}},{key:"next",value:function(){var e=Object(o.a)(i.a.mark((function e(){return i.a.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)}}()}]),n}(f),h=function(e){Object(u.a)(n,e);var t=Object(l.a)(n);function n(e,r){var a;return Object(s.a)(this,n),(a=t.call(this)).upstream=e,a.separator=r,a.carryover="",a}return Object(c.a)(n,[{key:"summary",value:function(){return"".concat(this.upstream.summary()," -> Split('").concat(this.separator,"')")}},{key:"pump",value:function(){var e=Object(o.a)(i.a.mark((function e(){var t,n,a,o,s;return i.a.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:(n=t.value.split(this.separator))[0]=this.carryover+n[0],a=Object(r.a)(n.slice(0,-1));try{for(a.s();!(o=a.n()).done;)s=o.value,this.outputQueue.push(s)}catch(i){a.e(i)}finally{a.f()}return this.carryover=n[n.length-1],e.abrupt("return",!0);case 15:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),n}(d.b)},function(e,t,n){"use strict";var r,a=n(4),i=(r=a)&&"object"===typeof r&&"default"in r?r.default:r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=!("undefined"===typeof window||!window.document||!window.document.createElement);e.exports=function(e,t,n){if("function"!==typeof e)throw new Error("Expected reducePropsToState to be a function.");if("function"!==typeof t)throw new Error("Expected handleStateChangeOnClient to be a function.");if("undefined"!==typeof n&&"function"!==typeof n)throw new Error("Expected mapStateOnServer to either be undefined or a function.");return function(r){if("function"!==typeof r)throw new Error("Expected WrappedComponent to be a React component.");var c,u=[];function l(){c=e(u.map((function(e){return e.props}))),d.canUseDOM?t(c):n&&(c=n(c))}var d=function(e){var t,n;function a(){return e.apply(this,arguments)||this}n=e,(t=a).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,a.peek=function(){return c},a.rewind=function(){if(a.canUseDOM)throw new Error("You may only call rewind() on the server. Call peek() to read the current state.");var e=c;return c=void 0,u=[],e};var o=a.prototype;return o.UNSAFE_componentWillMount=function(){u.push(this),l()},o.componentDidUpdate=function(){l()},o.componentWillUnmount=function(){var e=u.indexOf(this);u.splice(e,1),l()},o.render=function(){return i.createElement(r,this.props)},a}(a.PureComponent);return o(d,"displayName","SideEffect("+function(e){return e.displayName||e.name||"Component"}(r)+")"),o(d,"canUseDOM",s),d}}},function(e,t){var n="undefined"!==typeof Element,r="function"===typeof Map,a="function"===typeof Set,i="function"===typeof ArrayBuffer&&!!ArrayBuffer.isView;function o(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var s,c,u,l;if(Array.isArray(e)){if((s=e.length)!=t.length)return!1;for(c=s;0!==c--;)if(!o(e[c],t[c]))return!1;return!0}if(r&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(l=e.entries();!(c=l.next()).done;)if(!t.has(c.value[0]))return!1;for(l=e.entries();!(c=l.next()).done;)if(!o(c.value[1],t.get(c.value[0])))return!1;return!0}if(a&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(l=e.entries();!(c=l.next()).done;)if(!t.has(c.value[0]))return!1;return!0}if(i&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((s=e.length)!=t.length)return!1;for(c=s;0!==c--;)if(e[c]!==t[c])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((s=(u=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(c=s;0!==c--;)if(!Object.prototype.hasOwnProperty.call(t,u[c]))return!1;if(n&&e instanceof Element)return!1;for(c=s;0!==c--;)if(("_owner"!==u[c]&&"__v"!==u[c]&&"__o"!==u[c]||!e.$$typeof)&&!o(e[u[c]],t[u[c]]))return!1;return!0}return e!==e&&t!==t}e.exports=function(e,t){try{return o(e,t)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}}},function(e,t,n){"use strict";function r(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";function r(e){if(Array.isArray(e))return e}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";function r(e){for(var t="https://material-ui.com/production-error/?code="+e,n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=t.pulsate,a=void 0!==r&&r,i=t.center,s=void 0===i?o||t.pulsate:i,c=t.fakeElement,u=void 0!==c&&c;if("mousedown"===e.type&&m.current)m.current=!1;else{"touchstart"===e.type&&(m.current=!0);var l,d,f,p=u?null:y.current,h=p?p.getBoundingClientRect():{width:0,height:0,left:0,top:0};if(s||0===e.clientX&&0===e.clientY||!e.clientX&&!e.touches)l=Math.round(h.width/2),d=Math.round(h.height/2);else{var b=e.touches?e.touches[0]:e,x=b.clientX,k=b.clientY;l=Math.round(x-h.left),d=Math.round(k-h.top)}if(s)(f=Math.sqrt((2*Math.pow(h.width,2)+Math.pow(h.height,2))/3))%2===0&&(f+=1);else{var w=2*Math.max(Math.abs((p?p.clientWidth:0)-l),l)+2,j=2*Math.max(Math.abs((p?p.clientHeight:0)-d),d)+2;f=Math.sqrt(Math.pow(w,2)+Math.pow(j,2))}e.touches?null===g.current&&(g.current=function(){O({pulsate:a,rippleX:l,rippleY:d,rippleSize:f,cb:n})},v.current=setTimeout((function(){g.current&&(g.current(),g.current=null)}),80)):O({pulsate:a,rippleX:l,rippleY:d,rippleSize:f,cb:n})}}),[o,O]),w=i.useCallback((function(){x({},{pulsate:!0})}),[x]),j=i.useCallback((function(e,t){if(clearTimeout(v.current),"touchend"===e.type&&g.current)return e.persist(),g.current(),g.current=null,void(v.current=setTimeout((function(){j(e,t)})));g.current=null,p((function(e){return e.length>0?e.slice(1):e})),b.current=t}),[]);return i.useImperativeHandle(t,(function(){return{pulsate:w,start:x,stop:j}}),[w,x,j]),i.createElement("span",Object(r.a)({className:Object(c.a)(s.root,u),ref:y},l),i.createElement(R,{component:null,exit:!0},f))})),M=Object(d.a)((function(e){return{root:{overflow:"hidden",pointerEvents:"none",position:"absolute",zIndex:0,top:0,right:0,bottom:0,left:0,borderRadius:"inherit"},ripple:{opacity:0,position:"absolute"},rippleVisible:{opacity:.3,transform:"scale(1)",animation:"$enter ".concat(550,"ms ").concat(e.transitions.easing.easeInOut)},ripplePulsate:{animationDuration:"".concat(e.transitions.duration.shorter,"ms")},child:{opacity:1,display:"block",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:"currentColor"},childLeaving:{opacity:0,animation:"$exit ".concat(550,"ms ").concat(e.transitions.easing.easeInOut)},childPulsate:{position:"absolute",left:0,top:0,animation:"$pulsate 2500ms ".concat(e.transitions.easing.easeInOut," 200ms infinite")},"@keyframes enter":{"0%":{transform:"scale(0)",opacity:.1},"100%":{transform:"scale(1)",opacity:.3}},"@keyframes exit":{"0%":{opacity:1},"100%":{opacity:0}},"@keyframes pulsate":{"0%":{transform:"scale(1)"},"50%":{transform:"scale(0.92)"},"100%":{transform:"scale(1)"}}}}),{flip:!1,name:"MuiTouchRipple"})(i.memo(_)),z=i.forwardRef((function(e,t){var n=e.action,o=e.buttonRef,d=e.centerRipple,f=void 0!==d&&d,p=e.children,h=e.classes,b=e.className,m=e.component,v=void 0===m?"button":m,g=e.disabled,y=void 0!==g&&g,O=e.disableRipple,k=void 0!==O&&O,w=e.disableTouchRipple,j=void 0!==w&&w,S=e.focusRipple,N=void 0!==S&&S,I=e.focusVisibleClassName,C=e.onBlur,T=e.onClick,E=e.onFocus,A=e.onFocusVisible,R=e.onKeyDown,F=e.onKeyUp,D=e.onMouseDown,_=e.onMouseLeave,z=e.onMouseUp,L=e.onTouchEnd,P=e.onTouchMove,B=e.onTouchStart,W=e.onDragLeave,U=e.tabIndex,V=void 0===U?0:U,H=e.TouchRippleProps,G=e.type,q=void 0===G?"button":G,K=Object(a.a)(e,["action","buttonRef","centerRipple","children","classes","className","component","disabled","disableRipple","disableTouchRipple","focusRipple","focusVisibleClassName","onBlur","onClick","onFocus","onFocusVisible","onKeyDown","onKeyUp","onMouseDown","onMouseLeave","onMouseUp","onTouchEnd","onTouchMove","onTouchStart","onDragLeave","tabIndex","TouchRippleProps","type"]),X=i.useRef(null);var Y=i.useRef(null),$=i.useState(!1),Q=$[0],Z=$[1];y&&Q&&Z(!1);var J=x(),ee=J.isFocusVisible,te=J.onBlurVisible,ne=J.ref;function re(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:j;return Object(l.a)((function(r){return t&&t(r),!n&&Y.current&&Y.current[e](r),!0}))}i.useImperativeHandle(n,(function(){return{focusVisible:function(){Z(!0),X.current.focus()}}}),[]),i.useEffect((function(){Q&&N&&!k&&Y.current.pulsate()}),[k,N,Q]);var ae=re("start",D),ie=re("stop",W),oe=re("stop",z),se=re("stop",(function(e){Q&&e.preventDefault(),_&&_(e)})),ce=re("start",B),ue=re("stop",L),le=re("stop",P),de=re("stop",(function(e){Q&&(te(e),Z(!1)),C&&C(e)}),!1),fe=Object(l.a)((function(e){X.current||(X.current=e.currentTarget),ee(e)&&(Z(!0),A&&A(e)),E&&E(e)})),pe=function(){var e=s.findDOMNode(X.current);return v&&"button"!==v&&!("A"===e.tagName&&e.href)},he=i.useRef(!1),be=Object(l.a)((function(e){N&&!he.current&&Q&&Y.current&&" "===e.key&&(he.current=!0,e.persist(),Y.current.stop(e,(function(){Y.current.start(e)}))),e.target===e.currentTarget&&pe()&&" "===e.key&&e.preventDefault(),R&&R(e),e.target===e.currentTarget&&pe()&&"Enter"===e.key&&!y&&(e.preventDefault(),T&&T(e))})),me=Object(l.a)((function(e){N&&" "===e.key&&Y.current&&Q&&!e.defaultPrevented&&(he.current=!1,e.persist(),Y.current.stop(e,(function(){Y.current.pulsate(e)}))),F&&F(e),T&&e.target===e.currentTarget&&pe()&&" "===e.key&&!e.defaultPrevented&&T(e)})),ve=v;"button"===ve&&K.href&&(ve="a");var ge={};"button"===ve?(ge.type=q,ge.disabled=y):("a"===ve&&K.href||(ge.role="button"),ge["aria-disabled"]=y);var ye=Object(u.a)(o,t),Oe=Object(u.a)(ne,X),xe=Object(u.a)(ye,Oe),ke=i.useState(!1),we=ke[0],je=ke[1];i.useEffect((function(){je(!0)}),[]);var Se=we&&!k&&!y;return i.createElement(ve,Object(r.a)({className:Object(c.a)(h.root,b,Q&&[h.focusVisible,I],y&&h.disabled),onBlur:de,onClick:T,onFocus:fe,onKeyDown:be,onKeyUp:me,onMouseDown:ae,onMouseLeave:se,onMouseUp:oe,onDragLeave:ie,onTouchEnd:ue,onTouchMove:le,onTouchStart:ce,ref:xe,tabIndex:y?-1:V},ge,K),p,Se?i.createElement(M,Object(r.a)({ref:Y,center:f},H)):null)}));t.a=Object(d.a)({root:{display:"inline-flex",alignItems:"center",justifyContent:"center",position:"relative",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle","-moz-appearance":"none","-webkit-appearance":"none",textDecoration:"none",color:"inherit","&::-moz-focus-inner":{borderStyle:"none"},"&$disabled":{pointerEvents:"none",cursor:"default"},"@media print":{colorAdjust:"exact"}},disabled:{},focusVisible:{}},{name:"MuiButtonBase"})(z)},,,,,,,,,,,function(e,t,n){"use strict";var r=n(177),a=60103,i=60106;t.Fragment=60107,t.StrictMode=60108,t.Profiler=60114;var o=60109,s=60110,c=60112;t.Suspense=60113;var u=60115,l=60116;if("function"===typeof Symbol&&Symbol.for){var d=Symbol.for;a=d("react.element"),i=d("react.portal"),t.Fragment=d("react.fragment"),t.StrictMode=d("react.strict_mode"),t.Profiler=d("react.profiler"),o=d("react.provider"),s=d("react.context"),c=d("react.forward_ref"),t.Suspense=d("react.suspense"),u=d("react.memo"),l=d("react.lazy")}var f="function"===typeof Symbol&&Symbol.iterator;function p(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n