UNPKG

danfojs

Version:

JavaScript library providing high performance, intuitive, and easy to use data structures for manipulating and processing structured data.

5 lines 6.23 MB
var ese=Object.create;var rL=Object.defineProperty;var tse=Object.getOwnPropertyDescriptor;var rse=Object.getOwnPropertyNames;var nse=Object.getPrototypeOf,ase=Object.prototype.hasOwnProperty;var Tb=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var ri=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ise=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of rse(t))!ase.call(e,a)&&a!==r&&rL(e,a,{get:()=>t[a],enumerable:!(n=tse(t,a))||n.enumerable});return e};var km=(e,t,r)=>(r=e!=null?ese(nse(e)):{},ise(t||!e||!e.__esModule?rL(r,"default",{value:e,enumerable:!0}):r,e));var r3=ri(()=>{});var nL=ri(()=>{});var aL=ri(()=>{});var Gm=ri(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});var ose=r3();function sse(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var lse=sse(ose);var t4=function(e,t){return t4=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var a in n)n.hasOwnProperty(a)&&(r[a]=n[a])},t4(e,t)};function y0(e,t){t4(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function xi(e,t,r,n){function a(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function i(c){try{u(n.next(c))}catch(f){s(f)}}function l(c){try{u(n.throw(c))}catch(f){s(f)}}function u(c){c.done?o(c.value):a(c.value).then(i,l)}u((n=n.apply(e,t||[])).next())})}function bi(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,a,o,s;return s={next:i(0),throw:i(1),return:i(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(u){return function(c){return l([u,c])}}function l(u){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,a&&(o=u[0]&2?a.return:u[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,u[1])).done)return o;switch(a=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,a=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){r.label=u[1];break}if(u[0]===6&&r.label<o[1]){r.label=o[1],o=u;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(u);break}o[2]&&r.ops.pop(),r.trys.pop();continue}u=t.call(e,r)}catch(c){u=[6,c],a=0}finally{n=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Qf(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function hi(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),a,o=[],s;try{for(;(t===void 0||t-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(i){s={error:i}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o}function ys(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(hi(arguments[t]));return e}var use=1e-7,cse=1e-4,fse=function(){function e(t,r){this.backend=t,this.dataMover=r,this.data=new WeakMap,this.dataIdsCount=0}return e.prototype.get=function(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t)},e.prototype.set=function(t,r){this.dataIdsCount++,this.data.set(t,r)},e.prototype.has=function(t){return this.data.has(t)},e.prototype.delete=function(t){return this.dataIdsCount--,this.data.delete(t)},e.prototype.numDataIds=function(){return this.dataIdsCount},e}(),TL=function(){function e(){}return e.prototype.refCount=function(t){return Ah("refCount")},e.prototype.incRef=function(t){return Ah("incRef")},e.prototype.timerAvailable=function(){return!0},e.prototype.time=function(t){return Ah("time")},e.prototype.read=function(t){return Ah("read")},e.prototype.readSync=function(t){return Ah("readSync")},e.prototype.readToGPU=function(t,r){return Ah("readToGPU")},e.prototype.numDataIds=function(){return Ah("numDataIds")},e.prototype.disposeData=function(t,r){return Ah("disposeData")},e.prototype.write=function(t,r,n){return Ah("write")},e.prototype.move=function(t,r,n,a,o){return Ah("move")},e.prototype.memory=function(){return Ah("memory")},e.prototype.floatPrecision=function(){return Ah("floatPrecision")},e.prototype.epsilon=function(){return this.floatPrecision()===32?use:cse},e.prototype.dispose=function(){return Ah("dispose")},e}();function Ah(e){throw new Error("'"+e+"' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen")}function AL(e){for(var t=e.length,r=0;t>0;)r=Math.random()*t|0,t--,s3(e,t,r)}function hse(e,t){if(e.length!==t.length)throw new Error("Array sizes must match to be shuffled together "+("First array length was "+e.length)+("Second array length was "+t.length));for(var r=e.length,n=0;r>0;)n=Math.random()*r|0,r--,s3(e,r,n),s3(t,r,n)}function Nb(e,t,r){return Math.max(e,Math.min(t,r))}function pse(e){return e%2===0?e:e+1}function s3(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function dse(e){for(var t=0,r=0;r<e.length;r++)t+=e[r];return t}function vse(e,t){var r=Math.random();return t*r+(1-r)*e}function mse(e,t){for(var r=0,n=0;n<e.length;n++){var a=Number(e[n])-Number(t[n]);r+=a*a}return r}function Dr(e,t){if(!e)throw new Error(typeof t=="string"?t:t())}function nf(e,t,r){r===void 0&&(r=""),Dr(mv(e,t),function(){return r+(" Shapes "+e+" and "+t+" must match")})}function Bm(e){Dr(e!=null,function(){return"The input to the tensor constructor must be a non-null value."})}function Fm(e,t,r){if(t===void 0&&(t=[]),r===void 0&&(r=!1),t==null&&(t=[]),Array.isArray(e)||Gc(e)&&!r)for(var n=0;n<e.length;++n)Fm(e[n],t,r);else t.push(e);return t}function Ml(e){if(e.length===0)return 1;for(var t=e[0],r=1;r<e.length;r++)t*=e[r];return t}function gse(e){return e.length===0}function mv(e,t){if(e===t)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function Q1(e){return e%1===0}function yse(e){if(Math.tanh!=null)return Math.tanh(e);if(e===1/0)return 1;if(e===-1/0)return-1;var t=Math.exp(2*e);return(t-1)/(t+1)}function xse(e){var t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function bse(e){for(var t=new Uint32Array(e),r=0;r<e;++r)t[r]=r;return AL(t),t}function Cb(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function _se(e,t,r){return t===void 0&&(t=function(n){return 0}),new Promise(function(n,a){var o=0,s=function(){if(e()){n();return}o++;var i=t(o);if(r!=null&&o>=r){a();return}setTimeout(s,i)};s()})}function wse(e,t){for(var r=1,n=-1,a=0;a<e.length;++a)if(e[a]>=0)r*=e[a];else if(e[a]===-1){if(n!==-1)throw Error("Shapes can only have 1 implicit size. "+("Found -1 at dim "+n+" and dim "+a));n=a}else if(e[a]<0)throw Error("Shapes can not be < 0. Found "+e[a]+" at dim "+a);if(n===-1){if(t>0&&t!==r)throw Error("Size("+t+") must match the product of shape "+e);return e}if(r===0)throw Error("Cannot infer the missing size in ["+e+"] when there are 0 elements");if(t%r!==0)throw Error("The implicit shape can't be a fractional number. "+("Got "+t+" / "+r));var o=e.slice();return o[n]=t/r,o}function Wb(e,t){var r=t.length;return e=e==null?t.map(function(n,a){return a}):[].concat(e),Dr(e.every(function(n){return n>=-r&&n<r}),function(){return"All values in axis param must be in range [-"+r+", "+r+") but "+("got axis "+e)}),Dr(e.every(function(n){return Q1(n)}),function(){return"All values in axis param must be integers but "+("got axis "+e)}),e.map(function(n){return n<0?r+n:n})}function SL(e,t){for(var r=[],n=[],a=t!=null&&Array.isArray(t)&&t.length===0,o=t==null||a?null:Wb(t,e).sort(),s=0,i=0;i<e.length;++i){if(o!=null){if(o[s]===i&&e[i]!==1)throw new Error("Can't squeeze axis "+i+" since its dim '"+e[i]+"' is not 1");(o[s]==null||o[s]>i)&&e[i]===1&&(r.push(e[i]),n.push(i)),o[s]<=i&&s++}e[i]!==1&&(r.push(e[i]),n.push(i))}return{newShape:r,keptDims:n}}function EL(e,t){var r=null;if(e==null||e==="float32")r=new Float32Array(t);else if(e==="int32")r=new Int32Array(t);else if(e==="bool")r=new Uint8Array(t);else throw new Error("Unknown data type "+e);return r}function DL(e,t){var r=null;if(e==null||e==="float32")r=new Float32Array(t);else if(e==="int32")r=new Int32Array(t);else if(e==="bool")r=new Uint8Array(t);else if(e==="string")r=new Array(t);else throw new Error("Unknown data type "+e);return r}function CL(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(isNaN(n)||!isFinite(n))throw Error("A tensor of type "+t+" being uploaded contains "+n+".")}}function ML(e){return e==="bool"||e==="complex64"||e==="float32"||e==="int32"||e==="string"}function kse(e,t){return!(t==="complex64"||t==="float32"&&e!=="complex64"||t==="int32"&&e!=="float32"&&e!=="complex64"||t==="bool"&&e==="bool")}function Gc(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function r4(e){if(e==="float32"||e==="int32")return 4;if(e==="complex64")return 8;if(e==="bool")return 1;throw new Error("Unknown dtype "+e)}function IL(e){if(e==null)return 0;var t=0;return e.forEach(function(r){return t+=r.length}),t}function cv(e){return typeof e=="string"||e instanceof String}function NL(e){return typeof e=="boolean"}function FL(e){return typeof e=="number"}function w3(e){return Array.isArray(e)?w3(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":FL(e)?"float32":cv(e)?"string":NL(e)?"bool":"float32"}function dv(e){return!!(e&&e.constructor&&e.call&&e.apply)}function l3(e,t){for(var r=t;r<e;++r)if(e%r===0)return r;return e}function ay(e){var t=e.length;if(t<2)return[];var r=new Array(t-1);r[t-2]=e[t-1];for(var n=t-3;n>=0;--n)r[n]=r[n+1]*e[n+1];return r}function OL(e,t,r,n){n===void 0&&(n=!1);var a=new Array;if(t.length===1)for(var o=t[0]*(n?2:1),s=0;s<o;s++)a[s]=r[e+s];else for(var o=t[0],i=t.slice(1),l=i.reduce(function(c,f){return c*f})*(n?2:1),s=0;s<o;s++)a[s]=OL(e+s*l,i,r,n);return a}function q1(e,t,r){if(r===void 0&&(r=!1),e.length===0)return t[0];var n=e.reduce(function(a,o){return a*o})*(r?2:1);if(n===0)return[];if(n!==t.length)throw new Error("["+e+"] does not match the input size "+t.length+(r?" for a complex tensor":"")+".");return OL(0,e,t,r)}function E4(e,t){for(var r=k3(e,t),n=0;n<r.length;n++)r[n]=1;return r}function k3(e,t){if(t==null||t==="float32"||t==="complex64")return new Float32Array(e);if(t==="int32")return new Int32Array(e);if(t==="bool")return new Uint8Array(e);throw new Error("Unknown data type "+t)}function Tse(e,t){var r=e.reduce(function(n,a){return n*a},1);if(t==null||t==="float32")return q1(e,new Float32Array(r));if(t==="int32")return q1(e,new Int32Array(r));if(t==="bool")return q1(e,new Uint8Array(r));throw new Error("Unknown data type "+t)}function D4(e){e.forEach(function(t){Dr(Number.isInteger(t)&&t>=0,function(){return"Tensor must have a shape comprised of positive integers but got "+("shape ["+e+"].")})})}function Ase(e,t,r){if(t===0)return 0;if(t===1)return e[0];for(var n=e[e.length-1],a=0;a<e.length-1;++a)n+=r[a]*e[a];return n}function Sse(e,t,r){if(t===0)return[];if(t===1)return[e];for(var n=new Array(t),a=0;a<n.length-1;++a)n[a]=Math.floor(e/r[a]),e-=n[a]*r[a];return n[n.length-1]=e,n}function C4(e){return e&&e.then&&typeof e.then=="function"}var iL="tfjsflags",PL=function(){function e(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Ese,this.populateURLFlags()}return e.prototype.setPlatform=function(t,r){this.platform!=null&&(So().getBool("IS_TEST")||So().getBool("PROD")||console.warn("Platform "+this.platformName+" has already been set. "+("Overwriting the platform with "+r+"."))),this.platformName=t,this.platform=r},e.prototype.registerFlag=function(t,r,n){if(this.flagRegistry[t]={evaluationFn:r,setHook:n},this.urlFlags[t]!=null){var a=this.urlFlags[t];So().getBool("IS_TEST")||So().getBool("PROD")||console.warn("Setting feature override from URL "+t+": "+a+"."),this.set(t,a)}},e.prototype.getAsync=function(t){return xi(this,void 0,void 0,function(){var r,n;return bi(this,function(a){switch(a.label){case 0:return t in this.flags?[2,this.flags[t]]:(r=this.flags,n=t,[4,this.evaluateFlag(t)]);case 1:return r[n]=a.sent(),[2,this.flags[t]]}})})},e.prototype.get=function(t){if(t in this.flags)return this.flags[t];var r=this.evaluateFlag(t);if(C4(r))throw new Error("Flag "+t+" cannot be synchronously evaluated. Please use getAsync() instead.");return this.flags[t]=r,this.flags[t]},e.prototype.getNumber=function(t){return this.get(t)},e.prototype.getBool=function(t){return this.get(t)},e.prototype.getFlags=function(){return this.flags},Object.defineProperty(e.prototype,"features",{get:function(){return this.flags},enumerable:!0,configurable:!0}),e.prototype.set=function(t,r){if(this.flagRegistry[t]==null)throw new Error("Cannot set flag "+t+" as it has not been registered.");this.flags[t]=r,this.flagRegistry[t].setHook!=null&&this.flagRegistry[t].setHook(r)},e.prototype.evaluateFlag=function(t){if(this.flagRegistry[t]==null)throw new Error("Cannot evaluate flag '"+t+"': no evaluation function found.");return this.flagRegistry[t].evaluationFn()},e.prototype.setFlags=function(t){this.flags=Object.assign({},t)},e.prototype.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags()},e.prototype.populateURLFlags=function(){var t=this;if(!(typeof this.global>"u"||typeof this.global.location>"u"||typeof this.global.location.search>"u")){var r=this.getQueryParams(this.global.location.search);if(iL in r){var n=r[iL].split(",");n.forEach(function(a){var o=hi(a.split(":"),2),s=o[0],i=o[1];t.urlFlags[s]=Cse(s,i)})}}},e}();function Ese(e){var t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,function(r){for(var n=[],a=1;a<arguments.length;a++)n[a-1]=arguments[a];return Dse(t,n[0],n[1]),n.join("=")}),t}function Dse(e,t,r){e[decodeURIComponent(t)]=decodeURIComponent(r||"")}function Cse(e,t){if(t=t.toLowerCase(),t==="true"||t==="false")return t==="true";if(""+ +t===t)return+t;throw new Error("Could not parse value flag value "+t+" for flag "+e+".")}function So(){return Gt.ENV}Gt.ENV=null;function Mse(e){Gt.ENV=e}var KE;function LL(){if(KE==null){var e=void 0;if(typeof window<"u")e=window;else if(typeof global<"u")e=global;else if(typeof process<"u")e=process;else if(typeof self<"u")e=self;else throw new Error("Could not find a global object");KE=e}return KE}function Ise(){var e=LL();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function M4(e,t){var r=Ise();if(r.has(e))return r.get(e);var n=t();return r.set(e,n),r.get(e)}var RL="Abs",zL="Acos",BL="Acosh",I4="Add",UL="AddN",VL="All",jL="Any",WL="ArgMax",GL="ArgMin",$L="Asin",HL="Asinh",qL="Atan",XL="Atanh",KL="Atan2",YL="AvgPool",Nse="AvgPoolGrad",ZL="AvgPool3D",Fse="AvgPool3DGrad",JL="BatchMatMul",QL="BatchToSpaceND",eR="Bincount",Ose="BroadcastTo",tR="BroadcastArgs",N4="Cast",rR="Ceil",nR="ClipByValue",aR="Complex",iR="ComplexAbs",oR="Concat",sR="Conv2D",lR="Conv2DBackpropFilter",uR="Conv2DBackpropInput",cR="Conv3D",Pse="Conv3DBackpropFilterV2",fR="Conv3DBackpropInputV2",hR="Cos",pR="Cosh",dR="Cumsum",vR="CropAndResize",mR="DenseBincount",gR="DepthToSpace",yR="DepthwiseConv2dNative",xR="DepthwiseConv2dNativeBackpropFilter",bR="DepthwiseConv2dNativeBackpropInput",_R="Diag",wR="Dilation2D",Lse="Dilation2DBackpropInput",Rse="Dilation2DBackpropFilter",kR="RealDiv",TR="Einsum",AR="Elu",zse="EluGrad",SR="Erf",ER="Equal",DR="Exp",CR="ExpandDims",MR="Expm1",IR="FFT",NR="Fill",FR="FlipLeftRight",OR="Floor",PR="FloorDiv",LR="FusedBatchNorm",RR="GatherV2",zR="GatherNd",BR="Greater",UR="GreaterEqual",F4="Identity",VR="IFFT",jR="Imag",WR="IsFinite",GR="IsInf",$R="IsNan",HR="LeakyRelu",qR="Less",XR="LessEqual",KR="LinSpace",YR="Log",ZR="Log1p",JR="LogicalAnd",QR="LogicalNot",e7="LogicalOr",Bse="LogSoftmax",t7="LRN",Use="LRNGrad",r7="Max",n7="Maximum",a7="MaxPool",Vse="MaxPoolGrad",i7="MaxPool3D",jse="MaxPool3DGrad",o7="MaxPoolWithArgmax",s7="Mean",l7="Min",u7="Minimum",c7="MirrorPad",f7="Mod",h7="Multinomial",p7="Multiply",d7="Neg",v7="NotEqual",m7="NonMaxSuppressionV3",g7="NonMaxSuppressionV4",y7="NonMaxSuppressionV5",x7="OnesLike",b7="OneHot",_7="Pack",w7="PadV2",Wse="Pool",k7="Pow",T7="Prelu",A7="Prod",S7="Range",E7="Real",D7="Reciprocal",C7="Relu",M7="Reshape",I7="ResizeNearestNeighbor",Gse="ResizeNearestNeighborGrad",N7="ResizeBilinear",$se="ResizeBilinearGrad",F7="Relu6",O7="Reverse",P7="Round",L7="Rsqrt",R7="ScatterNd",z7="Select",B7="Selu",U7="Slice",V7="Sin",j7="Sinh",W7="Sign",G7="Sigmoid",$7="Softplus",H7="Sqrt",q7="Sum",X7="SpaceToBatchND",K7="SplitV",Y7="Softmax",Z7="SparseFillEmptyRows",J7="SparseReshape",Q7="SparseSegmentMean",e9="SparseSegmentSum",t9="SparseToDense",r9="SquaredDifference",Hse="Square",n9="StridedSlice",a9="StringNGrams",i9="StringSplit",o9="StringToHashBucketFast",s9="Sub",l9="Tan",u9="Tanh",O4="Tile",c9="TopK",f9="Transform",h9="Transpose",p9="Unique",d9="Unpack",v9="UnsortedSegmentSum",m9="ZerosLike",g9="Step",n4="FromPixels",y9="RotateWithOffset",a4="_FusedMatMul",i4="FusedConv2D",o4="FusedDepthwiseConv2D";function uv(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];So().getBool("IS_TEST")||So().getBool("PROD")||console.warn.apply(console,ys(e))}function qse(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];So().getBool("IS_TEST")||So().getBool("PROD")||console.log.apply(console,ys(e))}var ey=M4("kernelRegistry",function(){return new Map}),Fb=M4("gradRegistry",function(){return new Map});function u3(e,t){var r=P4(e,t);return ey.get(r)}function s4(e){return Fb.get(e)}function c3(e){for(var t=ey.entries(),r=[];;){var n=t.next(),a=n.done,o=n.value;if(a)break;var s=hi(o,2),i=s[0],l=s[1],u=hi(i.split("_"),1),c=u[0];c===e&&r.push(l)}return r}function x9(e){var t=e.kernelName,r=e.backendName,n=P4(t,r);ey.has(n)&&uv("The kernel '"+t+"' for backend "+("'"+r+"' is already registered")),ey.set(n,e)}function Xse(e){var t=e.kernelName;Fb.has(t)&&So().getBool("DEBUG")&&uv("Overriding the gradient for '"+t+"'"),Fb.set(t,e)}function Kse(e,t){var r=P4(e,t);if(!ey.has(r))throw new Error("The kernel '"+e+"' for backend "+("'"+t+"' is not registered"));ey.delete(r)}function Yse(e){if(!Fb.has(e))throw new Error("The gradient '"+e+"' for backend is not registered");Fb.delete(e)}function Zse(e,t){var r=c3(e);r.forEach(function(n){var a=Object.assign({},n,{backendName:t});x9(a)})}function P4(e,t){return t+"_"+e}var l4=fl,Qh=null;try{Qh=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{}function fl(e,t,r){this.low=e|0,this.high=t|0,this.unsigned=!!r}fl.prototype.__isLong__;Object.defineProperty(fl.prototype,"__isLong__",{value:!0});function th(e){return(e&&e.__isLong__)===!0}fl.isLong=th;var oL={},sL={};function Um(e,t){var r,n,a;return t?(e>>>=0,(a=0<=e&&e<256)&&(n=sL[e],n)?n:(r=hl(e,(e|0)<0?-1:0,!0),a&&(sL[e]=r),r)):(e|=0,(a=-128<=e&&e<128)&&(n=oL[e],n)?n:(r=hl(e,e<0?-1:0,!1),a&&(oL[e]=r),r))}fl.fromInt=Um;function ep(e,t){if(isNaN(e))return t?Dm:tp;if(t){if(e<0)return Dm;if(e>=b9)return k9}else{if(e<=-uL)return Jf;if(e+1>=uL)return w9}return e<0?ep(-e,t).neg():hl(e%ty|0,e/ty|0,t)}fl.fromNumber=ep;function hl(e,t,r){return new fl(e,t,r)}fl.fromBits=hl;var f3=Math.pow;function L4(e,t,r){if(e.length===0)throw Error("empty string");if(e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return tp;if(typeof t=="number"?(r=t,t=!1):t=!!t,r=r||10,r<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(n===0)return L4(e.substring(1),t,r).neg();for(var a=ep(f3(r,8)),o=tp,s=0;s<e.length;s+=8){var i=Math.min(8,e.length-s),l=parseInt(e.substring(s,s+i),r);if(i<8){var u=ep(f3(r,i));o=o.mul(u).add(ep(l))}else o=o.mul(a),o=o.add(ep(l))}return o.unsigned=t,o}fl.fromString=L4;function Jp(e,t){return typeof e=="number"?ep(e,t):typeof e=="string"?L4(e,t):hl(e.low,e.high,typeof t=="boolean"?t:e.unsigned)}fl.fromValue=Jp;var lL=1<<16,Jse=1<<24,ty=lL*lL,b9=ty*ty,uL=b9/2,cL=Um(Jse),tp=Um(0);fl.ZERO=tp;var Dm=Um(0,!0);fl.UZERO=Dm;var H1=Um(1);fl.ONE=H1;var _9=Um(1,!0);fl.UONE=_9;var u4=Um(-1);fl.NEG_ONE=u4;var w9=hl(-1,2147483647,!1);fl.MAX_VALUE=w9;var k9=hl(-1,-1,!0);fl.MAX_UNSIGNED_VALUE=k9;var Jf=hl(0,-2147483648,!1);fl.MIN_VALUE=Jf;var za=fl.prototype;za.toInt=function(){return this.unsigned?this.low>>>0:this.low};za.toNumber=function(){return this.unsigned?(this.high>>>0)*ty+(this.low>>>0):this.high*ty+(this.low>>>0)};za.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Jf)){var r=ep(t),n=this.div(r),a=n.mul(r).sub(this);return n.toString(t)+a.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var o=ep(f3(t,6),this.unsigned),s=this,i="";;){var l=s.div(o),u=s.sub(l.mul(o)).toInt()>>>0,c=u.toString(t);if(s=l,s.isZero())return c+i;for(;c.length<6;)c="0"+c;i=""+c+i}};za.getHighBits=function(){return this.high};za.getHighBitsUnsigned=function(){return this.high>>>0};za.getLowBits=function(){return this.low};za.getLowBitsUnsigned=function(){return this.low>>>0};za.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Jf)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,r=31;r>0&&(t&1<<r)==0;r--);return this.high!=0?r+33:r+1};za.isZero=function(){return this.high===0&&this.low===0};za.eqz=za.isZero;za.isNegative=function(){return!this.unsigned&&this.high<0};za.isPositive=function(){return this.unsigned||this.high>=0};za.isOdd=function(){return(this.low&1)===1};za.isEven=function(){return(this.low&1)===0};za.equals=function(t){return th(t)||(t=Jp(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};za.eq=za.equals;za.notEquals=function(t){return!this.eq(t)};za.neq=za.notEquals;za.ne=za.notEquals;za.lessThan=function(t){return this.comp(t)<0};za.lt=za.lessThan;za.lessThanOrEqual=function(t){return this.comp(t)<=0};za.lte=za.lessThanOrEqual;za.le=za.lessThanOrEqual;za.greaterThan=function(t){return this.comp(t)>0};za.gt=za.greaterThan;za.greaterThanOrEqual=function(t){return this.comp(t)>=0};za.gte=za.greaterThanOrEqual;za.ge=za.greaterThanOrEqual;za.compare=function(t){if(th(t)||(t=Jp(t)),this.eq(t))return 0;var r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};za.comp=za.compare;za.negate=function(){return!this.unsigned&&this.eq(Jf)?Jf:this.not().add(H1)};za.neg=za.negate;za.add=function(t){th(t)||(t=Jp(t));var r=this.high>>>16,n=this.high&65535,a=this.low>>>16,o=this.low&65535,s=t.high>>>16,i=t.high&65535,l=t.low>>>16,u=t.low&65535,c=0,f=0,h=0,p=0;return p+=o+u,h+=p>>>16,p&=65535,h+=a+l,f+=h>>>16,h&=65535,f+=n+i,c+=f>>>16,f&=65535,c+=r+s,c&=65535,hl(h<<16|p,c<<16|f,this.unsigned)};za.subtract=function(t){return th(t)||(t=Jp(t)),this.add(t.neg())};za.sub=za.subtract;za.multiply=function(t){if(this.isZero())return tp;if(th(t)||(t=Jp(t)),Qh){var r=Qh.mul(this.low,this.high,t.low,t.high);return hl(r,Qh.get_high(),this.unsigned)}if(t.isZero())return tp;if(this.eq(Jf))return t.isOdd()?Jf:tp;if(t.eq(Jf))return this.isOdd()?Jf:tp;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(cL)&&t.lt(cL))return ep(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,a=this.high&65535,o=this.low>>>16,s=this.low&65535,i=t.high>>>16,l=t.high&65535,u=t.low>>>16,c=t.low&65535,f=0,h=0,p=0,d=0;return d+=s*c,p+=d>>>16,d&=65535,p+=o*c,h+=p>>>16,p&=65535,p+=s*u,h+=p>>>16,p&=65535,h+=a*c,f+=h>>>16,h&=65535,h+=o*u,f+=h>>>16,h&=65535,h+=s*l,f+=h>>>16,h&=65535,f+=n*c+a*u+o*l+s*i,f&=65535,hl(p<<16|d,f<<16|h,this.unsigned)};za.mul=za.multiply;za.divide=function(t){if(th(t)||(t=Jp(t)),t.isZero())throw Error("division by zero");if(Qh){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var r=(this.unsigned?Qh.div_u:Qh.div_s)(this.low,this.high,t.low,t.high);return hl(r,Qh.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Dm:tp;var n,a,o;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Dm;if(t.gt(this.shru(1)))return _9;o=Dm}else{if(this.eq(Jf)){if(t.eq(H1)||t.eq(u4))return Jf;if(t.eq(Jf))return H1;var s=this.shr(1);return n=s.div(t).shl(1),n.eq(tp)?t.isNegative()?H1:u4:(a=this.sub(t.mul(n)),o=n.add(a.div(t)),o)}else if(t.eq(Jf))return this.unsigned?Dm:tp;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=tp}for(a=this;a.gte(t);){n=Math.max(1,Math.floor(a.toNumber()/t.toNumber()));for(var i=Math.ceil(Math.log(n)/Math.LN2),l=i<=48?1:f3(2,i-48),u=ep(n),c=u.mul(t);c.isNegative()||c.gt(a);)n-=l,u=ep(n,this.unsigned),c=u.mul(t);u.isZero()&&(u=H1),o=o.add(u),a=a.sub(c)}return o};za.div=za.divide;za.modulo=function(t){if(th(t)||(t=Jp(t)),Qh){var r=(this.unsigned?Qh.rem_u:Qh.rem_s)(this.low,this.high,t.low,t.high);return hl(r,Qh.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};za.mod=za.modulo;za.rem=za.modulo;za.not=function(){return hl(~this.low,~this.high,this.unsigned)};za.and=function(t){return th(t)||(t=Jp(t)),hl(this.low&t.low,this.high&t.high,this.unsigned)};za.or=function(t){return th(t)||(t=Jp(t)),hl(this.low|t.low,this.high|t.high,this.unsigned)};za.xor=function(t){return th(t)||(t=Jp(t)),hl(this.low^t.low,this.high^t.high,this.unsigned)};za.shiftLeft=function(t){return th(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?hl(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):hl(0,this.low<<t-32,this.unsigned)};za.shl=za.shiftLeft;za.shiftRight=function(t){return th(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?hl(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):hl(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};za.shr=za.shiftRight;za.shiftRightUnsigned=function(t){if(th(t)&&(t=t.toInt()),t&=63,t===0)return this;var r=this.high;if(t<32){var n=this.low;return hl(n>>>t|r<<32-t,r>>>t,this.unsigned)}else return t===32?hl(r,0,this.unsigned):hl(r>>>t-32,0,this.unsigned)};za.shru=za.shiftRightUnsigned;za.shr_u=za.shiftRightUnsigned;za.toSigned=function(){return this.unsigned?hl(this.low,this.high,!1):this};za.toUnsigned=function(){return this.unsigned?this:hl(this.low,this.high,!0)};za.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};za.toBytesLE=function(){var t=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};za.toBytesBE=function(){var t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};fl.fromBytes=function(t,r,n){return n?fl.fromBytesLE(t,r):fl.fromBytesBE(t,r)};fl.fromBytesLE=function(t,r){return new fl(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)};fl.fromBytesBE=function(t,r){return new fl(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)};var Qse=Object.assign(Object.create(null),l4,{default:l4}),Em=l4||Qse;function Gb(e){return Em.fromString(e,!0,16)}var T9=Gb("c3a5c85c97cb3127"),Am=Gb("b492b66fbe98f273"),rf=Gb("9ae16a3b2f90404f");function c4(e){return e.xor(e.shru(47))}function A9(e,t,r){var n=e.slice(t,t+r);return Em.fromBytes(Array.from(n),!0,!0)}function Js(e,t){return A9(e,t,8)}function fL(e,t){return A9(e,t,4)}function uc(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function hv(e,t,r){r===void 0&&(r=Gb("9ddfea08eb382d69"));var n=e.xor(t).mul(r);n=n.xor(n.shru(47));var a=t.xor(n).mul(r);return a=a.xor(a.shru(47)),a=a.mul(r),a}function ele(e,t,r,n,a,o){a=a.add(e),o=uc(o.add(a).add(n),21);var s=a;return a=a.add(t),a=a.add(r),o=o.add(uc(a,44)),[a.add(n),o.add(s)]}function n3(e,t,r,n){return ele(Js(e,t),Js(e,t+8),Js(e,t+16),Js(e,t+24),r,n)}function tle(e,t){if(t===void 0&&(t=e.length),t>=8){var r=rf.add(t*2),n=Js(e,0).add(rf),a=Js(e,t-8),o=uc(a,37).mul(r).add(n),s=uc(n,25).add(a).mul(r);return hv(o,s,r)}if(t>=4){var r=rf.add(t*2),n=fL(e,0);return hv(n.shl(3).add(t),fL(e,t-4),r)}if(t>0){var n=e[0],a=e[t>>1],o=e[t-1],i=n+(a<<8),l=t+(o<<2);return c4(rf.mul(i).xor(T9.mul(l))).mul(rf)}return rf}function rle(e,t){t===void 0&&(t=e.length);var r=rf.add(t*2),n=Js(e,0).mul(Am),a=Js(e,8),o=Js(e,t-8).mul(r),s=Js(e,t-16).mul(rf);return hv(uc(n.add(a),43).add(uc(o,30)).add(s),n.add(uc(a.add(rf),18)).add(o),r)}function nle(e,t){t===void 0&&(t=e.length);var r=rf.add(t*2),n=Js(e,0).mul(rf),a=Js(e,8),o=Js(e,t-8).mul(r),s=Js(e,t-16).mul(rf),i=uc(n.add(a),43).add(uc(o,30)).add(s),l=hv(i,n.add(uc(a.add(rf),18)).add(o),r),u=Js(e,16).mul(r),c=Js(e,24),f=i.add(Js(e,t-32)).mul(r),h=l.add(Js(e,t-24)).mul(r);return hv(uc(u.add(c),43).add(uc(f,30)).add(h),u.add(uc(c.add(n),18)).add(f),r)}function ale(e,t){var r,n;t===void 0&&(t=e.length);var a=Em.fromNumber(81,!0);if(t<=32)return t<=16?tle(e,t):rle(e,t);if(t<=64)return nle(e,t);var o=a,s=a.mul(Am).add(113),i=c4(s.mul(rf).add(113)).mul(rf),l=[Em.UZERO,Em.UZERO],u=[Em.UZERO,Em.UZERO];o=o.mul(rf).add(Js(e,0));var c=0,f=(t-1>>6)*64,h=f+(t-1&63)-63;do o=uc(o.add(s).add(l[0]).add(Js(e,c+8)),37).mul(Am),s=uc(s.add(l[1]).add(Js(e,c+48)),42).mul(Am),o=o.xor(u[1]),s=s.add(l[0]).add(Js(e,c+40)),i=uc(i.add(u[0]),33).mul(Am),l=n3(e,c,l[1].mul(Am),o.add(u[0])),u=n3(e,c+32,i.add(u[1]),s.add(Js(e,c+16))),r=hi([o,i],2),i=r[0],o=r[1],c+=64;while(c!==f);var p=Am.add(i.and(255).shl(1));return c=h,u[0]=u[0].add(t-1&63),l[0]=l[0].add(u[0]),u[0]=u[0].add(l[0]),o=uc(o.add(s).add(l[0]).add(Js(e,c+8)),37).mul(p),s=uc(s.add(l[1]).add(Js(e,c+48)),42).mul(p),o=o.xor(u[1].mul(9)),s=s.add(l[0].mul(9).add(Js(e,c+40))),i=uc(i.add(u[0]),33).mul(p),l=n3(e,c,l[1].mul(p),o.add(u[0])),u=n3(e,c+32,i.add(u[1]),s.add(Js(e,c+16))),n=hi([o,i],2),i=n[0],o=n[1],hv(hv(l[0],u[0],p).add(c4(s).mul(T9)).add(i),hv(l[1],u[1],p).add(o),p)}function ile(e,t){return t==="string"?$b(e):T3([e],t)}function ole(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function T3(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=Fm(e)),So().getBool("DEBUG")&&CL(e,t),ole(e,t))return e;if(t==null||t==="float32"||t==="complex64")return new Float32Array(e);if(t==="int32")return new Int32Array(e);if(t==="bool"){for(var r=new Uint8Array(e.length),n=0;n<r.length;++n)Math.round(e[n])!==0&&(r[n]=1);return r}else throw new Error("Unknown data type "+t)}function Ob(){return So().platform.now()}function sle(e,t){return So().platform.fetch(e,t)}function $b(e,t){return t===void 0&&(t="utf-8"),t=t||"utf-8",So().platform.encode(e,t)}function h3(e,t){return t===void 0&&(t="utf-8"),t=t||"utf-8",So().platform.decode(e,t)}var lle={__proto__:null,createScalarValue:ile,toTypedArray:T3,now:Ob,fetch:sle,encodeString:$b,decodeString:h3,shuffle:AL,shuffleCombo:hse,clamp:Nb,nearestLargerEven:pse,swap:s3,sum:dse,randUniform:vse,distSquared:mse,assert:Dr,assertShapesMatch:nf,assertNonNull:Bm,flatten:Fm,sizeFromShape:Ml,isScalarShape:gse,arraysEqual:mv,isInt:Q1,tanh:yse,sizeToSquarishShape:xse,createShuffledIndices:bse,rightPad:Cb,repeatedTry:_se,inferFromImplicitShape:wse,parseAxisParam:Wb,squeezeShape:SL,getTypedArrayFromDType:EL,getArrayFromDType:DL,checkConversionForErrors:CL,isValidDtype:ML,hasEncodingLoss:kse,isTypedArray:Gc,bytesPerElement:r4,bytesFromStringArray:IL,isString:cv,isBoolean:NL,isNumber:FL,inferDtype:w3,isFunction:dv,nearestDivisor:l3,computeStrides:ay,toNestedArray:q1,makeOnesTypedArray:E4,makeZerosTypedArray:k3,makeZerosNestedTypedArray:Tse,assertNonNegativeIntegerDimensions:D4,locToIndex:Ase,indexToLoc:Sse,isPromise:C4,hexToLong:Gb,fingerPrint64:ale},ule=function(){function e(t,r){this.backendTimer=t,this.logger=r,r==null&&(this.logger=new fle)}return e.prototype.profileKernel=function(t,r,n){var a,o,s,i=function(){s=n()},l,u=Ob();if(this.backendTimer.timerAvailable())l=this.backendTimer.time(i);else{i();try{for(var c=Qf(s),f=c.next();!f.done;f=c.next()){var h=f.value;h.dataSync()}}catch(m){a={error:m}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(a)throw a.error}}l=Promise.resolve({kernelMs:Ob()-u})}if(So().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(var p=function(m){var g=s[m];g.data().then(function(x){cle(x,g.dtype,t)})},d=0;d<s.length;d++)p(d);var v={kernelName:t,outputs:s,inputs:r,timeMs:l.then(function(m){return m.kernelMs}),extraInfo:l.then(function(m){return m.getExtraProfileInfo!=null?m.getExtraProfileInfo():""})};return v},e.prototype.logKernelProfile=function(t){var r=this,n=t.kernelName,a=t.outputs,o=t.timeMs,s=t.inputs,i=t.extraInfo;a.forEach(function(l){Promise.all([l.data(),o,i]).then(function(u){r.logger.logKernelProfile(n,l,u[0],u[1],s,u[2])})})},e}();function cle(e,t,r){if(t!=="float32")return!1;for(var n=0;n<e.length;n++){var a=e[n];if(isNaN(a)||!isFinite(a))return console.warn("Found "+a+" in the result of '"+r+"'"),!0}return!1}var fle=function(){function e(){}return e.prototype.logKernelProfile=function(t,r,n,a,o,s){var i=typeof a=="number"?Cb(a+"ms",9):a.error,l=Cb(t,25),u=r.rank,c=r.size,f=Cb(r.shape.toString(),14),h="";for(var p in o){var d=o[p];if(d!=null){var v=d.shape||r.shape,m=v.length;h+=p+": "+m+"D "+(m>0?v:"")+" "}}console.log("%c"+l+" %c"+i+" %c"+u+"D "+f+" %c"+c+" %c"+h+" %c"+s,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")},e}();function hle(e,t,r){for(var n={},a={},o=0;o<t.length;o++)n[t[o].id]=!0;for(var o=0;o<e.length;o++){var s=e[o],i=s.inputs;for(var l in i){for(var u=i[l],c=!1,f=0;f<t.length;f++)if(n[u.id]){s.outputs.forEach(function(b){return n[b.id]=!0}),c=!0,a[s.id]=!0;break}if(c)break}}var h={};h[r.id]=!0;for(var p={},o=e.length-1;o>=0;o--)for(var s=e[o],i=s.inputs,f=0;f<s.outputs.length;f++)if(h[s.outputs[f].id]){for(var l in i)h[i[l].id]=!0,p[s.id]=!0;break}for(var d=[],o=0;o<e.length;o++){var s=e[o];if(a[s.id]&&p[s.id]){var v={};for(var l in s.inputs){var m=s.inputs[l];n[m.id]&&(v[l]=m)}var g=Object.assign({},s);g.inputs=v,g.outputs=s.outputs,d.push(g)}}return d}function ple(e,t,r,n){for(var a=function(s){var i=t[s],l=[];if(i.outputs.forEach(function(h){var p=e[h.id];p!=null?l.push(p):l.push(null)}),i.gradient==null)throw new Error("Cannot compute gradient: gradient function not found "+("for "+i.kernelName+"."));var u=i.gradient(l),c=function(h){if(!(h in u))throw new Error("Cannot backprop through input "+h+". "+("Available gradients found: "+Object.keys(u)+"."));var p=r(function(){return u[h]()});if(p.dtype!=="float32")throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input "+(h+" must have 'float32' dtype, but has '"+p.dtype+"'"));var d=i.inputs[h];if(!mv(p.shape,d.shape))throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input "+("'"+h+"' has shape '"+p.shape+"', which does not match ")+("the shape of the input '"+d.shape+"'"));if(e[d.id]==null)e[d.id]=p;else{var v=e[d.id];e[d.id]=n(v,p),v.dispose()}};for(var f in i.inputs)c(f)},o=t.length-1;o>=0;o--)a(o)}var hL=20,Sb=3,YE=7;function dle(e,t,r,n){var a=ay(t),o=vle(e,t,r,a),s=t.length,i=a3(e,t,r,a,o),l=["Tensor"];return n&&(l.push(" dtype: "+r),l.push(" rank: "+s),l.push(" shape: ["+t+"]"),l.push(" values:")),l.push(i.map(function(u){return" "+u}).join(` `)),l.join(` `)}function vle(e,t,r,n){var a=Ml(t),o=n[n.length-1],s=new Array(o).fill(0),i=t.length,l=r==="complex64"?Db(e):e;if(i>1)for(var u=0;u<a/o;u++)for(var c=u*o,f=0;f<o;f++)s[f]=Math.max(s[f],Eb(l[c+f],0,r).length);return s}function Eb(e,t,r){var n;return Array.isArray(e)?n=parseFloat(e[0].toFixed(YE))+" + "+(parseFloat(e[1].toFixed(YE))+"j"):cv(e)?n="'"+e+"'":r==="bool"?n=S9(e):n=parseFloat(e.toFixed(YE)).toString(),Cb(n,t)}function S9(e){return e===0?"false":"true"}function a3(e,t,r,n,a,o){o===void 0&&(o=!0);var s=r==="complex64"?2:1,i=t[0],l=t.length;if(l===0){if(r==="complex64"){var u=Db(e);return[Eb(u[0],0,r)]}return r==="bool"?[S9(e[0])]:[e[0].toString()]}if(l===1){if(i>hL){var c=Sb*s,f=Array.from(e.slice(0,c)),h=Array.from(e.slice((i-Sb)*s,i*s));return r==="complex64"&&(f=Db(f),h=Db(h)),["["+f.map(function(k,T){return Eb(k,a[T],r)}).join(", ")+", ..., "+h.map(function(k,T){return Eb(k,a[i-Sb+T],r)}).join(", ")+"]"]}var p=r==="complex64"?Db(e):Array.from(e);return["["+p.map(function(k,T){return Eb(k,a[T],r)}).join(", ")+"]"]}var d=t.slice(1),v=n.slice(1),m=n[0]*s,g=[];if(i>hL){for(var x=0;x<Sb;x++){var b=x*m,y=b+m;g.push.apply(g,ys(a3(e.slice(b,y),d,r,v,a,!1)))}g.push("...");for(var x=i-Sb;x<i;x++){var b=x*m,y=b+m;g.push.apply(g,ys(a3(e.slice(b,y),d,r,v,a,x===i-1)))}}else for(var x=0;x<i;x++){var b=x*m,y=b+m;g.push.apply(g,ys(a3(e.slice(b,y),d,r,v,a,x===i-1)))}var w=l===2?",":"";g[0]="["+g[0]+w;for(var x=1;x<g.length-1;x++)g[x]=" "+g[x]+w;for(var _=`, `,x=2;x<l;x++)_+=` `;return g[g.length-1]=" "+g[g.length-1]+"]"+(o?"":_),g}function Db(e){for(var t=[],r=0;r<e.length;r+=2)t.push([e[r],e[r+1]]);return t}var p3=function(){function e(t,r,n){var a=this;if(this.dtype=r,this.shape=t.slice(),this.size=Ml(t),n!=null){var o=n.length;Dr(o===this.size,function(){return"Length of values '"+o+"' does not match the size "+("inferred by the shape '"+a.size+"'.")})}if(r==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||DL(r,this.size),this.strides=ay(t)}return e.prototype.set=function(t){for(var r=this,n=[],a=1;a<arguments.length;a++)n[a-1]=arguments[a];n.length===0&&(n=[0]),Dr(n.length===this.rank,function(){return"The number of provided coordinates ("+n.length+") must "+("match the rank ("+r.rank+")")});var o=this.locToIndex(n);this.values[o]=t},e.prototype.get=function(){for(var t,r,n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];n.length===0&&(n=[0]);var o=0;try{for(var s=Qf(n),i=s.next();!i.done;i=s.next()){var l=i.value;if(l<0||l>=this.shape[o]){var u="Requested out of range element at "+n+". "+(" Buffer shape="+this.shape);throw new Error(u)}o++}}catch(h){t={error:h}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}for(var c=n[n.length-1],f=0;f<n.length-1;++f)c+=this.strides[f]*n[f];return this.values[c]},e.prototype.locToIndex=function(t){if(this.rank===0)return 0;if(this.rank===1)return t[0];for(var r=t[t.length-1],n=0;n<t.length-1;++n)r+=this.strides[n]*t[n];return r},e.prototype.indexToLoc=function(t){if(this.rank===0)return[];if(this.rank===1)return[t];for(var r=new Array(this.shape.length),n=0;n<r.length-1;++n)r[n]=Math.floor(t/this.strides[n]),t-=r[n]*this.strides[n];return r[r.length-1]=t,r},Object.defineProperty(e.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),e.prototype.toTensor=function(){return Xp().makeTensor(this.values,this.shape,this.dtype)},e}(),Xp=null,G1=null;function mle(e){Xp=e}function gle(e){G1=e}var Du=function(){function e(t,r,n,a){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=r||"float32",this.size=Ml(t),this.strides=ay(t),this.dataId=n,this.id=a,this.rankType=this.rank<5?this.rank.toString():"higher"}return Object.defineProperty(e.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),e.prototype.buffer=function(){return xi(this,void 0,void 0,function(){var t;return bi(this,function(r){switch(r.label){case 0:return[4,this.data()];case 1:return t=r.sent(),[2,G1.buffer(this.shape,this.dtype,t)]}})})},e.prototype.bufferSync=function(){return G1.buffer(this.shape,this.dtype,this.dataSync())},e.prototype.array=function(){return xi(this,void 0,void 0,function(){var t;return bi(this,function(r){switch(r.label){case 0:return[4,this.data()];case 1:return t=r.sent(),[2,q1(this.shape,t,this.dtype==="complex64")]}})})},e.prototype.arraySync=function(){return q1(this.shape,this.dataSync(),this.dtype==="complex64")},e.prototype.data=function(){return xi(this,void 0,void 0,function(){var t,r;return bi(this,function(n){switch(n.label){case 0:return this.throwIfDisposed(),t=Xp().read(this.dataId),this.dtype!=="string"?[3,2]:[4,t];case 1:r=n.sent();try{return[2,r.map(function(a){return h3(a)})]}catch{throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}n.label=2;case 2:return[2,t]}})})},e.prototype.dataToGPU=function(t){return this.throwIfDisposed(),Xp().readToGPU(this.dataId,t)},e.prototype.dataSync=function(){this.throwIfDisposed();var t=Xp().readSync(this.dataId);if(this.dtype==="string")try{return t.map(function(r){return h3(r)})}catch{throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t},e.prototype.bytes=function(){return xi(this,void 0,void 0,function(){var t;return bi(this,function(r){switch(r.label){case 0:return this.throwIfDisposed(),[4,Xp().read(this.dataId)];case 1:return t=r.sent(),this.dtype==="string"?[2,t]:[2,new Uint8Array(t.buffer)]}})})},e.prototype.dispose=function(){this.isDisposed||(Xp().disposeTensor(this),this.isDisposedInternal=!0)},Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this.isDisposedInternal},enumerable:!0,configurable:!0}),e.prototype.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.")},e.prototype.print=function(t){return t===void 0&&(t=!1),G1.print(this,t)},e.prototype.clone=function(){return this.throwIfDisposed(),G1.clone(this)},e.prototype.toString=function(t){t===void 0&&(t=!1);var r=this.dataSync();return dle(r,this.shape,this.dtype,t)},e.prototype.cast=function(t){return this.throwIfDisposed(),G1.cast(this,t)},e.prototype.variable=function(t,r,n){return t===void 0&&(t=!0),this.throwIfDisposed(),Xp().makeVariable(this,t,r,n)},e}();Object.defineProperty(Du,Symbol.hasInstance,{value:function(e){return!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null}});function yle(){return M4("Tensor",function(){return Du})}yle();var Pb=function(e){y0(t,e);function t(r,n,a,o){var s=e.call(this,r.shape,r.dtype,r.dataId,o)||this;return s.trainable=n,s.name=a,s}return t.prototype.assign=function(r){if(r.dtype!==this.dtype)throw new Error("dtype of the new value ("+r.dtype+") and "+("previous value ("+this.dtype+") must match"));if(!mv(r.shape,this.shape))throw new Error("shape of the new value ("+r.shape+") and "+("previous value ("+this.shape+") must match"));Xp().disposeTensor(this),this.dataId=r.dataId,Xp().incRef(this,null)},t.prototype.dispose=function(){Xp().disposeVariable(this),this.isDisposedInternal=!0},t}(Du);Object.defineProperty(Pb,Symbol.hasInstance,{value:function(e){return e instanceof Du&&e.assign!=null&&e.assign instanceof Function}});Gt.Rank=void 0;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(Gt.Rank||(Gt.Rank={}));var f4;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(f4||(f4={}));var h4;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(h4||(h4={}));var p4;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(p4||(p4={}));var d4;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(d4||(d4={}));var xle={float32:p4,int32:f4,bool:h4,complex64:d4};function A3(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error("Can not upcast "+e+" with "+t)}return xle[e][t]}function ble(e){return A3(e,"int32")}function Bl(e,t){if(e.dtype===t.dtype)return[e,t];var r=A3(e.dtype,t.dtype);return[e.cast(r),t.cast(r)]}function E9(e,t){Dr(e.dtype===t.dtype,function(){return"The dtypes of the first("+e.dtype+") and"+(" second("+t.dtype+") input must match")})}function _le(e,t){return t.some(function(r){return r.id===e.id})}function R4(e){var t=[],r=new Set;return D9(e,t,r),t}function D9(e,t,r){if(e!=null){if(e instanceof Du){t.push(e);return}if(!!wle(e)){var n=e;for(var a in n){var o=n[a];r.has(o)||(r.add(o),D9(o,t,r))}}}}function wle(e){return Array.isArray(e)||typeof e=="object"}var kle={__proto__:null,makeTypesMatch:Bl,assertTypesMatch:E9,isTensorInList:_le,getTensorsInContainer:R4};function ZE(e){return e.kernelName!=null}var pL=function(){function e(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map(function(t){return t.name})))}}}return e.prototype.dispose=function(){for(var t in this.registeredVariables)this.registeredVariables[t].dispose()},e}(),z4=function(){function e(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new pL}return e.prototype.ready=function(){return xi(this,void 0,void 0,function(){var t,r,n,a;return bi(this,function(o){switch(o.label){case 0:if(this.pendingBackendInit!=null)return[2,this.pendingBackendInit.then(function(){})];if(this.backendInstance!=null)return[2];t=this.getSortedBackends(),r=0,o.label=1;case 1:return r<t.length?(n=t[r],[4,this.initializeBackend(n).success]):[3,5];case 2:return a=o.sent(),a?[4,this.setBackend(n)]:[3,4];case 3:return o.sent(),[2];case 4:return r++,[3,1];case 5:throw new Error("Could not initialize any backends, all backend initializations failed.")}})})},Object.defineProperty(e.prototype,"backend",{get:function(){if(this.pendingBackendInit!=null)throw new Error("Backend '"+this.backendName+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");if(this.backendInstance==null){var t=this.initializeBackendsAndReturnBest(),r=t.name,n=t.asyncInit;if(n)throw new Error("The highest priority backend '"+r+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");this.setBackend(r)}return this.backendInstance},enumerable:!0,configurable:!0}),e.prototype.backendNames=function(){return Object.keys(this.registryFactory)},e.prototype.findBackend=function(t){if(!(t in this.registry))if(t in this.registryFactory){var r=this.initializeBackend(t).asyncInit;if(r)return null}else return null;return this.registry[t]},e.prototype.findBackendFactory=function(t){return t in this.registryFactory?this.registryFactory[t].factory:null},e.prototype.registerBackend=function(t,r,n){return n===void 0&&(n=1),t in this.registryFactory?(uv(t+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[t]={factory:r,priority:n},!0)},e.prototype.setBackend=function(t){return xi(this,void 0,void 0,function(){var r,n,a,o,s;return bi(this,function(i){switch(i.label){case 0:if(this.registryFactory[t]==null)throw new Error("Backend name '"+t+"' not found in registry");return this.backendName=t,this.registry[t]!=null?[3,4]:(this.backendInstance=null,r=this.initializeBackend(t),n=r.success,a=r.asyncInit,a?[4,n]:[3,2]);case 1:return s=i.sent(),[3,3];case 2:s=n,i.label=3;case 3:if(o=s,!o)return[2,!1];i.label=4;case 4:return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new ule(this.backendInstance),[2,!0]}})})},e.prototype.setupRegisteredKernels=function(){var t=this,r=c3(this.backendName);r.forEach(function(n){n.setupFunc!=null&&n.setupFunc(t.backendInstance)})},e.prototype.disposeRegisteredKernels=function(t){var r=this,n=c3(t);n.forEach(function(a){a.disposeFunc!=null&&a.disposeFunc(r.registry[t])})},e.prototype.initializeBackend=function(t){var r=this,n=this.registryFactory[t];if(n==null)throw new Error("Cannot initialize backend "+t+", no registration found.");try{var a=n.factory();if(a&&!(a instanceof TL)&&typeof a.then=="function"){var o=++this.pendingBackendInitId,s=a.then(function(i){return o<r.pendingBackendInitId?!1:(r.registry[t]=i,r.pendingBackendInit=null,!0)}).catch(function(i){return o<r.pendingBackendInitId||(r.pendingBackendInit=null,uv("Initialization of backend "+t+" failed"),uv(i.stack||i.message)),!1});return this.pendingBackendInit=s,{success:s,asyncInit:!0}}else return this.registry[t]=a,{success:!0,asyncInit:!1}}catch(i){return uv("Initialization of backend "+t+" failed"),uv(i.stack||i.message),{success:!1,asyncInit:!1}}},e.prototype.removeBackend=function(t){if(!(t in this.registryFactory))throw new Error(t+" backend not found in registry");this.backendName===t&&this.pendingBackendInit!=null&&this.pendingBackendInitId++,t in this.registry&&(this.disposeRegisteredKernels(t),this.registry[t].dispos