@genai-fi/nanogpt 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/Generator.js +22 -22
  2. package/dist/MLP-KHhikThU.js +83 -0
  3. package/dist/NanoGPTModel.d.ts +2 -3
  4. package/dist/NanoGPTModel.js +79 -79
  5. package/dist/TeachableLLM.js +16 -13
  6. package/dist/axis_util-DeydwOoC.js +69 -0
  7. package/dist/{concat-BIZS_td9.js → concat-DS_qH7MI.js} +5 -5
  8. package/dist/config.js +7 -8
  9. package/dist/{gather-BPGW8RsB.js → gather-BUmJIS8n.js} +1 -1
  10. package/dist/{index-pWA4_lUh.js → index-XjBAhiFO.js} +1272 -1174
  11. package/dist/layers/BaseLayer.d.ts +14 -2
  12. package/dist/layers/BaseLayer.js +9 -9
  13. package/dist/layers/CausalSelfAttention.d.ts +4 -8
  14. package/dist/layers/CausalSelfAttention.js +106 -80
  15. package/dist/layers/MLP.d.ts +2 -3
  16. package/dist/layers/MLP.js +5 -62
  17. package/dist/layers/RMSNorm.d.ts +2 -2
  18. package/dist/layers/RMSNorm.js +11 -11
  19. package/dist/layers/RoPECache.js +3 -3
  20. package/dist/layers/TiedEmbedding.js +7 -6
  21. package/dist/layers/TransformerBlock.d.ts +2 -6
  22. package/dist/layers/TransformerBlock.js +9 -12
  23. package/dist/{sum-C7Mgy9Bw.js → log_sum_exp-DJPkVZZn.js} +32 -54
  24. package/dist/main.js +22 -19
  25. package/dist/{mat_mul-D7_a4KJn.js → mat_mul-CKwFEV1Q.js} +1 -1
  26. package/dist/max-DJvEiCAJ.js +25 -0
  27. package/dist/moments-CrWRPcR3.js +53 -0
  28. package/dist/norm-BzY929B_.js +86 -0
  29. package/dist/{ones-Cog-G2ag.js → ones-BO01zpJG.js} +2 -2
  30. package/dist/ops/appendCache.js +1 -1
  31. package/dist/ops/attentionMask.js +1 -1
  32. package/dist/ops/cpu/appendCache.js +2 -2
  33. package/dist/ops/cpu/attentionMask.js +2 -2
  34. package/dist/ops/cpu/fusedSoftmax.d.ts +9 -0
  35. package/dist/ops/cpu/fusedSoftmax.js +23 -0
  36. package/dist/ops/cpu/gatherSub.js +3 -3
  37. package/dist/ops/cpu/mulDropout.d.ts +1 -0
  38. package/dist/ops/cpu/mulDropout.js +17 -0
  39. package/dist/ops/cpu/qkv.js +3 -3
  40. package/dist/ops/cpu/rope.js +5 -5
  41. package/dist/ops/cpu/scatterSub.js +27 -27
  42. package/dist/ops/fusedSoftmax.d.ts +2 -0
  43. package/dist/ops/fusedSoftmax.js +10 -0
  44. package/dist/ops/gatherSub.js +1 -1
  45. package/dist/ops/grads/attentionMask.js +1 -1
  46. package/dist/ops/grads/fusedSoftmax.d.ts +2 -0
  47. package/dist/ops/grads/fusedSoftmax.js +17 -0
  48. package/dist/ops/grads/qkv.js +1 -1
  49. package/dist/ops/grads/rope.js +1 -1
  50. package/dist/ops/mulDrop.d.ts +2 -0
  51. package/dist/ops/mulDrop.js +9 -0
  52. package/dist/ops/node/sparseCrossEntropy.js +1 -1
  53. package/dist/ops/qkv.js +1 -1
  54. package/dist/ops/scatterSub.js +1 -1
  55. package/dist/ops/webgl/appendCache.js +1 -1
  56. package/dist/ops/webgl/attentionMask.js +1 -1
  57. package/dist/ops/webgl/fusedSoftmax.d.ts +11 -0
  58. package/dist/ops/webgl/fusedSoftmax.js +3930 -0
  59. package/dist/ops/webgl/gatherSub.js +1 -1
  60. package/dist/ops/webgl/mulDropout.d.ts +1 -0
  61. package/dist/ops/webgl/mulDropout.js +41 -0
  62. package/dist/ops/webgl/qkv.js +1 -1
  63. package/dist/ops/webgl/rope.js +1 -1
  64. package/dist/ops/webgl/scatterSub.js +1 -1
  65. package/dist/{random_width-oeUIlUZj.js → random_width-CMHmdbSu.js} +4212 -6630
  66. package/dist/{range-CcDl05lo.js → range-DQMNzBWs.js} +1 -1
  67. package/dist/{reshape-C8CR_Bad.js → reshape-DFzh97Sc.js} +1 -1
  68. package/dist/{sin-BJIrfnj7.js → sin-BYM-U4Ut.js} +1 -1
  69. package/dist/slice_util-CnVNPQI-.js +90 -0
  70. package/dist/softmax-4DOn6cPq.js +28 -0
  71. package/dist/{split-DZbvruEP.js → split-CkbeVdF8.js} +3 -3
  72. package/dist/{stack-BMm-efee.js → stack-DaIMO5iX.js} +1 -1
  73. package/dist/sum-C6u3xMi3.js +27 -0
  74. package/dist/{tensor-DJVbYhh1.js → tensor-Cu1fU7H7.js} +1 -1
  75. package/dist/{tensor2d-ZuQSh2D-.js → tensor2d-D0CKdG6B.js} +1 -1
  76. package/dist/tfjs_backend-Bzl2SrRo.js +2460 -0
  77. package/dist/training/AdamExt.js +1 -1
  78. package/dist/training/DatasetBuilder.js +3 -3
  79. package/dist/training/FullTrainer.js +1 -1
  80. package/dist/training/Trainer.js +13 -12
  81. package/dist/training/sparseCrossEntropy.js +12 -11
  82. package/dist/utilities/dummy.js +8 -8
  83. package/dist/utilities/generate.js +11 -11
  84. package/dist/utilities/load.js +1 -1
  85. package/dist/utilities/profile.js +1 -1
  86. package/dist/utilities/weights.js +2 -2
  87. package/dist/{variable-Dl_ub3pk.js → variable-BS4AKqNU.js} +1 -1
  88. package/dist/{zeros-CCy9C3uU.js → zeros-CmJFiC84.js} +1 -1
  89. package/package.json +1 -1
  90. package/dist/exports_layers-tbTBcwMM.js +0 -25
  91. package/dist/layers/LayerNorm.d.ts +0 -13
  92. package/dist/layers/LayerNorm.js +0 -33
  93. package/dist/moments-DfcpfwKi.js +0 -132
  94. package/dist/softmax-Be_lsqUc.js +0 -105
  95. package/dist/training/LayerTrainer.d.ts +0 -29
  96. package/dist/training/LayerTrainer.js +0 -95
  97. package/dist/training/lwSchedule.d.ts +0 -7
  98. package/dist/training/lwSchedule.js +0 -162
@@ -1,6 +1,6 @@
1
1
  import { g as Ot } from "./index-D5v913EJ.js";
2
2
  import { p as Z } from "./index-xuotMAFm.js";
3
- import { B as gt } from "./index-Tf7vU29b.js";
3
+ import { B as mt } from "./index-Tf7vU29b.js";
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -17,8 +17,8 @@ import { B as gt } from "./index-Tf7vU29b.js";
17
17
  * limitations under the License.
18
18
  * =============================================================================
19
19
  */
20
- const Ae = 1e-7, Be = 1e-4;
21
- class ve {
20
+ const Me = 1e-7, Ne = 1e-4;
21
+ class Fe {
22
22
  refCount(t) {
23
23
  return v("refCount");
24
24
  }
@@ -37,22 +37,22 @@ class ve {
37
37
  readSync(t) {
38
38
  return v("readSync");
39
39
  }
40
- readToGPU(t, e) {
40
+ readToGPU(t, n) {
41
41
  return v("readToGPU");
42
42
  }
43
43
  numDataIds() {
44
44
  return v("numDataIds");
45
45
  }
46
- disposeData(t, e) {
46
+ disposeData(t, n) {
47
47
  return v("disposeData");
48
48
  }
49
- write(t, e, s) {
49
+ write(t, n, s) {
50
50
  return v("write");
51
51
  }
52
- move(t, e, s, r, a) {
52
+ move(t, n, s, r, a) {
53
53
  return v("move");
54
54
  }
55
- createTensorFromGPUData(t, e, s) {
55
+ createTensorFromGPUData(t, n, s) {
56
56
  return v("createTensorFromGPUData");
57
57
  }
58
58
  memory() {
@@ -64,14 +64,14 @@ class ve {
64
64
  }
65
65
  /** Returns the smallest representable number. */
66
66
  epsilon() {
67
- return this.floatPrecision() === 32 ? Ae : Be;
67
+ return this.floatPrecision() === 32 ? Me : Ne;
68
68
  }
69
69
  dispose() {
70
70
  return v("dispose");
71
71
  }
72
72
  }
73
- function v(n) {
74
- throw new Error(`'${n}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`);
73
+ function v(e) {
74
+ 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`);
75
75
  }
76
76
  /**
77
77
  * @license
@@ -89,175 +89,227 @@ function v(n) {
89
89
  * limitations under the License.
90
90
  * =============================================================================
91
91
  */
92
- function Bs(n) {
93
- let t = n.length, e = 0;
92
+ function Ns(e) {
93
+ let t = e.length, n = 0;
94
94
  for (; t > 0; )
95
- e = Math.random() * t | 0, t--, Me(n, t, e);
95
+ n = Math.random() * t | 0, t--, Re(e, t, n);
96
96
  }
97
- function Me(n, t, e) {
98
- const s = n[t];
99
- n[t] = n[e], n[e] = s;
97
+ function Re(e, t, n) {
98
+ const s = e[t];
99
+ e[t] = e[n], e[n] = s;
100
100
  }
101
- function y(n, t) {
102
- if (!n)
101
+ function y(e, t) {
102
+ if (!e)
103
103
  throw new Error(typeof t == "string" ? t : t());
104
104
  }
105
- function vs(n, t, e = "") {
106
- y(Ft(n, t), () => e + ` Shapes ${n} and ${t} must match`);
105
+ function De(e, t, n = "") {
106
+ y(Rt(e, t), () => n + ` Shapes ${e} and ${t} must match`);
107
107
  }
108
- function Ms(n) {
109
- y(n != null, () => "The input to the tensor constructor must be a non-null value.");
108
+ function Fs(e) {
109
+ y(e != null, () => "The input to the tensor constructor must be a non-null value.");
110
110
  }
111
- function z(n) {
112
- if (n.length === 0)
111
+ function z(e) {
112
+ if (e.length === 0)
113
113
  return 1;
114
- let t = n[0];
115
- for (let e = 1; e < n.length; e++)
116
- t *= n[e];
114
+ let t = e[0];
115
+ for (let n = 1; n < e.length; n++)
116
+ t *= e[n];
117
117
  return t;
118
118
  }
119
- function Ft(n, t) {
120
- if (n === t)
119
+ function Rt(e, t) {
120
+ if (e === t)
121
121
  return !0;
122
- if (n == null || t == null || n.length !== t.length)
122
+ if (e == null || t == null || e.length !== t.length)
123
123
  return !1;
124
- for (let e = 0; e < n.length; e++)
125
- if (n[e] !== t[e])
124
+ for (let n = 0; n < e.length; n++)
125
+ if (e[n] !== t[n])
126
126
  return !1;
127
127
  return !0;
128
128
  }
129
- function Ne(n) {
130
- return n % 1 === 0;
131
- }
132
- function lt(n, t) {
133
- return t <= n.length ? n : n + " ".repeat(t - n.length);
129
+ function $e(e) {
130
+ return e % 1 === 0;
131
+ }
132
+ function lt(e, t) {
133
+ return t <= e.length ? e : e + " ".repeat(t - e.length);
134
+ }
135
+ function Rs(e, t) {
136
+ let n = 1, s = -1;
137
+ for (let a = 0; a < e.length; ++a)
138
+ if (e[a] >= 0)
139
+ n *= e[a];
140
+ else if (e[a] === -1) {
141
+ if (s !== -1)
142
+ throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${a}`);
143
+ s = a;
144
+ } else if (e[a] < 0)
145
+ throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`);
146
+ if (s === -1) {
147
+ if (t > 0 && t !== n)
148
+ throw Error(`Size(${t}) must match the product of shape ${e}`);
149
+ return e;
150
+ }
151
+ if (n === 0)
152
+ throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);
153
+ if (t % n !== 0)
154
+ throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);
155
+ const r = e.slice();
156
+ return r[s] = t / n, r;
134
157
  }
135
- function Re(n, t) {
136
- const e = t.length;
137
- return n = n == null ? t.map((s, r) => r) : [].concat(n), y(n.every((s) => s >= -e && s < e), () => `All values in axis param must be in range [-${e}, ${e}) but got axis ${n}`), y(n.every((s) => Ne(s)), () => `All values in axis param must be integers but got axis ${n}`), n.map((s) => s < 0 ? e + s : s);
158
+ function xe(e, t) {
159
+ const n = t.length;
160
+ return e = e == null ? t.map((s, r) => r) : [].concat(e), y(e.every((s) => s >= -n && s < n), () => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`), y(e.every((s) => $e(s)), () => `All values in axis param must be integers but got axis ${e}`), e.map((s) => s < 0 ? n + s : s);
138
161
  }
139
- function Ns(n, t) {
140
- const e = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null : Re(t, n).sort();
162
+ function Ds(e, t) {
163
+ const n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null : xe(t, e).sort();
141
164
  let o = 0;
142
- for (let i = 0; i < n.length; ++i) {
165
+ for (let i = 0; i < e.length; ++i) {
143
166
  if (a != null) {
144
- if (a[o] === i && n[i] !== 1)
145
- throw new Error(`Can't squeeze axis ${i} since its dim '${n[i]}' is not 1`);
146
- (a[o] == null || a[o] > i) && n[i] === 1 && (e.push(n[i]), s.push(i)), a[o] <= i && o++;
167
+ if (a[o] === i && e[i] !== 1)
168
+ throw new Error(`Can't squeeze axis ${i} since its dim '${e[i]}' is not 1`);
169
+ (a[o] == null || a[o] > i) && e[i] === 1 && (n.push(e[i]), s.push(i)), a[o] <= i && o++;
147
170
  }
148
- n[i] !== 1 && (e.push(n[i]), s.push(i));
149
- }
150
- return { newShape: e, keptDims: s };
151
- }
152
- function Fe(n, t) {
153
- let e = null;
154
- if (n == null || n === "float32")
155
- e = new Float32Array(t);
156
- else if (n === "int32")
157
- e = new Int32Array(t);
158
- else if (n === "bool")
159
- e = new Uint8Array(t);
160
- else if (n === "string")
161
- e = new Array(t);
171
+ e[i] !== 1 && (n.push(e[i]), s.push(i));
172
+ }
173
+ return { newShape: n, keptDims: s };
174
+ }
175
+ function $s(e, t) {
176
+ return te(e, t);
177
+ }
178
+ function te(e, t) {
179
+ let n = null;
180
+ if (e == null || e === "float32")
181
+ n = new Float32Array(t);
182
+ else if (e === "int32")
183
+ n = new Int32Array(t);
184
+ else if (e === "bool")
185
+ n = new Uint8Array(t);
186
+ else if (e === "string")
187
+ n = new Array(t);
162
188
  else
163
- throw new Error(`Unknown data type ${n}`);
164
- return e;
189
+ throw new Error(`Unknown data type ${e}`);
190
+ return n;
165
191
  }
166
- function De(n, t) {
167
- for (let e = 0; e < n.length; e++) {
168
- const s = n[e];
192
+ function Ce(e, t) {
193
+ for (let n = 0; n < e.length; n++) {
194
+ const s = e[n];
169
195
  if (isNaN(s) || !isFinite(s))
170
196
  throw Error(`A tensor of type ${t} being uploaded contains ${s}.`);
171
197
  }
172
198
  }
173
- function $e(n) {
174
- return n === "bool" || n === "complex64" || n === "float32" || n === "int32" || n === "string";
199
+ function Pe(e) {
200
+ return e === "bool" || e === "complex64" || e === "float32" || e === "int32" || e === "string";
175
201
  }
176
- function St(n) {
177
- if (n === "float32" || n === "int32")
202
+ function kt(e) {
203
+ if (e === "float32" || e === "int32")
178
204
  return 4;
179
- if (n === "complex64")
205
+ if (e === "complex64")
180
206
  return 8;
181
- if (n === "bool")
207
+ if (e === "bool")
182
208
  return 1;
183
- throw new Error(`Unknown dtype ${n}`);
209
+ throw new Error(`Unknown dtype ${e}`);
184
210
  }
185
- function xe(n) {
186
- if (n == null)
211
+ function Le(e) {
212
+ if (e == null)
187
213
  return 0;
188
214
  let t = 0;
189
- return n.forEach((e) => t += e.length), t;
215
+ return e.forEach((n) => t += n.length), t;
190
216
  }
191
- function Dt(n) {
192
- return typeof n == "string" || n instanceof String;
217
+ function Dt(e) {
218
+ return typeof e == "string" || e instanceof String;
193
219
  }
194
- function Ce(n) {
195
- return typeof n == "boolean";
220
+ function _e(e) {
221
+ return typeof e == "boolean";
196
222
  }
197
- function Pe(n) {
198
- return typeof n == "number";
223
+ function Oe(e) {
224
+ return typeof e == "number";
199
225
  }
200
- function mt(n) {
201
- return Array.isArray(n) ? mt(n[0]) : n instanceof Float32Array ? "float32" : n instanceof Int32Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray ? "int32" : Pe(n) ? "float32" : Dt(n) ? "string" : Ce(n) ? "bool" : "float32";
226
+ function pt(e) {
227
+ return Array.isArray(e) ? pt(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : Oe(e) ? "float32" : Dt(e) ? "string" : _e(e) ? "bool" : "float32";
202
228
  }
203
- function kt(n) {
204
- return !!(n && n.constructor && n.call && n.apply);
229
+ function ht(e) {
230
+ return !!(e && e.constructor && e.call && e.apply);
205
231
  }
206
- function $t(n) {
207
- const t = n.length;
232
+ function xs(e, t) {
233
+ for (let n = t; n < e; ++n)
234
+ if (e % n === 0)
235
+ return n;
236
+ return e;
237
+ }
238
+ function $t(e) {
239
+ const t = e.length;
208
240
  if (t < 2)
209
241
  return [];
210
- const e = new Array(t - 1);
211
- e[t - 2] = n[t - 1];
242
+ const n = new Array(t - 1);
243
+ n[t - 2] = e[t - 1];
212
244
  for (let s = t - 3; s >= 0; --s)
213
- e[s] = e[s + 1] * n[s + 1];
214
- return e;
245
+ n[s] = n[s + 1] * e[s + 1];
246
+ return n;
215
247
  }
216
- function Zt(n, t, e, s = !1) {
248
+ function ee(e, t, n, s = !1) {
217
249
  const r = new Array();
218
250
  if (t.length === 1) {
219
251
  const a = t[0] * (s ? 2 : 1);
220
252
  for (let o = 0; o < a; o++)
221
- r[o] = e[n + o];
253
+ r[o] = n[e + o];
222
254
  } else {
223
255
  const a = t[0], o = t.slice(1), i = o.reduce((c, l) => c * l) * (s ? 2 : 1);
224
256
  for (let c = 0; c < a; c++)
225
- r[c] = Zt(n + c * i, o, e, s);
257
+ r[c] = ee(e + c * i, o, n, s);
226
258
  }
227
259
  return r;
228
260
  }
229
- function _t(n, t, e = !1) {
230
- if (n.length === 0)
261
+ function Gt(e, t, n = !1) {
262
+ if (e.length === 0)
231
263
  return t[0];
232
- const s = n.reduce((r, a) => r * a) * (e ? 2 : 1);
264
+ const s = e.reduce((r, a) => r * a) * (n ? 2 : 1);
233
265
  if (s === 0)
234
266
  return [];
235
267
  if (s !== t.length)
236
- throw new Error(`[${n}] does not match the input size ${t.length}${e ? " for a complex tensor" : ""}.`);
237
- return Zt(0, n, t, e);
268
+ throw new Error(`[${e}] does not match the input size ${t.length}${n ? " for a complex tensor" : ""}.`);
269
+ return ee(0, e, t, n);
238
270
  }
239
- function Le(n, t) {
240
- const e = te(n, t);
241
- for (let s = 0; s < e.length; s++)
242
- e[s] = 1;
243
- return e;
271
+ function Ge(e, t) {
272
+ const n = ne(e, t);
273
+ for (let s = 0; s < n.length; s++)
274
+ n[s] = 1;
275
+ return n;
244
276
  }
245
- function te(n, t) {
277
+ function ne(e, t) {
246
278
  if (t == null || t === "float32" || t === "complex64")
247
- return new Float32Array(n);
279
+ return new Float32Array(e);
248
280
  if (t === "int32")
249
- return new Int32Array(n);
281
+ return new Int32Array(e);
250
282
  if (t === "bool")
251
- return new Uint8Array(n);
283
+ return new Uint8Array(e);
252
284
  throw new Error(`Unknown data type ${t}`);
253
285
  }
254
- function xt(n) {
255
- n.forEach((t) => {
256
- y(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${n}].`);
286
+ function xt(e) {
287
+ e.forEach((t) => {
288
+ y(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${e}].`);
257
289
  });
258
290
  }
259
- function Ct(n) {
260
- return n && n.then && typeof n.then == "function";
291
+ function Cs(e, t, n) {
292
+ if (t === 0)
293
+ return 0;
294
+ if (t === 1)
295
+ return e[0];
296
+ let s = e[e.length - 1];
297
+ for (let r = 0; r < e.length - 1; ++r)
298
+ s += n[r] * e[r];
299
+ return s;
300
+ }
301
+ function Ps(e, t, n) {
302
+ if (t === 0)
303
+ return [];
304
+ if (t === 1)
305
+ return [e];
306
+ const s = new Array(t);
307
+ for (let r = 0; r < s.length - 1; ++r)
308
+ s[r] = Math.floor(e / n[r]), e -= s[r] * n[r];
309
+ return s[s.length - 1] = e, s;
310
+ }
311
+ function Ct(e) {
312
+ return e && e.then && typeof e.then == "function";
261
313
  }
262
314
  /**
263
315
  * @license
@@ -276,16 +328,16 @@ function Ct(n) {
276
328
  * =============================================================================
277
329
  */
278
330
  const Ut = "tfjsflags";
279
- class Oe {
331
+ class Ue {
280
332
  // tslint:disable-next-line: no-any
281
333
  constructor(t) {
282
- this.global = t, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = _e, this.populateURLFlags();
334
+ this.global = t, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = ze, this.populateURLFlags();
283
335
  }
284
- setPlatform(t, e) {
285
- this.platform != null && (k().getBool("IS_TEST") || k().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`)), this.platformName = t, this.platform = e;
336
+ setPlatform(t, n) {
337
+ this.platform != null && (k().getBool("IS_TEST") || k().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`)), this.platformName = t, this.platform = n;
286
338
  }
287
- registerFlag(t, e, s) {
288
- if (this.flagRegistry[t] = { evaluationFn: e, setHook: s }, this.urlFlags[t] != null) {
339
+ registerFlag(t, n, s) {
340
+ if (this.flagRegistry[t] = { evaluationFn: n, setHook: s }, this.urlFlags[t] != null) {
289
341
  const r = this.urlFlags[t];
290
342
  k().getBool("IS_TEST") || k().getBool("PROD") || console.warn(`Setting feature override from URL ${t}: ${r}.`), this.set(t, r);
291
343
  }
@@ -296,10 +348,10 @@ class Oe {
296
348
  get(t) {
297
349
  if (t in this.flags)
298
350
  return this.flags[t];
299
- const e = this.evaluateFlag(t);
300
- if (Ct(e))
351
+ const n = this.evaluateFlag(t);
352
+ if (Ct(n))
301
353
  throw new Error(`Flag ${t} cannot be synchronously evaluated. Please use getAsync() instead.`);
302
- return this.flags[t] = e, this.flags[t];
354
+ return this.flags[t] = n, this.flags[t];
303
355
  }
304
356
  getNumber(t) {
305
357
  return this.get(t);
@@ -317,10 +369,10 @@ class Oe {
317
369
  get features() {
318
370
  return this.flags;
319
371
  }
320
- set(t, e) {
372
+ set(t, n) {
321
373
  if (this.flagRegistry[t] == null)
322
374
  throw new Error(`Cannot set flag ${t} as it has not been registered.`);
323
- this.flags[t] = e, this.flagRegistry[t].setHook != null && this.flagRegistry[t].setHook(e);
375
+ this.flags[t] = n, this.flagRegistry[t].setHook != null && this.flagRegistry[t].setHook(n);
324
376
  }
325
377
  evaluateFlag(t) {
326
378
  if (this.flagRegistry[t] == null)
@@ -339,27 +391,27 @@ class Oe {
339
391
  const t = this.getQueryParams(this.global.location.search);
340
392
  Ut in t && t[Ut].split(",").forEach((s) => {
341
393
  const [r, a] = s.split(":");
342
- this.urlFlags[r] = Ge(r, a);
394
+ this.urlFlags[r] = We(r, a);
343
395
  });
344
396
  }
345
397
  }
346
- function _e(n) {
398
+ function ze(e) {
347
399
  const t = {};
348
- return n.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (e, ...s) => (Ue(t, s[0], s[1]), s.join("="))), t;
400
+ return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (Ve(t, s[0], s[1]), s.join("="))), t;
349
401
  }
350
- function Ue(n, t, e) {
351
- n[decodeURIComponent(t)] = decodeURIComponent(e || "");
402
+ function Ve(e, t, n) {
403
+ e[decodeURIComponent(t)] = decodeURIComponent(n || "");
352
404
  }
353
- function Ge(n, t) {
354
- const e = t.toLowerCase();
355
- return e === "true" || e === "false" ? e === "true" : `${+e}` === e ? +e : t;
405
+ function We(e, t) {
406
+ const n = t.toLowerCase();
407
+ return n === "true" || n === "false" ? n === "true" : `${+n}` === n ? +n : t;
356
408
  }
357
409
  function k() {
358
- return ee;
410
+ return se;
359
411
  }
360
- let ee = null;
361
- function ze(n) {
362
- ee = n;
412
+ let se = null;
413
+ function je(e) {
414
+ se = e;
363
415
  }
364
416
  /**
365
417
  * @license
@@ -377,38 +429,38 @@ function ze(n) {
377
429
  * limitations under the License.
378
430
  * =============================================================================
379
431
  */
380
- let pt;
381
- function ne() {
382
- if (pt == null) {
383
- let n;
432
+ let yt;
433
+ function re() {
434
+ if (yt == null) {
435
+ let e;
384
436
  if (typeof window < "u")
385
- n = window;
437
+ e = window;
386
438
  else if (typeof Ot < "u")
387
- n = Ot;
439
+ e = Ot;
388
440
  else if (typeof Z < "u")
389
- n = Z;
441
+ e = Z;
390
442
  else if (typeof self < "u")
391
- n = self;
443
+ e = self;
392
444
  else
393
445
  throw new Error("Could not find a global object");
394
- pt = n;
446
+ yt = e;
395
447
  }
396
- return pt;
448
+ return yt;
397
449
  }
398
- function Ve() {
399
- const n = ne();
400
- return n._tfGlobals == null && (n._tfGlobals = /* @__PURE__ */ new Map()), n._tfGlobals;
450
+ function Ke() {
451
+ const e = re();
452
+ return e._tfGlobals == null && (e._tfGlobals = /* @__PURE__ */ new Map()), e._tfGlobals;
401
453
  }
402
- function Pt(n, t) {
403
- const e = Ve();
404
- if (e.has(n))
405
- return e.get(n);
454
+ function Pt(e, t) {
455
+ const n = Ke();
456
+ if (n.has(e))
457
+ return n.get(e);
406
458
  {
407
459
  const s = t();
408
- return e.set(n, s), e.get(n);
460
+ return n.set(e, s), n.get(e);
409
461
  }
410
462
  }
411
- const We = "Abs", Rs = "Acos", Fs = "Acosh", se = "Add", Ds = "AddN", $s = "All", xs = "Any", Cs = "ArgMax", Ps = "ArgMin", Ls = "Asin", Os = "Asinh", _s = "Atan", Us = "Atanh", Gs = "Atan2", zs = "AvgPool", Vs = "AvgPoolGrad", Ws = "AvgPool3D", js = "AvgPool3DGrad", Ks = "BatchMatMul", qs = "BatchToSpaceND", Hs = "Bincount", Js = "BroadcastTo", re = "Cast", Xs = "Ceil", Ys = "ClipByValue", Qs = "Complex", je = "ComplexAbs", Zs = "Concat", tr = "Conv2D", er = "Conv2DBackpropFilter", nr = "Conv2DBackpropInput", sr = "Conv3D", rr = "Conv3DBackpropFilterV2", ar = "Conv3DBackpropInputV2", or = "Cos", ir = "Cosh", cr = "Cumprod", lr = "Cumsum", ur = "CropAndResize", hr = "DenseBincount", dr = "DepthwiseConv2dNative", fr = "DepthwiseConv2dNativeBackpropFilter", gr = "DepthwiseConv2dNativeBackpropInput", mr = "Dilation2D", pr = "Dilation2DBackpropInput", yr = "Dilation2DBackpropFilter", Ke = "RealDiv", br = "Einsum", wr = "Elu", Sr = "EluGrad", kr = "Erf", Ir = "Equal", Tr = "Exp", Er = "ExpandDims", Ar = "Expm1", qe = "Fill", Br = "FlipLeftRight", vr = "Floor", He = "FloorDiv", Mr = "FusedBatchNorm", Nr = "GatherV2", Rr = "GatherNd", Fr = "Greater", Dr = "GreaterEqual", ae = "Identity", $r = "Imag", xr = "IsFinite", Cr = "IsInf", Pr = "IsNan", Lr = "LeakyRelu", Or = "Less", _r = "LessEqual", Ur = "Log", Gr = "Log1p", zr = "LogicalAnd", Vr = "LogicalNot", Wr = "LogSoftmax", jr = "LRN", Kr = "LRNGrad", qr = "Max", Je = "Maximum", Hr = "MaxPool", Jr = "MaxPoolGrad", Xr = "MaxPool3D", Yr = "MaxPool3DGrad", Qr = "Mean", Zr = "Min", ta = "Minimum", ea = "MirrorPad", na = "Mod", sa = "Multinomial", Xe = "Multiply", ra = "Neg", aa = "NotEqual", oa = "NonMaxSuppressionV3", ia = "NonMaxSuppressionV4", ca = "NonMaxSuppressionV5", la = "OnesLike", ua = "OneHot", ha = "Pack", da = "PadV2", Ye = "Pow", fa = "Prelu", ga = "Prod", ma = "Range", pa = "Real", ya = "Reciprocal", ba = "Relu", wa = "Reshape", Sa = "ResizeNearestNeighbor", ka = "ResizeNearestNeighborGrad", Ia = "ResizeBilinear", Ta = "ResizeBilinearGrad", Ea = "Relu6", Aa = "Reverse", Ba = "Round", va = "Rsqrt", Ma = "ScatterNd", Na = "Select", Ra = "Selu", Fa = "Slice", Da = "Sin", $a = "Sinh", xa = "Sign", Ca = "Sigmoid", Pa = "Softplus", Qe = "Sqrt", La = "Sum", Oa = "SpaceToBatchND", _a = "SplitV", Ua = "Softmax", Ga = "SquaredDifference", za = "Square", Ze = "Sub", Va = "Tan", Wa = "Tanh", ja = "Tile", Ka = "TopK", qa = "Transform", Ha = "Transpose", Ja = "Unpack", Xa = "UnsortedSegmentSum", tn = "ZerosLike", Ya = "Step", Qa = "RotateWithOffset", Za = "_FusedMatMul", to = "FusedConv2D";
463
+ const qe = "Abs", Ls = "Acos", _s = "Acosh", ae = "Add", Os = "AddN", Gs = "All", Us = "Any", zs = "ArgMax", Vs = "ArgMin", Ws = "Asin", js = "Asinh", Ks = "Atan", qs = "Atanh", Hs = "Atan2", Js = "AvgPool", Xs = "AvgPoolGrad", Ys = "AvgPool3D", Qs = "AvgPool3DGrad", Zs = "BatchMatMul", tr = "BatchToSpaceND", er = "Bincount", nr = "BroadcastTo", oe = "Cast", sr = "Ceil", rr = "ClipByValue", ar = "Complex", He = "ComplexAbs", or = "Concat", ir = "Conv2D", cr = "Conv2DBackpropFilter", lr = "Conv2DBackpropInput", ur = "Conv3D", hr = "Conv3DBackpropFilterV2", fr = "Conv3DBackpropInputV2", dr = "Cos", gr = "Cosh", mr = "Cumprod", pr = "Cumsum", yr = "CropAndResize", br = "DenseBincount", wr = "DepthwiseConv2dNative", Sr = "DepthwiseConv2dNativeBackpropFilter", kr = "DepthwiseConv2dNativeBackpropInput", Ir = "Dilation2D", Tr = "Dilation2DBackpropInput", Er = "Dilation2DBackpropFilter", Je = "RealDiv", Ar = "Einsum", Br = "Elu", vr = "EluGrad", Mr = "Erf", Nr = "Equal", Fr = "Exp", Rr = "ExpandDims", Dr = "Expm1", Xe = "Fill", $r = "FlipLeftRight", xr = "Floor", Ye = "FloorDiv", Cr = "FusedBatchNorm", Pr = "GatherV2", Lr = "GatherNd", _r = "Greater", Or = "GreaterEqual", ie = "Identity", Gr = "Imag", Ur = "IsFinite", zr = "IsInf", Vr = "IsNan", Wr = "LeakyRelu", jr = "Less", Kr = "LessEqual", qr = "Log", Hr = "Log1p", Jr = "LogicalAnd", Xr = "LogicalNot", Yr = "LogSoftmax", Qr = "LRN", Zr = "LRNGrad", ta = "Max", Qe = "Maximum", ea = "MaxPool", na = "MaxPoolGrad", sa = "MaxPool3D", ra = "MaxPool3DGrad", aa = "Mean", oa = "Min", ia = "Minimum", ca = "MirrorPad", la = "Mod", ua = "Multinomial", Ze = "Multiply", ha = "Neg", fa = "NotEqual", da = "NonMaxSuppressionV3", ga = "NonMaxSuppressionV4", ma = "NonMaxSuppressionV5", pa = "OnesLike", ya = "OneHot", ba = "Pack", wa = "PadV2", tn = "Pow", Sa = "Prelu", ka = "Prod", Ia = "Range", Ta = "Real", Ea = "Reciprocal", Aa = "Relu", Ba = "Reshape", va = "ResizeNearestNeighbor", Ma = "ResizeNearestNeighborGrad", Na = "ResizeBilinear", Fa = "ResizeBilinearGrad", Ra = "Relu6", Da = "Reverse", $a = "Round", xa = "Rsqrt", Ca = "ScatterNd", Pa = "Select", La = "Selu", _a = "Slice", Oa = "Sin", Ga = "Sinh", Ua = "Sign", za = "Sigmoid", Va = "Softplus", en = "Sqrt", Wa = "Sum", ja = "SpaceToBatchND", Ka = "SplitV", qa = "Softmax", Ha = "SquaredDifference", Ja = "Square", nn = "Sub", Xa = "Tan", Ya = "Tanh", Qa = "Tile", Za = "TopK", to = "Transform", eo = "Transpose", no = "Unpack", so = "UnsortedSegmentSum", sn = "ZerosLike", ro = "Step", ao = "RotateWithOffset", oo = "_FusedMatMul", io = "FusedConv2D";
412
464
  /**
413
465
  * @license
414
466
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -425,8 +477,8 @@ const We = "Abs", Rs = "Acos", Fs = "Acosh", se = "Add", Ds = "AddN", $s = "All"
425
477
  * limitations under the License.
426
478
  * =============================================================================
427
479
  */
428
- function _(...n) {
429
- k().getBool("IS_TEST") || k().getBool("PROD") || console.warn(...n);
480
+ function O(...e) {
481
+ k().getBool("IS_TEST") || k().getBool("PROD") || console.warn(...e);
430
482
  }
431
483
  /**
432
484
  * @license
@@ -444,35 +496,35 @@ function _(...n) {
444
496
  * limitations under the License.
445
497
  * =============================================================================
446
498
  */
447
- const ht = Pt("kernelRegistry", () => /* @__PURE__ */ new Map()), It = Pt("gradRegistry", () => /* @__PURE__ */ new Map());
448
- function Gt(n, t) {
449
- const e = oe(n, t);
450
- return ht.get(e);
499
+ const ft = Pt("kernelRegistry", () => /* @__PURE__ */ new Map()), It = Pt("gradRegistry", () => /* @__PURE__ */ new Map());
500
+ function zt(e, t) {
501
+ const n = ce(e, t);
502
+ return ft.get(n);
451
503
  }
452
- function zt(n) {
453
- return It.get(n);
504
+ function Vt(e) {
505
+ return It.get(e);
454
506
  }
455
- function Vt(n) {
456
- const t = ht.entries(), e = [];
507
+ function Wt(e) {
508
+ const t = ft.entries(), n = [];
457
509
  for (; ; ) {
458
510
  const { done: s, value: r } = t.next();
459
511
  if (s)
460
512
  break;
461
513
  const [a, o] = r, [i] = a.split("_");
462
- i === n && e.push(o);
514
+ i === e && n.push(o);
463
515
  }
464
- return e;
516
+ return n;
465
517
  }
466
- function eo(n) {
467
- const { kernelName: t, backendName: e } = n, s = oe(t, e);
468
- ht.has(s) && _(`The kernel '${t}' for backend '${e}' is already registered`), ht.set(s, n);
518
+ function co(e) {
519
+ const { kernelName: t, backendName: n } = e, s = ce(t, n);
520
+ ft.has(s) && O(`The kernel '${t}' for backend '${n}' is already registered`), ft.set(s, e);
469
521
  }
470
- function no(n) {
471
- const { kernelName: t } = n;
472
- It.has(t) && k().getBool("DEBUG") && _(`Overriding the gradient for '${t}'`), It.set(t, n);
522
+ function lo(e) {
523
+ const { kernelName: t } = e;
524
+ It.has(t) && k().getBool("DEBUG") && O(`Overriding the gradient for '${t}'`), It.set(t, e);
473
525
  }
474
- function oe(n, t) {
475
- return `${t}_${n}`;
526
+ function ce(e, t) {
527
+ return `${t}_${e}`;
476
528
  }
477
529
  /**
478
530
  * @license
@@ -490,8 +542,8 @@ function oe(n, t) {
490
542
  * limitations under the License.
491
543
  * =============================================================================
492
544
  */
493
- function ie(n) {
494
- return n instanceof Float32Array || n instanceof Int32Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray;
545
+ function le(e) {
546
+ return e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray;
495
547
  }
496
548
  /**
497
549
  * @license
@@ -509,50 +561,53 @@ function ie(n) {
509
561
  * limitations under the License.
510
562
  * =============================================================================
511
563
  */
512
- function en(n, t) {
513
- return n instanceof Float32Array && t === "float32" || n instanceof Int32Array && t === "int32" || n instanceof Uint8Array && t === "bool";
564
+ function uo(e, t) {
565
+ return t === "string" ? ue(e) : Lt([e], t);
514
566
  }
515
- function ce(n, t) {
567
+ function rn(e, t) {
568
+ return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool";
569
+ }
570
+ function Lt(e, t) {
516
571
  if (t === "string")
517
572
  throw new Error("Cannot convert a string[] to a TypedArray");
518
- if (Array.isArray(n) && (n = ct(n)), k().getBool("DEBUG") && De(n, t), en(n, t))
519
- return n;
573
+ if (Array.isArray(e) && (e = ct(e)), k().getBool("DEBUG") && Ce(e, t), rn(e, t))
574
+ return e;
520
575
  if (t == null || t === "float32" || t === "complex64")
521
- return new Float32Array(n);
576
+ return new Float32Array(e);
522
577
  if (t === "int32")
523
- return new Int32Array(n);
578
+ return new Int32Array(e);
524
579
  if (t === "bool") {
525
- const e = new Uint8Array(n.length);
526
- for (let s = 0; s < e.length; ++s)
527
- Math.round(n[s]) !== 0 && (e[s] = 1);
528
- return e;
580
+ const n = new Uint8Array(e.length);
581
+ for (let s = 0; s < n.length; ++s)
582
+ Math.round(e[s]) !== 0 && (n[s] = 1);
583
+ return n;
529
584
  } else
530
585
  throw new Error(`Unknown data type ${t}`);
531
586
  }
532
587
  function dt() {
533
588
  return k().platform.now();
534
589
  }
535
- function nn(n, t = "utf-8") {
536
- return t = t || "utf-8", k().platform.encode(n, t);
590
+ function ue(e, t = "utf-8") {
591
+ return t = t || "utf-8", k().platform.encode(e, t);
537
592
  }
538
- function Wt(n, t = "utf-8") {
539
- return t = t || "utf-8", k().platform.decode(n, t);
593
+ function jt(e, t = "utf-8") {
594
+ return t = t || "utf-8", k().platform.decode(e, t);
540
595
  }
541
- function R(n) {
542
- return k().platform.isTypedArray != null ? k().platform.isTypedArray(n) : ie(n);
596
+ function F(e) {
597
+ return k().platform.isTypedArray != null ? k().platform.isTypedArray(e) : le(e);
543
598
  }
544
- function ct(n, t = [], e = !1) {
545
- if (t == null && (t = []), typeof n == "boolean" || typeof n == "number" || typeof n == "string" || Ct(n) || n == null || R(n) && e)
546
- t.push(n);
547
- else if (Array.isArray(n) || R(n))
548
- for (let s = 0; s < n.length; ++s)
549
- ct(n[s], t, e);
599
+ function ct(e, t = [], n = !1) {
600
+ if (t == null && (t = []), typeof e == "boolean" || typeof e == "number" || typeof e == "string" || Ct(e) || e == null || F(e) && n)
601
+ t.push(e);
602
+ else if (Array.isArray(e) || F(e))
603
+ for (let s = 0; s < e.length; ++s)
604
+ ct(e[s], t, n);
550
605
  else {
551
606
  let s = -1;
552
- for (const r of Object.keys(n))
607
+ for (const r of Object.keys(e))
553
608
  /^([1-9]+[0-9]*|0)$/.test(r) && (s = Math.max(s, Number(r)));
554
609
  for (let r = 0; r <= s; r++)
555
- ct(n[r], t, e);
610
+ ct(e[r], t, n);
556
611
  }
557
612
  return t;
558
613
  }
@@ -572,11 +627,11 @@ function ct(n, t = [], e = !1) {
572
627
  * limitations under the License.
573
628
  * =============================================================================
574
629
  */
575
- class sn {
576
- constructor(t, e) {
577
- this.backendTimer = t, this.logger = e, e == null && (this.logger = new an());
630
+ class an {
631
+ constructor(t, n) {
632
+ this.backendTimer = t, this.logger = n, n == null && (this.logger = new cn());
578
633
  }
579
- profileKernel(t, e, s) {
634
+ profileKernel(t, n, s) {
580
635
  let r;
581
636
  const a = () => {
582
637
  r = s();
@@ -595,48 +650,48 @@ class sn {
595
650
  for (let l = 0; l < r.length; l++) {
596
651
  const u = r[l];
597
652
  u.data().then((h) => {
598
- rn(h, u.dtype, t);
653
+ on(h, u.dtype, t);
599
654
  });
600
655
  }
601
656
  return {
602
657
  kernelName: t,
603
658
  outputs: r,
604
- inputs: e,
659
+ inputs: n,
605
660
  timeMs: o.then((l) => l.kernelMs),
606
661
  extraInfo: o.then((l) => l.getExtraProfileInfo != null ? l.getExtraProfileInfo() : "")
607
662
  };
608
663
  }
609
664
  logKernelProfile(t) {
610
- const { kernelName: e, outputs: s, timeMs: r, inputs: a, extraInfo: o } = t;
665
+ const { kernelName: n, outputs: s, timeMs: r, inputs: a, extraInfo: o } = t;
611
666
  s.forEach((i) => {
612
667
  Promise.all([i.data(), r, o]).then((c) => {
613
- this.logger.logKernelProfile(e, i, c[0], c[1], a, c[2]);
668
+ this.logger.logKernelProfile(n, i, c[0], c[1], a, c[2]);
614
669
  });
615
670
  });
616
671
  }
617
672
  }
618
- function rn(n, t, e) {
673
+ function on(e, t, n) {
619
674
  if (t !== "float32")
620
675
  return !1;
621
- for (let s = 0; s < n.length; s++) {
622
- const r = n[s];
676
+ for (let s = 0; s < e.length; s++) {
677
+ const r = e[s];
623
678
  if (isNaN(r) || !isFinite(r))
624
- return console.warn(`Found ${r} in the result of '${e}'`), !0;
679
+ return console.warn(`Found ${r} in the result of '${n}'`), !0;
625
680
  }
626
681
  return !1;
627
682
  }
628
- class an {
629
- logKernelProfile(t, e, s, r, a, o) {
630
- const i = typeof r == "number" ? lt(`${r}ms`, 9) : r.error, c = lt(t, 25), l = e.rank, u = e.size, h = lt(e.shape.toString(), 14);
631
- let d = "";
683
+ class cn {
684
+ logKernelProfile(t, n, s, r, a, o) {
685
+ const i = typeof r == "number" ? lt(`${r}ms`, 9) : r.error, c = lt(t, 25), l = n.rank, u = n.size, h = lt(n.shape.toString(), 14);
686
+ let f = "";
632
687
  for (const m in a) {
633
688
  const p = a[m];
634
689
  if (p != null) {
635
- const f = p.shape || e.shape, w = f.length;
636
- d += `${m}: ${w}D ${w > 0 ? f : ""} `;
690
+ const d = p.shape || n.shape, w = d.length;
691
+ f += `${m}: ${w}D ${w > 0 ? d : ""} `;
637
692
  }
638
693
  }
639
- console.log(`%c${c} %c${i} %c${l}D ${h} %c${u} %c${d} %c${o}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue");
694
+ console.log(`%c${c} %c${i} %c${l}D ${h} %c${u} %c${f} %c${o}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue");
640
695
  }
641
696
  }
642
697
  /**
@@ -655,18 +710,18 @@ class an {
655
710
  * limitations under the License.
656
711
  * =============================================================================
657
712
  */
658
- function on(n, t, e) {
713
+ function ln(e, t, n) {
659
714
  const s = {}, r = {};
660
715
  for (let c = 0; c < t.length; c++)
661
716
  s[t[c].id] = !0;
662
- for (let c = 0; c < n.length; c++) {
663
- const l = n[c], u = l.inputs;
717
+ for (let c = 0; c < e.length; c++) {
718
+ const l = e[c], u = l.inputs;
664
719
  for (const h in u) {
665
- const d = u[h];
720
+ const f = u[h];
666
721
  let m = !1;
667
722
  for (let p = 0; p < t.length; p++)
668
- if (s[d.id]) {
669
- l.outputs.forEach((f) => s[f.id] = !0), m = !0, r[l.id] = !0;
723
+ if (s[f.id]) {
724
+ l.outputs.forEach((d) => s[d.id] = !0), m = !0, r[l.id] = !0;
670
725
  break;
671
726
  }
672
727
  if (m)
@@ -674,25 +729,25 @@ function on(n, t, e) {
674
729
  }
675
730
  }
676
731
  const a = {};
677
- a[e.id] = !0;
732
+ a[n.id] = !0;
678
733
  const o = {};
679
- for (let c = n.length - 1; c >= 0; c--) {
680
- const l = n[c], u = l.inputs;
734
+ for (let c = e.length - 1; c >= 0; c--) {
735
+ const l = e[c], u = l.inputs;
681
736
  for (let h = 0; h < l.outputs.length; h++)
682
737
  if (a[l.outputs[h].id]) {
683
- for (const d in u)
684
- a[u[d].id] = !0, o[l.id] = !0;
738
+ for (const f in u)
739
+ a[u[f].id] = !0, o[l.id] = !0;
685
740
  break;
686
741
  }
687
742
  }
688
743
  const i = [];
689
- for (let c = 0; c < n.length; c++) {
690
- const l = n[c];
744
+ for (let c = 0; c < e.length; c++) {
745
+ const l = e[c];
691
746
  if (r[l.id] && o[l.id]) {
692
747
  const u = {};
693
- for (const d in l.inputs) {
694
- const m = l.inputs[d];
695
- s[m.id] && (u[d] = m);
748
+ for (const f in l.inputs) {
749
+ const m = l.inputs[f];
750
+ s[m.id] && (u[f] = m);
696
751
  }
697
752
  const h = Object.assign({}, l);
698
753
  h.inputs = u, h.outputs = l.outputs, i.push(h);
@@ -700,11 +755,11 @@ function on(n, t, e) {
700
755
  }
701
756
  return i;
702
757
  }
703
- function cn(n, t, e, s) {
758
+ function un(e, t, n, s) {
704
759
  for (let r = t.length - 1; r >= 0; r--) {
705
760
  const a = t[r], o = [];
706
761
  if (a.outputs.forEach((c) => {
707
- const l = n[c.id];
762
+ const l = e[c.id];
708
763
  l != null ? o.push(l) : o.push(null);
709
764
  }), a.gradient == null)
710
765
  throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);
@@ -712,17 +767,17 @@ function cn(n, t, e, s) {
712
767
  for (const c in a.inputs) {
713
768
  if (!(c in i))
714
769
  throw new Error(`Cannot backprop through input ${c}. Available gradients found: ${Object.keys(i)}.`);
715
- const l = e(() => i[c]());
770
+ const l = n(() => i[c]());
716
771
  if (l.dtype !== "float32")
717
772
  throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${c} must have 'float32' dtype, but has '${l.dtype}'`);
718
773
  const u = a.inputs[c];
719
- if (!Ft(l.shape, u.shape))
774
+ if (!Rt(l.shape, u.shape))
720
775
  throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${c}' has shape '${l.shape}', which does not match the shape of the input '${u.shape}'`);
721
- if (n[u.id] == null)
722
- n[u.id] = l;
776
+ if (e[u.id] == null)
777
+ e[u.id] = l;
723
778
  else {
724
- const h = n[u.id];
725
- n[u.id] = s(h, l), h.dispose();
779
+ const h = e[u.id];
780
+ e[u.id] = s(h, l), h.dispose();
726
781
  }
727
782
  }
728
783
  }
@@ -743,106 +798,106 @@ function cn(n, t, e, s) {
743
798
  * limitations under the License.
744
799
  * =============================================================================
745
800
  */
746
- const jt = 20, at = 3, yt = 7;
747
- function ln(n, t, e, s) {
748
- const r = $t(t), a = un(n, t, e, r), o = t.length, i = ut(n, t, e, r, a), c = ["Tensor"];
749
- return s && (c.push(` dtype: ${e}`), c.push(` rank: ${o}`), c.push(` shape: [${t}]`), c.push(" values:")), c.push(i.map((l) => " " + l).join(`
801
+ const Kt = 20, at = 3, bt = 7;
802
+ function hn(e, t, n, s) {
803
+ const r = $t(t), a = fn(e, t, n, r), o = t.length, i = ut(e, t, n, r, a), c = ["Tensor"];
804
+ return s && (c.push(` dtype: ${n}`), c.push(` rank: ${o}`), c.push(` shape: [${t}]`), c.push(" values:")), c.push(i.map((l) => " " + l).join(`
750
805
  `)), c.join(`
751
806
  `);
752
807
  }
753
- function un(n, t, e, s) {
754
- const r = z(t), a = s[s.length - 1], o = new Array(a).fill(0), i = t.length, c = e === "complex64" ? it(n) : n;
808
+ function fn(e, t, n, s) {
809
+ const r = z(t), a = s[s.length - 1], o = new Array(a).fill(0), i = t.length, c = n === "complex64" ? it(e) : e;
755
810
  if (i > 1)
756
811
  for (let l = 0; l < r / a; l++) {
757
812
  const u = l * a;
758
813
  for (let h = 0; h < a; h++)
759
- o[h] = Math.max(o[h], ot(c[u + h], 0, e).length);
814
+ o[h] = Math.max(o[h], ot(c[u + h], 0, n).length);
760
815
  }
761
816
  return o;
762
817
  }
763
- function ot(n, t, e) {
818
+ function ot(e, t, n) {
764
819
  let s;
765
- return Array.isArray(n) ? s = `${parseFloat(n[0].toFixed(yt))} + ${parseFloat(n[1].toFixed(yt))}j` : Dt(n) ? s = `'${n}'` : e === "bool" ? s = le(n) : s = parseFloat(n.toFixed(yt)).toString(), lt(s, t);
820
+ return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(bt))} + ${parseFloat(e[1].toFixed(bt))}j` : Dt(e) ? s = `'${e}'` : n === "bool" ? s = he(e) : s = parseFloat(e.toFixed(bt)).toString(), lt(s, t);
766
821
  }
767
- function le(n) {
768
- return n === 0 ? "false" : "true";
822
+ function he(e) {
823
+ return e === 0 ? "false" : "true";
769
824
  }
770
- function ut(n, t, e, s, r, a = !0) {
771
- const o = e === "complex64" ? 2 : 1, i = t[0], c = t.length;
825
+ function ut(e, t, n, s, r, a = !0) {
826
+ const o = n === "complex64" ? 2 : 1, i = t[0], c = t.length;
772
827
  if (c === 0) {
773
- if (e === "complex64") {
774
- const f = it(n);
775
- return [ot(f[0], 0, e)];
828
+ if (n === "complex64") {
829
+ const d = it(e);
830
+ return [ot(d[0], 0, n)];
776
831
  }
777
- return e === "bool" ? [le(n[0])] : [n[0].toString()];
832
+ return n === "bool" ? [he(e[0])] : [e[0].toString()];
778
833
  }
779
834
  if (c === 1) {
780
- if (i > jt) {
835
+ if (i > Kt) {
781
836
  const w = at * o;
782
- let I = Array.from(n.slice(0, w)), O = Array.from(n.slice((i - at) * o, i * o));
783
- return e === "complex64" && (I = it(I), O = it(O)), [
784
- "[" + I.map((J, X) => ot(J, r[X], e)).join(", ") + ", ..., " + O.map((J, X) => ot(J, r[i - at + X], e)).join(", ") + "]"
837
+ let I = Array.from(e.slice(0, w)), _ = Array.from(e.slice((i - at) * o, i * o));
838
+ return n === "complex64" && (I = it(I), _ = it(_)), [
839
+ "[" + I.map((J, X) => ot(J, r[X], n)).join(", ") + ", ..., " + _.map((J, X) => ot(J, r[i - at + X], n)).join(", ") + "]"
785
840
  ];
786
841
  }
787
842
  return [
788
- "[" + (e === "complex64" ? it(n) : Array.from(n)).map((w, I) => ot(w, r[I], e)).join(", ") + "]"
843
+ "[" + (n === "complex64" ? it(e) : Array.from(e)).map((w, I) => ot(w, r[I], n)).join(", ") + "]"
789
844
  ];
790
845
  }
791
- const l = t.slice(1), u = s.slice(1), h = s[0] * o, d = [];
792
- if (i > jt) {
793
- for (let f = 0; f < at; f++) {
794
- const w = f * h, I = w + h;
795
- d.push(...ut(
796
- n.slice(w, I),
846
+ const l = t.slice(1), u = s.slice(1), h = s[0] * o, f = [];
847
+ if (i > Kt) {
848
+ for (let d = 0; d < at; d++) {
849
+ const w = d * h, I = w + h;
850
+ f.push(...ut(
851
+ e.slice(w, I),
797
852
  l,
798
- e,
853
+ n,
799
854
  u,
800
855
  r,
801
856
  !1
802
857
  /* isLast */
803
858
  ));
804
859
  }
805
- d.push("...");
806
- for (let f = i - at; f < i; f++) {
807
- const w = f * h, I = w + h;
808
- d.push(...ut(
809
- n.slice(w, I),
860
+ f.push("...");
861
+ for (let d = i - at; d < i; d++) {
862
+ const w = d * h, I = w + h;
863
+ f.push(...ut(
864
+ e.slice(w, I),
810
865
  l,
811
- e,
866
+ n,
812
867
  u,
813
868
  r,
814
- f === i - 1
869
+ d === i - 1
815
870
  /* isLast */
816
871
  ));
817
872
  }
818
873
  } else
819
- for (let f = 0; f < i; f++) {
820
- const w = f * h, I = w + h;
821
- d.push(...ut(
822
- n.slice(w, I),
874
+ for (let d = 0; d < i; d++) {
875
+ const w = d * h, I = w + h;
876
+ f.push(...ut(
877
+ e.slice(w, I),
823
878
  l,
824
- e,
879
+ n,
825
880
  u,
826
881
  r,
827
- f === i - 1
882
+ d === i - 1
828
883
  /* isLast */
829
884
  ));
830
885
  }
831
886
  const m = c === 2 ? "," : "";
832
- d[0] = "[" + (i > 0 ? d[0] + m : "");
833
- for (let f = 1; f < d.length - 1; f++)
834
- d[f] = " " + d[f] + m;
887
+ f[0] = "[" + (i > 0 ? f[0] + m : "");
888
+ for (let d = 1; d < f.length - 1; d++)
889
+ f[d] = " " + f[d] + m;
835
890
  let p = `,
836
891
  `;
837
- for (let f = 2; f < c; f++)
892
+ for (let d = 2; d < c; d++)
838
893
  p += `
839
894
  `;
840
- return d[d.length - 1] = " " + d[d.length - 1] + "]" + (a ? "" : p), d;
895
+ return f[f.length - 1] = " " + f[f.length - 1] + "]" + (a ? "" : p), f;
841
896
  }
842
- function it(n) {
897
+ function it(e) {
843
898
  const t = [];
844
- for (let e = 0; e < n.length; e += 2)
845
- t.push([n[e], n[e + 1]]);
899
+ for (let n = 0; n < e.length; n += 2)
900
+ t.push([e[n], e[n + 1]]);
846
901
  return t;
847
902
  }
848
903
  /**
@@ -861,15 +916,15 @@ function it(n) {
861
916
  * limitations under the License.
862
917
  * =============================================================================
863
918
  */
864
- class hn {
865
- constructor(t, e, s) {
866
- if (this.dtype = e, this.shape = t.slice(), this.size = z(t), s != null) {
919
+ class dn {
920
+ constructor(t, n, s) {
921
+ if (this.dtype = n, this.shape = t.slice(), this.size = z(t), s != null) {
867
922
  const r = s.length;
868
923
  y(r === this.size, () => `Length of values '${r}' does not match the size inferred by the shape '${this.size}'.`);
869
924
  }
870
- if (e === "complex64")
925
+ if (n === "complex64")
871
926
  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).");
872
- this.values = s || Fe(e, this.size), this.strides = $t(t);
927
+ this.values = s || te(n, this.size), this.strides = $t(t);
873
928
  }
874
929
  /**
875
930
  * Sets a value in the buffer at a given location.
@@ -879,9 +934,9 @@ class hn {
879
934
  *
880
935
  * @doc {heading: 'Tensors', subheading: 'Creation'}
881
936
  */
882
- set(t, ...e) {
883
- e.length === 0 && (e = [0]), y(e.length === this.rank, () => `The number of provided coordinates (${e.length}) must match the rank (${this.rank})`);
884
- const s = this.locToIndex(e);
937
+ set(t, ...n) {
938
+ n.length === 0 && (n = [0]), y(n.length === this.rank, () => `The number of provided coordinates (${n.length}) must match the rank (${this.rank})`);
939
+ const s = this.locToIndex(n);
885
940
  this.values[s] = t;
886
941
  }
887
942
  /**
@@ -893,13 +948,13 @@ class hn {
893
948
  */
894
949
  get(...t) {
895
950
  t.length === 0 && (t = [0]);
896
- let e = 0;
951
+ let n = 0;
897
952
  for (const r of t) {
898
- if (r < 0 || r >= this.shape[e]) {
953
+ if (r < 0 || r >= this.shape[n]) {
899
954
  const a = `Requested out of range element at ${t}. Buffer shape=${this.shape}`;
900
955
  throw new Error(a);
901
956
  }
902
- e++;
957
+ n++;
903
958
  }
904
959
  let s = t[t.length - 1];
905
960
  for (let r = 0; r < t.length - 1; ++r)
@@ -911,20 +966,20 @@ class hn {
911
966
  return 0;
912
967
  if (this.rank === 1)
913
968
  return t[0];
914
- let e = t[t.length - 1];
969
+ let n = t[t.length - 1];
915
970
  for (let s = 0; s < t.length - 1; ++s)
916
- e += this.strides[s] * t[s];
917
- return e;
971
+ n += this.strides[s] * t[s];
972
+ return n;
918
973
  }
919
974
  indexToLoc(t) {
920
975
  if (this.rank === 0)
921
976
  return [];
922
977
  if (this.rank === 1)
923
978
  return [t];
924
- const e = new Array(this.shape.length);
925
- for (let s = 0; s < e.length - 1; ++s)
926
- e[s] = Math.floor(t / this.strides[s]), t -= e[s] * this.strides[s];
927
- return e[e.length - 1] = t, e;
979
+ const n = new Array(this.shape.length);
980
+ for (let s = 0; s < n.length - 1; ++s)
981
+ n[s] = Math.floor(t / this.strides[s]), t -= n[s] * this.strides[s];
982
+ return n[n.length - 1] = t, n;
928
983
  }
929
984
  get rank() {
930
985
  return this.shape.length;
@@ -935,19 +990,19 @@ class hn {
935
990
  * @doc {heading: 'Tensors', subheading: 'Creation'}
936
991
  */
937
992
  toTensor() {
938
- return F().makeTensor(this.values, this.shape, this.dtype);
993
+ return R().makeTensor(this.values, this.shape, this.dtype);
939
994
  }
940
995
  }
941
- let F = null, Y = null;
942
- function dn(n) {
943
- F = n;
996
+ let R = null, Y = null;
997
+ function gn(e) {
998
+ R = e;
944
999
  }
945
- function fn(n) {
946
- Y = n;
1000
+ function mn(e) {
1001
+ Y = e;
947
1002
  }
948
1003
  class D {
949
- constructor(t, e, s, r) {
950
- this.kept = !1, this.isDisposedInternal = !1, this.shape = t.slice(), this.dtype = e || "float32", this.size = z(t), this.strides = $t(t), this.dataId = s, this.id = r, this.rankType = this.rank < 5 ? this.rank.toString() : "higher";
1004
+ constructor(t, n, s, r) {
1005
+ this.kept = !1, this.isDisposedInternal = !1, this.shape = t.slice(), this.dtype = n || "float32", this.size = z(t), this.strides = $t(t), this.dataId = s, this.id = r, this.rankType = this.rank < 5 ? this.rank.toString() : "higher";
951
1006
  }
952
1007
  get rank() {
953
1008
  return this.shape.length;
@@ -976,7 +1031,7 @@ class D {
976
1031
  */
977
1032
  async array() {
978
1033
  const t = await this.data();
979
- return _t(this.shape, t, this.dtype === "complex64");
1034
+ return Gt(this.shape, t, this.dtype === "complex64");
980
1035
  }
981
1036
  /**
982
1037
  * Returns the tensor data as a nested array. The transfer of data is done
@@ -985,7 +1040,7 @@ class D {
985
1040
  * @doc {heading: 'Tensors', subheading: 'Classes'}
986
1041
  */
987
1042
  arraySync() {
988
- return _t(this.shape, this.dataSync(), this.dtype === "complex64");
1043
+ return Gt(this.shape, this.dataSync(), this.dtype === "complex64");
989
1044
  }
990
1045
  /**
991
1046
  * Asynchronously downloads the values from the `tf.Tensor`. Returns a
@@ -995,11 +1050,11 @@ class D {
995
1050
  */
996
1051
  async data() {
997
1052
  this.throwIfDisposed();
998
- const t = F().read(this.dataId);
1053
+ const t = R().read(this.dataId);
999
1054
  if (this.dtype === "string") {
1000
- const e = await t;
1055
+ const n = await t;
1001
1056
  try {
1002
- return e.map((s) => Wt(s));
1057
+ return n.map((s) => jt(s));
1003
1058
  } catch {
1004
1059
  throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");
1005
1060
  }
@@ -1041,7 +1096,7 @@ class D {
1041
1096
  * @doc {heading: 'Tensors', subheading: 'Classes'}
1042
1097
  */
1043
1098
  dataToGPU(t) {
1044
- return this.throwIfDisposed(), F().readToGPU(this.dataId, t);
1099
+ return this.throwIfDisposed(), R().readToGPU(this.dataId, t);
1045
1100
  }
1046
1101
  /**
1047
1102
  * Synchronously downloads the values from the `tf.Tensor`. This blocks the
@@ -1051,10 +1106,10 @@ class D {
1051
1106
  */
1052
1107
  dataSync() {
1053
1108
  this.throwIfDisposed();
1054
- const t = F().readSync(this.dataId);
1109
+ const t = R().readSync(this.dataId);
1055
1110
  if (this.dtype === "string")
1056
1111
  try {
1057
- return t.map((e) => Wt(e));
1112
+ return t.map((n) => jt(n));
1058
1113
  } catch {
1059
1114
  throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");
1060
1115
  }
@@ -1063,7 +1118,7 @@ class D {
1063
1118
  /** Returns the underlying bytes of the tensor's data. */
1064
1119
  async bytes() {
1065
1120
  this.throwIfDisposed();
1066
- const t = await F().read(this.dataId);
1121
+ const t = await R().read(this.dataId);
1067
1122
  return this.dtype === "string" ? t : new Uint8Array(t.buffer);
1068
1123
  }
1069
1124
  /**
@@ -1072,7 +1127,7 @@ class D {
1072
1127
  * @doc {heading: 'Tensors', subheading: 'Classes'}
1073
1128
  */
1074
1129
  dispose() {
1075
- this.isDisposed || (this.kerasMask && this.kerasMask.dispose(), F().disposeTensor(this), this.isDisposedInternal = !0);
1130
+ this.isDisposed || (this.kerasMask && this.kerasMask.dispose(), R().disposeTensor(this), this.isDisposedInternal = !0);
1076
1131
  }
1077
1132
  get isDisposed() {
1078
1133
  return this.isDisposedInternal;
@@ -1105,26 +1160,26 @@ class D {
1105
1160
  * @doc {heading: 'Tensors', subheading: 'Classes'}
1106
1161
  */
1107
1162
  toString(t = !1) {
1108
- const e = this.dataSync();
1109
- return ln(e, this.shape, this.dtype, t);
1163
+ const n = this.dataSync();
1164
+ return hn(n, this.shape, this.dtype, t);
1110
1165
  }
1111
1166
  cast(t) {
1112
1167
  return this.throwIfDisposed(), Y.cast(this, t);
1113
1168
  }
1114
- variable(t = !0, e, s) {
1115
- return this.throwIfDisposed(), F().makeVariable(this, t, e, s);
1169
+ variable(t = !0, n, s) {
1170
+ return this.throwIfDisposed(), R().makeVariable(this, t, n, s);
1116
1171
  }
1117
1172
  }
1118
1173
  Object.defineProperty(D, Symbol.hasInstance, {
1119
- value: (n) => !!n && n.data != null && n.dataSync != null && n.throwIfDisposed != null
1174
+ value: (e) => !!e && e.data != null && e.dataSync != null && e.throwIfDisposed != null
1120
1175
  });
1121
- function ue() {
1176
+ function fe() {
1122
1177
  return Pt("Tensor", () => D);
1123
1178
  }
1124
- ue();
1125
- class ft extends D {
1126
- constructor(t, e, s, r) {
1127
- super(t.shape, t.dtype, t.dataId, r), this.trainable = e, this.name = s;
1179
+ fe();
1180
+ class gt extends D {
1181
+ constructor(t, n, s, r) {
1182
+ super(t.shape, t.dtype, t.dataId, r), this.trainable = n, this.name = s;
1128
1183
  }
1129
1184
  /**
1130
1185
  * Assign a new `tf.Tensor` to this variable. The new `tf.Tensor` must have
@@ -1137,20 +1192,20 @@ class ft extends D {
1137
1192
  assign(t) {
1138
1193
  if (t.dtype !== this.dtype)
1139
1194
  throw new Error(`dtype of the new value (${t.dtype}) and previous value (${this.dtype}) must match`);
1140
- if (!Ft(t.shape, this.shape))
1195
+ if (!Rt(t.shape, this.shape))
1141
1196
  throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);
1142
- F().disposeTensor(this), this.dataId = t.dataId, F().incRef(
1197
+ R().disposeTensor(this), this.dataId = t.dataId, R().incRef(
1143
1198
  this,
1144
1199
  null
1145
1200
  /* backend */
1146
1201
  );
1147
1202
  }
1148
1203
  dispose() {
1149
- F().disposeVariable(this), this.isDisposedInternal = !0;
1204
+ R().disposeVariable(this), this.isDisposedInternal = !0;
1150
1205
  }
1151
1206
  }
1152
- Object.defineProperty(ft, Symbol.hasInstance, {
1153
- value: (n) => n instanceof D && n.assign != null && n.assign instanceof Function
1207
+ Object.defineProperty(gt, Symbol.hasInstance, {
1208
+ value: (e) => e instanceof D && e.assign != null && e.assign instanceof Function
1154
1209
  });
1155
1210
  /**
1156
1211
  * @license
@@ -1168,45 +1223,48 @@ Object.defineProperty(ft, Symbol.hasInstance, {
1168
1223
  * limitations under the License.
1169
1224
  * =============================================================================
1170
1225
  */
1171
- var Kt;
1172
- (function(n) {
1173
- n.R0 = "R0", n.R1 = "R1", n.R2 = "R2", n.R3 = "R3", n.R4 = "R4", n.R5 = "R5", n.R6 = "R6";
1174
- })(Kt || (Kt = {}));
1226
+ var qt;
1227
+ (function(e) {
1228
+ e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6";
1229
+ })(qt || (qt = {}));
1175
1230
  var Tt;
1176
- (function(n) {
1177
- n.float32 = "float32", n.int32 = "int32", n.bool = "int32", n.complex64 = "complex64";
1231
+ (function(e) {
1232
+ e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64";
1178
1233
  })(Tt || (Tt = {}));
1179
1234
  var Et;
1180
- (function(n) {
1181
- n.float32 = "float32", n.int32 = "int32", n.bool = "bool", n.complex64 = "complex64";
1235
+ (function(e) {
1236
+ e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64";
1182
1237
  })(Et || (Et = {}));
1183
1238
  var At;
1184
- (function(n) {
1185
- n.float32 = "float32", n.int32 = "float32", n.bool = "float32", n.complex64 = "complex64";
1239
+ (function(e) {
1240
+ e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64";
1186
1241
  })(At || (At = {}));
1187
1242
  var Bt;
1188
- (function(n) {
1189
- n.float32 = "complex64", n.int32 = "complex64", n.bool = "complex64", n.complex64 = "complex64";
1243
+ (function(e) {
1244
+ e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64";
1190
1245
  })(Bt || (Bt = {}));
1191
- const gn = {
1246
+ const pn = {
1192
1247
  float32: At,
1193
1248
  int32: Tt,
1194
1249
  bool: Et,
1195
1250
  complex64: Bt
1196
1251
  };
1197
- function mn(n, t) {
1198
- if (n === "string" || t === "string") {
1199
- if (n === "string" && t === "string")
1252
+ function de(e, t) {
1253
+ if (e === "string" || t === "string") {
1254
+ if (e === "string" && t === "string")
1200
1255
  return "string";
1201
- throw new Error(`Can not upcast ${n} with ${t}`);
1256
+ throw new Error(`Can not upcast ${e} with ${t}`);
1202
1257
  }
1203
- return gn[n][t];
1258
+ return pn[e][t];
1259
+ }
1260
+ function ho(e) {
1261
+ return de(e, "int32");
1204
1262
  }
1205
- function he(n) {
1206
- return n != null && typeof n == "object" && "texture" in n && n.texture instanceof WebGLTexture;
1263
+ function ge(e) {
1264
+ return e != null && typeof e == "object" && "texture" in e && e.texture instanceof WebGLTexture;
1207
1265
  }
1208
- function de(n) {
1209
- return typeof GPUBuffer < "u" && n != null && typeof n == "object" && "buffer" in n && n.buffer instanceof GPUBuffer;
1266
+ function me(e) {
1267
+ return typeof GPUBuffer < "u" && e != null && typeof e == "object" && "buffer" in e && e.buffer instanceof GPUBuffer;
1210
1268
  }
1211
1269
  /**
1212
1270
  * @license
@@ -1224,36 +1282,36 @@ function de(n) {
1224
1282
  * limitations under the License.
1225
1283
  * =============================================================================
1226
1284
  */
1227
- function q(n, t) {
1228
- if (n.dtype === t.dtype)
1229
- return [n, t];
1230
- const e = mn(n.dtype, t.dtype);
1231
- return [n.cast(e), t.cast(e)];
1285
+ function q(e, t) {
1286
+ if (e.dtype === t.dtype)
1287
+ return [e, t];
1288
+ const n = de(e.dtype, t.dtype);
1289
+ return [e.cast(n), t.cast(n)];
1232
1290
  }
1233
- function so(n, t) {
1234
- return t.some((e) => e.id === n.id);
1291
+ function fo(e, t) {
1292
+ return t.some((n) => n.id === e.id);
1235
1293
  }
1236
- function fe(n) {
1294
+ function pe(e) {
1237
1295
  const t = [];
1238
- return ge(n, t, /* @__PURE__ */ new Set()), t;
1296
+ return ye(e, t, /* @__PURE__ */ new Set()), t;
1239
1297
  }
1240
- function ge(n, t, e) {
1241
- if (n == null)
1298
+ function ye(e, t, n) {
1299
+ if (e == null)
1242
1300
  return;
1243
- if (n instanceof D) {
1244
- t.push(n);
1301
+ if (e instanceof D) {
1302
+ t.push(e);
1245
1303
  return;
1246
1304
  }
1247
- if (!pn(n))
1305
+ if (!yn(e))
1248
1306
  return;
1249
- const s = n;
1307
+ const s = e;
1250
1308
  for (const r in s) {
1251
1309
  const a = s[r];
1252
- e.has(a) || (e.add(a), ge(a, t, e));
1310
+ n.has(a) || (n.add(a), ye(a, t, n));
1253
1311
  }
1254
1312
  }
1255
- function pn(n) {
1256
- return Array.isArray(n) || typeof n == "object";
1313
+ function yn(e) {
1314
+ return Array.isArray(e) || typeof e == "object";
1257
1315
  }
1258
1316
  /**
1259
1317
  * @license
@@ -1271,10 +1329,10 @@ function pn(n) {
1271
1329
  * limitations under the License.
1272
1330
  * =============================================================================
1273
1331
  */
1274
- function bt(n) {
1275
- return n.kernelName != null;
1332
+ function wt(e) {
1333
+ return e.kernelName != null;
1276
1334
  }
1277
- class qt {
1335
+ class Ht {
1278
1336
  constructor() {
1279
1337
  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 = /* @__PURE__ */ new WeakMap(), this.profiling = !1, this.activeProfile = {
1280
1338
  newBytes: 0,
@@ -1294,7 +1352,7 @@ class qt {
1294
1352
  }
1295
1353
  class et {
1296
1354
  constructor(t) {
1297
- this.ENV = t, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new qt();
1355
+ this.ENV = t, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new Ht();
1298
1356
  }
1299
1357
  async ready() {
1300
1358
  if (this.pendingBackendInit != null)
@@ -1303,8 +1361,8 @@ class et {
1303
1361
  if (this.backendInstance != null)
1304
1362
  return;
1305
1363
  const t = this.getSortedBackends();
1306
- for (let e = 0; e < t.length; e++) {
1307
- const s = t[e];
1364
+ for (let n = 0; n < t.length; n++) {
1365
+ const s = t[n];
1308
1366
  if (await this.initializeBackend(s).success) {
1309
1367
  await this.setBackend(s);
1310
1368
  return;
@@ -1316,8 +1374,8 @@ class et {
1316
1374
  if (this.pendingBackendInit != null)
1317
1375
  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`);
1318
1376
  if (this.backendInstance == null) {
1319
- const { name: t, asyncInit: e } = this.initializeBackendsAndReturnBest();
1320
- if (e)
1377
+ const { name: t, asyncInit: n } = this.initializeBackendsAndReturnBest();
1378
+ if (n)
1321
1379
  throw new Error(`The highest priority backend '${t}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);
1322
1380
  this.setBackend(t);
1323
1381
  }
@@ -1329,8 +1387,8 @@ class et {
1329
1387
  findBackend(t) {
1330
1388
  if (!(t in this.registry))
1331
1389
  if (t in this.registryFactory) {
1332
- const { asyncInit: e } = this.initializeBackend(t);
1333
- if (e)
1390
+ const { asyncInit: n } = this.initializeBackend(t);
1391
+ if (n)
1334
1392
  return null;
1335
1393
  } else
1336
1394
  return null;
@@ -1339,27 +1397,27 @@ class et {
1339
1397
  findBackendFactory(t) {
1340
1398
  return t in this.registryFactory ? this.registryFactory[t].factory : null;
1341
1399
  }
1342
- registerBackend(t, e, s = 1) {
1343
- return t in this.registryFactory ? (_(`${t} backend was already registered. Reusing existing backend factory.`), !1) : (this.registryFactory[t] = { factory: e, priority: s }, !0);
1400
+ registerBackend(t, n, s = 1) {
1401
+ return t in this.registryFactory ? (O(`${t} backend was already registered. Reusing existing backend factory.`), !1) : (this.registryFactory[t] = { factory: n, priority: s }, !0);
1344
1402
  }
1345
1403
  async setBackend(t) {
1346
1404
  if (this.registryFactory[t] == null)
1347
1405
  throw new Error(`Backend name '${t}' not found in registry`);
1348
1406
  if (this.backendName = t, this.registry[t] == null) {
1349
1407
  this.backendInstance = null;
1350
- const { success: e, asyncInit: s } = this.initializeBackend(t);
1351
- if (!(s ? await e : e))
1408
+ const { success: n, asyncInit: s } = this.initializeBackend(t);
1409
+ if (!(s ? await n : n))
1352
1410
  return !1;
1353
1411
  }
1354
- return this.backendInstance = this.registry[t], this.setupRegisteredKernels(), this.profiler = new sn(this.backendInstance), !0;
1412
+ return this.backendInstance = this.registry[t], this.setupRegisteredKernels(), this.profiler = new an(this.backendInstance), !0;
1355
1413
  }
1356
1414
  setupRegisteredKernels() {
1357
- Vt(this.backendName).forEach((e) => {
1358
- e.setupFunc != null && e.setupFunc(this.backendInstance);
1415
+ Wt(this.backendName).forEach((n) => {
1416
+ n.setupFunc != null && n.setupFunc(this.backendInstance);
1359
1417
  });
1360
1418
  }
1361
1419
  disposeRegisteredKernels(t) {
1362
- Vt(t).forEach((s) => {
1420
+ Wt(t).forEach((s) => {
1363
1421
  s.disposeFunc != null && s.disposeFunc(this.registry[t]);
1364
1422
  });
1365
1423
  }
@@ -1370,18 +1428,18 @@ class et {
1370
1428
  * there is no backend in the factory registry.
1371
1429
  */
1372
1430
  initializeBackend(t) {
1373
- const e = this.registryFactory[t];
1374
- if (e == null)
1431
+ const n = this.registryFactory[t];
1432
+ if (n == null)
1375
1433
  throw new Error(`Cannot initialize backend ${t}, no registration found.`);
1376
1434
  try {
1377
- const s = e.factory();
1378
- if (s && !(s instanceof ve) && typeof s.then == "function") {
1379
- const r = ++this.pendingBackendInitId, a = s.then((o) => r < this.pendingBackendInitId ? !1 : (this.registry[t] = o, this.pendingBackendInit = null, !0)).catch((o) => (r < this.pendingBackendInitId || (this.pendingBackendInit = null, _(`Initialization of backend ${t} failed`), _(o.stack || o.message)), !1));
1435
+ const s = n.factory();
1436
+ if (s && !(s instanceof Fe) && typeof s.then == "function") {
1437
+ const r = ++this.pendingBackendInitId, a = s.then((o) => r < this.pendingBackendInitId ? !1 : (this.registry[t] = o, this.pendingBackendInit = null, !0)).catch((o) => (r < this.pendingBackendInitId || (this.pendingBackendInit = null, O(`Initialization of backend ${t} failed`), O(o.stack || o.message)), !1));
1380
1438
  return this.pendingBackendInit = a, { success: a, asyncInit: !0 };
1381
1439
  } else
1382
1440
  return this.registry[t] = s, { success: !0, asyncInit: !1 };
1383
1441
  } catch (s) {
1384
- return _(`Initialization of backend ${t} failed`), _(s.stack || s.message), { success: !1, asyncInit: !1 };
1442
+ return O(`Initialization of backend ${t} failed`), O(s.stack || s.message), { success: !1, asyncInit: !1 };
1385
1443
  }
1386
1444
  }
1387
1445
  removeBackend(t) {
@@ -1392,44 +1450,44 @@ class et {
1392
1450
  getSortedBackends() {
1393
1451
  if (Object.keys(this.registryFactory).length === 0)
1394
1452
  throw new Error("No backend found in registry.");
1395
- return Object.keys(this.registryFactory).sort((t, e) => this.registryFactory[e].priority - this.registryFactory[t].priority);
1453
+ return Object.keys(this.registryFactory).sort((t, n) => this.registryFactory[n].priority - this.registryFactory[t].priority);
1396
1454
  }
1397
1455
  initializeBackendsAndReturnBest() {
1398
1456
  const t = this.getSortedBackends();
1399
- for (let e = 0; e < t.length; e++) {
1400
- const s = t[e], { success: r, asyncInit: a } = this.initializeBackend(s);
1457
+ for (let n = 0; n < t.length; n++) {
1458
+ const s = t[n], { success: r, asyncInit: a } = this.initializeBackend(s);
1401
1459
  if (a || r)
1402
1460
  return { name: s, asyncInit: a };
1403
1461
  }
1404
1462
  throw new Error("Could not initialize any backends, all backend initializations failed.");
1405
1463
  }
1406
- moveData(t, e) {
1407
- const s = this.state.tensorInfo.get(e), r = s.backend, a = this.readSync(e), o = r.refCount(e);
1408
- r.disposeData(e, !0), s.backend = t, t.move(e, a, s.shape, s.dtype, o), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++;
1464
+ moveData(t, n) {
1465
+ const s = this.state.tensorInfo.get(n), r = s.backend, a = this.readSync(n), o = r.refCount(n);
1466
+ r.disposeData(n, !0), s.backend = t, t.move(n, a, s.shape, s.dtype, o), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++;
1409
1467
  }
1410
- tidy(t, e) {
1468
+ tidy(t, n) {
1411
1469
  let s = null;
1412
- if (e == null) {
1470
+ if (n == null) {
1413
1471
  if (typeof t != "function")
1414
1472
  throw new Error("Please provide a function to tidy()");
1415
- e = t;
1473
+ n = t;
1416
1474
  } else {
1417
1475
  if (typeof t != "string" && !(t instanceof String))
1418
1476
  throw new Error("When calling with two arguments, the first argument to tidy() must be a string");
1419
- if (typeof e != "function")
1477
+ if (typeof n != "function")
1420
1478
  throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");
1421
1479
  s = t;
1422
1480
  }
1423
1481
  let r;
1424
- return this.scopedRun(() => this.startScope(s), () => this.endScope(r), () => (r = e(), r instanceof Promise && console.error("Cannot return a Promise inside of tidy."), r));
1482
+ return this.scopedRun(() => this.startScope(s), () => this.endScope(r), () => (r = n(), r instanceof Promise && console.error("Cannot return a Promise inside of tidy."), r));
1425
1483
  }
1426
- scopedRun(t, e, s) {
1484
+ scopedRun(t, n, s) {
1427
1485
  t();
1428
1486
  try {
1429
1487
  const r = s();
1430
- return e(), r;
1488
+ return n(), r;
1431
1489
  } catch (r) {
1432
- throw e(), r;
1490
+ throw n(), r;
1433
1491
  }
1434
1492
  }
1435
1493
  nextTensorId() {
@@ -1445,18 +1503,18 @@ class et {
1445
1503
  * execution.
1446
1504
  */
1447
1505
  clone(t) {
1448
- const e = g.runKernel(ae, { x: t }), s = { x: t }, r = (o) => ({
1506
+ const n = g.runKernel(ie, { x: t }), s = { x: t }, r = (o) => ({
1449
1507
  x: () => {
1450
1508
  const i = "float32", c = { x: o }, l = { dtype: i };
1451
1509
  return g.runKernel(
1452
- re,
1510
+ oe,
1453
1511
  c,
1454
1512
  // tslint:disable-next-line: no-unnecessary-type-assertion
1455
1513
  l
1456
1514
  );
1457
1515
  }
1458
1516
  }), a = [];
1459
- return this.addTapeNode(this.state.activeScope.name, s, [e], r, a, {}), e;
1517
+ return this.addTapeNode(this.state.activeScope.name, s, [n], r, a, {}), n;
1460
1518
  }
1461
1519
  /**
1462
1520
  * Execute a kernel with the given name and return the output tensor.
@@ -1471,21 +1529,21 @@ class et {
1471
1529
  * for the backprop computation. These are booleans since the output
1472
1530
  * tensors are not visible to the user.
1473
1531
  */
1474
- runKernel(t, e, s) {
1475
- if (this.backendName == null && this.backend, !(Gt(t, this.backendName) != null))
1532
+ runKernel(t, n, s) {
1533
+ if (this.backendName == null && this.backend, !(zt(t, this.backendName) != null))
1476
1534
  throw new Error(`Kernel '${t}' not registered for backend '${this.backendName}'`);
1477
- return this.runKernelFunc({ kernelName: t, inputs: e, attrs: s });
1535
+ return this.runKernelFunc({ kernelName: t, inputs: n, attrs: s });
1478
1536
  }
1479
1537
  shouldCheckForMemLeaks() {
1480
1538
  return this.ENV.getBool("IS_TEST");
1481
1539
  }
1482
- checkKernelForMemLeak(t, e, s) {
1540
+ checkKernelForMemLeak(t, n, s) {
1483
1541
  const r = this.backend.numDataIds();
1484
1542
  let a = 0;
1485
1543
  s.forEach((c) => {
1486
1544
  a += c.dtype === "complex64" ? 3 : 1;
1487
1545
  });
1488
- const o = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], i = r - e - a - o;
1546
+ const o = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], i = r - n - a - o;
1489
1547
  if (i > 0)
1490
1548
  throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${t}'`);
1491
1549
  }
@@ -1495,60 +1553,60 @@ class et {
1495
1553
  * Use `runKernel` to execute kernels from outside of engine.
1496
1554
  */
1497
1555
  runKernelFunc(t) {
1498
- let e, s = [];
1556
+ let n, s = [];
1499
1557
  const r = this.isTapeOn(), a = this.state.numBytes, o = this.state.numTensors;
1500
1558
  this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0);
1501
1559
  let i;
1502
1560
  this.backendName == null && this.backend;
1503
1561
  let c;
1504
- const l = bt(t) ? t.kernelName : this.state.activeScope != null ? this.state.activeScope.name : "";
1505
- if (bt(t)) {
1506
- const { kernelName: p, inputs: f, attrs: w } = t;
1562
+ const l = wt(t) ? t.kernelName : this.state.activeScope != null ? this.state.activeScope.name : "";
1563
+ if (wt(t)) {
1564
+ const { kernelName: p, inputs: d, attrs: w } = t;
1507
1565
  this.backendName == null && this.backend;
1508
- const I = Gt(p, this.backendName);
1566
+ const I = zt(p, this.backendName);
1509
1567
  y(I != null, () => `Cannot find registered kernel '${p}' for backend '${this.backendName}'`), i = () => {
1510
- const O = this.backend.numDataIds();
1511
- c = I.kernelFunc({ inputs: f, attrs: w, backend: this.backend });
1568
+ const _ = this.backend.numDataIds();
1569
+ c = I.kernelFunc({ inputs: d, attrs: w, backend: this.backend });
1512
1570
  const J = Array.isArray(c) ? c : [c];
1513
- this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(p, O, J);
1571
+ this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(p, _, J);
1514
1572
  const X = J.map((rt) => rt.rank != null ? rt : this.makeTensorFromTensorInfo(rt));
1515
1573
  if (r) {
1516
- const rt = this.getTensorsForGradient(p, f, X);
1574
+ const rt = this.getTensorsForGradient(p, d, X);
1517
1575
  s = this.saveTensorsForBackwardMode(rt);
1518
1576
  }
1519
1577
  return X;
1520
1578
  };
1521
1579
  } else {
1522
- const { forwardFunc: p } = t, f = (w) => {
1580
+ const { forwardFunc: p } = t, d = (w) => {
1523
1581
  r && (s = w.map((I) => this.keep(this.clone(I))));
1524
1582
  };
1525
1583
  i = () => {
1526
1584
  const w = this.backend.numDataIds();
1527
- c = this.tidy(() => p(this.backend, f));
1585
+ c = this.tidy(() => p(this.backend, d));
1528
1586
  const I = Array.isArray(c) ? c : [c];
1529
1587
  return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(l, w, I), I;
1530
1588
  };
1531
1589
  }
1532
- const { inputs: u, attrs: h } = t, d = bt(t) ? null : t.backwardsFunc;
1590
+ const { inputs: u, attrs: h } = t, f = wt(t) ? null : t.backwardsFunc;
1533
1591
  let m;
1534
1592
  return this.scopedRun(
1535
1593
  // Stop recording to a tape when running a kernel.
1536
1594
  () => this.state.kernelDepth++,
1537
1595
  () => this.state.kernelDepth--,
1538
1596
  () => {
1539
- !this.ENV.getBool("DEBUG") && !this.state.profiling ? e = i() : (m = this.profiler.profileKernel(l, u, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(m), e = m.outputs);
1597
+ !this.ENV.getBool("DEBUG") && !this.state.profiling ? n = i() : (m = this.profiler.profileKernel(l, u, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(m), n = m.outputs);
1540
1598
  }
1541
- ), r && this.addTapeNode(l, u, e, d, s, h), this.state.profiling && this.state.activeProfile.kernels.push({
1599
+ ), r && this.addTapeNode(l, u, n, f, s, h), this.state.profiling && this.state.activeProfile.kernels.push({
1542
1600
  name: l,
1543
1601
  bytesAdded: this.state.numBytes - a,
1544
1602
  totalBytesSnapshot: this.state.numBytes,
1545
1603
  tensorsAdded: this.state.numTensors - o,
1546
1604
  totalTensorsSnapshot: this.state.numTensors,
1547
1605
  inputShapes: Object.keys(u).map((p) => u[p] != null ? u[p].shape : null),
1548
- outputShapes: e.map((p) => p.shape),
1606
+ outputShapes: n.map((p) => p.shape),
1549
1607
  kernelTimeMs: m.timeMs,
1550
1608
  extraInfo: m.extraInfo
1551
- }), Array.isArray(c) ? e : e[0];
1609
+ }), Array.isArray(c) ? n : n[0];
1552
1610
  }
1553
1611
  /**
1554
1612
  * Saves tensors used in forward mode for use in backward mode.
@@ -1565,12 +1623,12 @@ class et {
1565
1623
  * @param inputs a map of input tensors.
1566
1624
  * @param outputs an array of output tensors from forward mode of kernel.
1567
1625
  */
1568
- getTensorsForGradient(t, e, s) {
1569
- const r = zt(t);
1626
+ getTensorsForGradient(t, n, s) {
1627
+ const r = Vt(t);
1570
1628
  if (r != null) {
1571
1629
  const a = r.inputsToSave || [], o = r.outputsToSave || [];
1572
1630
  let i;
1573
- r.saveAllInputs ? (y(Array.isArray(e), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(e).map((l) => e[l])) : i = a.map((l) => e[l]);
1631
+ r.saveAllInputs ? (y(Array.isArray(n), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(n).map((l) => n[l])) : i = a.map((l) => n[l]);
1574
1632
  const c = s.filter((l, u) => o[u]);
1575
1633
  return i.concat(c);
1576
1634
  }
@@ -1581,15 +1639,15 @@ class et {
1581
1639
  * tensor with the provided shape, dtype and values. It always
1582
1640
  * creates a new data id and writes the values to the underlying backend.
1583
1641
  */
1584
- makeTensor(t, e, s, r) {
1642
+ makeTensor(t, n, s, r) {
1585
1643
  if (t == null)
1586
1644
  throw new Error("Values passed to engine.makeTensor() are null");
1587
1645
  s = s || "float32", r = r || this.backend;
1588
1646
  let a = t;
1589
- s === "string" && Dt(t[0]) && (a = t.map((c) => nn(c)));
1590
- const o = r.write(a, e, s), i = new D(e, s, o, this.nextTensorId());
1647
+ s === "string" && Dt(t[0]) && (a = t.map((c) => ue(c)));
1648
+ const o = r.write(a, n, s), i = new D(n, s, o, this.nextTensorId());
1591
1649
  if (this.trackTensor(i, r), s === "string") {
1592
- const c = this.state.tensorInfo.get(o), l = xe(a);
1650
+ const c = this.state.tensorInfo.get(o), l = Le(a);
1593
1651
  this.state.numBytes += l - c.bytes, c.bytes = l;
1594
1652
  }
1595
1653
  return i;
@@ -1600,9 +1658,9 @@ class et {
1600
1658
  * a new data id, only increments the ref count used in memory tracking.
1601
1659
  * @deprecated
1602
1660
  */
1603
- makeTensorFromDataId(t, e, s, r) {
1661
+ makeTensorFromDataId(t, n, s, r) {
1604
1662
  s = s || "float32";
1605
- const a = { dataId: t, shape: e, dtype: s };
1663
+ const a = { dataId: t, shape: n, dtype: s };
1606
1664
  return this.makeTensorFromTensorInfo(a, r);
1607
1665
  }
1608
1666
  /**
@@ -1610,52 +1668,52 @@ class et {
1610
1668
  * around an existing data id in TensorInfo. It doesn't create a new data id,
1611
1669
  * only increments the ref count used in memory tracking.
1612
1670
  */
1613
- makeTensorFromTensorInfo(t, e) {
1671
+ makeTensorFromTensorInfo(t, n) {
1614
1672
  const { dataId: s, shape: r, dtype: a } = t, o = new D(r, a, s, this.nextTensorId());
1615
- return this.trackTensor(o, e), o;
1673
+ return this.trackTensor(o, n), o;
1616
1674
  }
1617
- makeVariable(t, e = !0, s, r) {
1675
+ makeVariable(t, n = !0, s, r) {
1618
1676
  s = s || this.nextVariableId().toString(), r != null && r !== t.dtype && (t = t.cast(r));
1619
- const a = new ft(t, e, s, this.nextTensorId());
1677
+ const a = new gt(t, n, s, this.nextTensorId());
1620
1678
  if (this.state.registeredVariables[a.name] != null)
1621
1679
  throw new Error(`Variable with name ${a.name} was already registered`);
1622
1680
  return this.state.registeredVariables[a.name] = a, this.incRef(a, this.backend), a;
1623
1681
  }
1624
- trackTensor(t, e) {
1682
+ trackTensor(t, n) {
1625
1683
  this.state.numTensors++, t.dtype === "string" && this.state.numStringTensors++;
1626
1684
  let s = 0;
1627
- t.dtype !== "complex64" && t.dtype !== "string" && (s = t.size * St(t.dtype)), this.state.numBytes += s, this.state.tensorInfo.has(t.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(t.dataId, {
1628
- backend: e || this.backend,
1685
+ t.dtype !== "complex64" && t.dtype !== "string" && (s = t.size * kt(t.dtype)), this.state.numBytes += s, this.state.tensorInfo.has(t.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(t.dataId, {
1686
+ backend: n || this.backend,
1629
1687
  dtype: t.dtype,
1630
1688
  shape: t.shape,
1631
1689
  bytes: s
1632
- })), t instanceof ft || this.track(t);
1690
+ })), t instanceof gt || this.track(t);
1633
1691
  }
1634
1692
  // Track the tensor by dataId and increase the refCount for the dataId in the
1635
1693
  // backend.
1636
1694
  // TODO(pyu10055): This is currently used by makeVariable method, to increase
1637
1695
  // refCount on the backend for the dataId. It can potentially be replaced with
1638
1696
  // Identity op indead of calling backend directly.
1639
- incRef(t, e) {
1640
- this.trackTensor(t, e), this.backend.incRef(t.dataId);
1697
+ incRef(t, n) {
1698
+ this.trackTensor(t, n), this.backend.incRef(t.dataId);
1641
1699
  }
1642
- removeDataId(t, e) {
1643
- this.state.tensorInfo.has(t) && this.state.tensorInfo.get(t).backend === e && (this.state.tensorInfo.delete(t), this.state.numDataBuffers--);
1700
+ removeDataId(t, n) {
1701
+ this.state.tensorInfo.has(t) && this.state.tensorInfo.get(t).backend === n && (this.state.tensorInfo.delete(t), this.state.numDataBuffers--);
1644
1702
  }
1645
1703
  disposeTensor(t) {
1646
1704
  if (!this.state.tensorInfo.has(t.dataId))
1647
1705
  return;
1648
- const e = this.state.tensorInfo.get(t.dataId);
1649
- if (this.state.numTensors--, t.dtype === "string" && (this.state.numStringTensors--, this.state.numBytes -= e.bytes), t.dtype !== "complex64" && t.dtype !== "string") {
1650
- const s = t.size * St(t.dtype);
1706
+ const n = this.state.tensorInfo.get(t.dataId);
1707
+ if (this.state.numTensors--, t.dtype === "string" && (this.state.numStringTensors--, this.state.numBytes -= n.bytes), t.dtype !== "complex64" && t.dtype !== "string") {
1708
+ const s = t.size * kt(t.dtype);
1651
1709
  this.state.numBytes -= s;
1652
1710
  }
1653
- e.backend.disposeData(t.dataId) && this.removeDataId(t.dataId, e.backend);
1711
+ n.backend.disposeData(t.dataId) && this.removeDataId(t.dataId, n.backend);
1654
1712
  }
1655
1713
  disposeVariables() {
1656
1714
  for (const t in this.state.registeredVariables) {
1657
- const e = this.state.registeredVariables[t];
1658
- this.disposeVariable(e);
1715
+ const n = this.state.registeredVariables[t];
1716
+ this.disposeVariable(n);
1659
1717
  }
1660
1718
  }
1661
1719
  disposeVariable(t) {
@@ -1667,8 +1725,8 @@ class et {
1667
1725
  }
1668
1726
  async profile(t) {
1669
1727
  this.state.profiling = !0;
1670
- const e = this.state.numBytes, s = this.state.numTensors;
1671
- this.state.activeProfile.kernels = [], this.state.activeProfile.result = await t(), this.state.profiling = !1, this.state.activeProfile.peakBytes = Math.max(...this.state.activeProfile.kernels.map((r) => r.totalBytesSnapshot)), this.state.activeProfile.newBytes = this.state.numBytes - e, this.state.activeProfile.newTensors = this.state.numTensors - s;
1728
+ const n = this.state.numBytes, s = this.state.numTensors;
1729
+ this.state.activeProfile.kernels = [], this.state.activeProfile.result = await t(), this.state.profiling = !1, this.state.activeProfile.peakBytes = Math.max(...this.state.activeProfile.kernels.map((r) => r.totalBytesSnapshot)), this.state.activeProfile.newBytes = this.state.numBytes - n, this.state.activeProfile.newTensors = this.state.numTensors - s;
1672
1730
  for (const r of this.state.activeProfile.kernels)
1673
1731
  r.kernelTimeMs = await r.kernelTimeMs, r.extraInfo = await r.extraInfo;
1674
1732
  return this.state.activeProfile;
@@ -1676,12 +1734,12 @@ class et {
1676
1734
  isTapeOn() {
1677
1735
  return this.state.gradientDepth > 0 && this.state.kernelDepth === 0;
1678
1736
  }
1679
- addTapeNode(t, e, s, r, a, o) {
1680
- const i = { id: this.state.nextTapeNodeId++, kernelName: t, inputs: e, outputs: s, saved: a }, c = zt(t);
1737
+ addTapeNode(t, n, s, r, a, o) {
1738
+ const i = { id: this.state.nextTapeNodeId++, kernelName: t, inputs: n, outputs: s, saved: a }, c = Vt(t);
1681
1739
  c != null && (r = c.gradFunc), r != null && (i.gradient = (l) => (l = l.map((u, h) => {
1682
1740
  if (u == null) {
1683
- const d = s[h], m = te(d.size, d.dtype);
1684
- return this.makeTensor(m, d.shape, d.dtype);
1741
+ const f = s[h], m = ne(f.size, f.dtype);
1742
+ return this.makeTensor(m, f.shape, f.dtype);
1685
1743
  }
1686
1744
  return u;
1687
1745
  }), r(l.length > 1 ? l : l[0], a, o))), this.state.activeTape.push(i);
@@ -1700,25 +1758,25 @@ class et {
1700
1758
  * as scope() without the need for a function closure.
1701
1759
  */
1702
1760
  startScope(t) {
1703
- const e = {
1761
+ const n = {
1704
1762
  track: [],
1705
1763
  name: "unnamed scope",
1706
1764
  id: this.state.nextScopeId++
1707
1765
  };
1708
- t && (e.name = t), this.state.scopeStack.push(e), this.state.activeScope = e;
1766
+ t && (n.name = t), this.state.scopeStack.push(n), this.state.activeScope = n;
1709
1767
  }
1710
1768
  /**
1711
1769
  * End a scope. Use this with startScope() to achieve the same functionality
1712
1770
  * as scope() without the need for a function closure.
1713
1771
  */
1714
1772
  endScope(t) {
1715
- const e = fe(t), s = new Set(e.map((a) => a.id));
1773
+ const n = pe(t), s = new Set(n.map((a) => a.id));
1716
1774
  for (let a = 0; a < this.state.activeScope.track.length; a++) {
1717
1775
  const o = this.state.activeScope.track[a];
1718
1776
  !o.kept && !s.has(o.id) && o.dispose();
1719
1777
  }
1720
1778
  const r = this.state.scopeStack.pop();
1721
- this.state.activeScope = this.state.scopeStack.length === 0 ? null : this.state.scopeStack[this.state.scopeStack.length - 1], e.forEach((a) => {
1779
+ this.state.activeScope = this.state.scopeStack.length === 0 ? null : this.state.scopeStack[this.state.scopeStack.length - 1], n.forEach((a) => {
1722
1780
  !a.kept && a.scopeId === r.id && this.track(a);
1723
1781
  });
1724
1782
  }
@@ -1728,25 +1786,25 @@ class et {
1728
1786
  * was not a function of that `x`. It also takes optional dy to multiply the
1729
1787
  * gradient, which defaults to `1`.
1730
1788
  */
1731
- gradients(t, e, s, r = !1) {
1732
- if (y(e.length > 0, () => "gradients() received an empty list of xs."), s != null && s.dtype !== "float32")
1789
+ gradients(t, n, s, r = !1) {
1790
+ if (y(n.length > 0, () => "gradients() received an empty list of xs."), s != null && s.dtype !== "float32")
1733
1791
  throw new Error(`dy must have 'float32' dtype, but has '${s.dtype}'`);
1734
1792
  const a = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", t));
1735
1793
  y(a instanceof D, () => "The result y returned by f() must be a tensor.");
1736
- const o = on(this.state.activeTape, e, a);
1737
- if (!r && o.length === 0 && e.length > 0)
1794
+ const o = ln(this.state.activeTape, n, a);
1795
+ if (!r && o.length === 0 && n.length > 0)
1738
1796
  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.");
1739
1797
  return this.tidy("backward", () => {
1740
1798
  const i = {};
1741
- i[a.id] = s ?? yn(a.shape), cn(
1799
+ i[a.id] = s ?? bn(a.shape), un(
1742
1800
  i,
1743
1801
  o,
1744
1802
  // Pass the tidy function to avoid circular dep with `tape.ts`.
1745
1803
  (l) => this.tidy(l),
1746
1804
  // Pass an add function to avoide a circular dep with `tape.ts`.
1747
- bn
1805
+ wn
1748
1806
  );
1749
- const c = e.map((l) => i[l.id]);
1807
+ const c = n.map((l) => i[l.id]);
1750
1808
  return this.state.gradientDepth === 0 && (this.state.activeTape.forEach((l) => {
1751
1809
  for (const u of l.saved)
1752
1810
  u.dispose();
@@ -1754,19 +1812,19 @@ class et {
1754
1812
  });
1755
1813
  }
1756
1814
  customGrad(t) {
1757
- return y(kt(t), () => "The f passed in customGrad(f) must be a function."), (...e) => {
1758
- y(e.every((i) => i instanceof D), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors");
1815
+ return y(ht(t), () => "The f passed in customGrad(f) must be a function."), (...n) => {
1816
+ y(n.every((i) => i instanceof D), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors");
1759
1817
  let s;
1760
1818
  const r = {};
1761
- e.forEach((i, c) => {
1819
+ n.forEach((i, c) => {
1762
1820
  r[c] = i;
1763
1821
  });
1764
- const a = (i, c) => (s = t(...e, c), y(s.value instanceof D, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), y(kt(s.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), s.value), o = (i, c) => {
1822
+ const a = (i, c) => (s = t(...n, c), y(s.value instanceof D, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), y(ht(s.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), s.value), o = (i, c) => {
1765
1823
  const l = s.gradFunc(i, c), u = Array.isArray(l) ? l : [l];
1766
- y(u.length === e.length, () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."), y(u.every((d) => d instanceof D), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");
1824
+ y(u.length === n.length, () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."), y(u.every((f) => f instanceof D), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");
1767
1825
  const h = {};
1768
- return u.forEach((d, m) => {
1769
- h[m] = () => d;
1826
+ return u.forEach((f, m) => {
1827
+ h[m] = () => f;
1770
1828
  }), h;
1771
1829
  };
1772
1830
  return this.runKernelFunc({
@@ -1782,12 +1840,12 @@ class et {
1782
1840
  read(t) {
1783
1841
  return this.state.tensorInfo.get(t).backend.read(t);
1784
1842
  }
1785
- readToGPU(t, e) {
1786
- return this.state.tensorInfo.get(t).backend.readToGPU(t, e);
1843
+ readToGPU(t, n) {
1844
+ return this.state.tensorInfo.get(t).backend.readToGPU(t, n);
1787
1845
  }
1788
1846
  async time(t) {
1789
- const e = dt(), s = await this.backend.time(t);
1790
- return s.wallMs = dt() - e, s;
1847
+ const n = dt(), s = await this.backend.time(t);
1848
+ return s.wallMs = dt() - n, s;
1791
1849
  }
1792
1850
  /**
1793
1851
  * Tracks a Tensor in the current scope to be automatically cleaned up
@@ -1806,7 +1864,7 @@ class et {
1806
1864
  * registered backend factories.
1807
1865
  */
1808
1866
  reset() {
1809
- this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new qt();
1867
+ this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new Ht();
1810
1868
  for (const t in this.registry)
1811
1869
  this.disposeRegisteredKernels(t), this.registry[t].dispose(), delete this.registry[t];
1812
1870
  this.backendName = null, this.backendInstance = null, this.pendingBackendInit = null;
@@ -1814,22 +1872,22 @@ class et {
1814
1872
  }
1815
1873
  et.nextTensorId = 0;
1816
1874
  et.nextVariableId = 0;
1817
- function yn(n) {
1818
- const t = Le(z(n), "float32");
1819
- return g.makeTensor(t, n, "float32");
1875
+ function bn(e) {
1876
+ const t = Ge(z(e), "float32");
1877
+ return g.makeTensor(t, e, "float32");
1820
1878
  }
1821
- function me() {
1822
- const n = ne();
1823
- if (n._tfengine == null) {
1824
- const t = new Oe(n);
1825
- n._tfengine = new et(t);
1879
+ function be() {
1880
+ const e = re();
1881
+ if (e._tfengine == null) {
1882
+ const t = new Ue(e);
1883
+ e._tfengine = new et(t);
1826
1884
  }
1827
- return ze(n._tfengine.ENV), dn(() => n._tfengine), n._tfengine;
1885
+ return je(e._tfengine.ENV), gn(() => e._tfengine), e._tfengine;
1828
1886
  }
1829
- const g = me();
1830
- function bn(n, t) {
1831
- const e = { a: n, b: t };
1832
- return g.runKernel(se, e);
1887
+ const g = be();
1888
+ function wn(e, t) {
1889
+ const n = { a: e, b: t };
1890
+ return g.runKernel(ae, n);
1833
1891
  }
1834
1892
  /**
1835
1893
  * @license
@@ -1847,15 +1905,15 @@ function bn(n, t) {
1847
1905
  * limitations under the License.
1848
1906
  * =============================================================================
1849
1907
  */
1850
- function wn() {
1908
+ function Sn() {
1851
1909
  return typeof window < "u" && window.document != null || //@ts-ignore
1852
1910
  typeof WorkerGlobalScope < "u";
1853
1911
  }
1854
1912
  const B = k();
1855
- B.registerFlag("DEBUG", () => !1, (n) => {
1856
- n && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.");
1913
+ B.registerFlag("DEBUG", () => !1, (e) => {
1914
+ e && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.");
1857
1915
  });
1858
- B.registerFlag("IS_BROWSER", () => wn());
1916
+ B.registerFlag("IS_BROWSER", () => Sn());
1859
1917
  B.registerFlag("IS_NODE", () => typeof Z < "u" && typeof Z.versions < "u" && typeof Z.versions.node < "u");
1860
1918
  B.registerFlag("IS_CHROME", () => typeof navigator < "u" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor));
1861
1919
  B.registerFlag("IS_SAFARI", () => typeof navigator < "u" && navigator != null && navigator.userAgent != null && /Safari/.test(navigator.userAgent) && /Apple/.test(navigator.vendor));
@@ -1883,57 +1941,57 @@ B.registerFlag("USE_SETTIMEOUTCUSTOM", () => !1);
1883
1941
  * limitations under the License.
1884
1942
  * =============================================================================
1885
1943
  */
1886
- function Sn(n, t) {
1887
- let e = n;
1888
- if (R(n))
1889
- return t === "string" ? [] : [n.length];
1890
- if (he(n)) {
1891
- const r = n.channels || "RGBA";
1892
- return [n.height, n.width * r.length];
1893
- } else if (de(n))
1894
- return [n.buffer.size / (t == null ? 4 : St(t))];
1895
- if (!Array.isArray(n))
1944
+ function kn(e, t) {
1945
+ let n = e;
1946
+ if (F(e))
1947
+ return t === "string" ? [] : [e.length];
1948
+ if (ge(e)) {
1949
+ const r = e.channels || "RGBA";
1950
+ return [e.height, e.width * r.length];
1951
+ } else if (me(e))
1952
+ return [e.buffer.size / (t == null ? 4 : kt(t))];
1953
+ if (!Array.isArray(e))
1896
1954
  return [];
1897
1955
  const s = [];
1898
- for (; Array.isArray(e) || R(e) && t !== "string"; )
1899
- s.push(e.length), e = e[0];
1900
- return Array.isArray(n) && k().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && pe(n, s, []), s;
1956
+ for (; Array.isArray(n) || F(n) && t !== "string"; )
1957
+ s.push(n.length), n = n[0];
1958
+ return Array.isArray(e) && k().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && we(e, s, []), s;
1901
1959
  }
1902
- function pe(n, t, e) {
1903
- if (e = e || [], !Array.isArray(n) && !R(n)) {
1904
- y(t.length === 0, () => `Element arr[${e.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);
1960
+ function we(e, t, n) {
1961
+ if (n = n || [], !Array.isArray(e) && !F(e)) {
1962
+ y(t.length === 0, () => `Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);
1905
1963
  return;
1906
1964
  }
1907
- y(t.length > 0, () => `Element arr[${e.join("][")}] should be a primitive, but is an array of ${n.length} elements`), y(n.length === t[0], () => `Element arr[${e.join("][")}] should have ${t[0]} elements, but has ${n.length} elements`);
1965
+ y(t.length > 0, () => `Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`), y(e.length === t[0], () => `Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);
1908
1966
  const s = t.slice(1);
1909
- for (let r = 0; r < n.length; ++r)
1910
- pe(n[r], s, e.concat(r));
1967
+ for (let r = 0; r < e.length; ++r)
1968
+ we(e[r], s, n.concat(r));
1911
1969
  }
1912
- function Ht(n, t, e, s) {
1913
- if (n !== "string_or_numeric") {
1914
- if (n == null)
1970
+ function Jt(e, t, n, s) {
1971
+ if (e !== "string_or_numeric") {
1972
+ if (e == null)
1915
1973
  throw new Error("Expected dtype cannot be null.");
1916
- if (n !== "numeric" && n !== t || n === "numeric" && t === "string")
1917
- throw new Error(`Argument '${e}' passed to '${s}' must be ${n} tensor, but got ${t} tensor`);
1974
+ if (e !== "numeric" && e !== t || e === "numeric" && t === "string")
1975
+ throw new Error(`Argument '${n}' passed to '${s}' must be ${e} tensor, but got ${t} tensor`);
1918
1976
  }
1919
1977
  }
1920
- function T(n, t, e, s = "numeric") {
1921
- if (n instanceof ue())
1922
- return Ht(s, n.dtype, t, e), n;
1923
- let r = mt(n);
1924
- if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), Ht(s, r, t, e), n == null || !R(n) && !Array.isArray(n) && typeof n != "number" && typeof n != "boolean" && typeof n != "string") {
1925
- const c = n == null ? "null" : n.constructor.name;
1926
- throw new Error(`Argument '${t}' passed to '${e}' must be a Tensor or TensorLike, but got '${c}'`);
1978
+ function T(e, t, n, s = "numeric") {
1979
+ if (e instanceof fe())
1980
+ return Jt(s, e.dtype, t, n), e;
1981
+ let r = pt(e);
1982
+ if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), Jt(s, r, t, n), e == null || !F(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") {
1983
+ const c = e == null ? "null" : e.constructor.name;
1984
+ throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${c}'`);
1927
1985
  }
1928
- const a = Sn(n, r);
1929
- !R(n) && !Array.isArray(n) && (n = [n]);
1930
- const i = r !== "string" ? ce(n, r) : ct(n, [], !0);
1986
+ const a = kn(e, r);
1987
+ !F(e) && !Array.isArray(e) && (e = [e]);
1988
+ const i = r !== "string" ? Lt(e, r) : ct(e, [], !0);
1931
1989
  return g.makeTensor(i, a, r);
1932
1990
  }
1933
- function ro(n, t, e, s = "numeric") {
1934
- if (!Array.isArray(n))
1935
- throw new Error(`Argument ${t} passed to ${e} must be a \`Tensor[]\` or \`TensorLike[]\``);
1936
- return n.map((a, o) => T(a, `${t}[${o}]`, e, s));
1991
+ function In(e, t, n, s = "numeric") {
1992
+ if (!Array.isArray(e))
1993
+ throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);
1994
+ return e.map((a, o) => T(a, `${t}[${o}]`, n, s));
1937
1995
  }
1938
1996
  /**
1939
1997
  * @license
@@ -1951,16 +2009,16 @@ function ro(n, t, e, s = "numeric") {
1951
2009
  * limitations under the License.
1952
2010
  * =============================================================================
1953
2011
  */
1954
- const kn = "__op";
1955
- function N(n) {
1956
- const t = Object.keys(n);
2012
+ const Tn = "__op";
2013
+ function N(e) {
2014
+ const t = Object.keys(e);
1957
2015
  if (t.length !== 1)
1958
2016
  throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);
1959
- let e = t[0];
1960
- const s = n[e];
1961
- e.endsWith("_") && (e = e.substring(0, e.length - 1)), e = e + kn;
2017
+ let n = t[0];
2018
+ const s = e[n];
2019
+ n.endsWith("_") && (n = n.substring(0, n.length - 1)), n = n + Tn;
1962
2020
  const r = (...a) => {
1963
- g.startScope(e);
2021
+ g.startScope(n);
1964
2022
  try {
1965
2023
  const o = s(...a);
1966
2024
  return Ct(o) && console.error("Cannot return a Promise inside of tidy."), g.endScope(o), o;
@@ -1968,7 +2026,7 @@ function N(n) {
1968
2026
  throw g.endScope(null), o;
1969
2027
  }
1970
2028
  };
1971
- return Object.defineProperty(r, "name", { value: e, configurable: !0 }), r;
2029
+ return Object.defineProperty(r, "name", { value: n, configurable: !0 }), r;
1972
2030
  }
1973
2031
  /**
1974
2032
  * @license
@@ -1986,28 +2044,28 @@ function N(n) {
1986
2044
  * limitations under the License.
1987
2045
  * =============================================================================
1988
2046
  */
1989
- function In(n, t, e, s) {
2047
+ function En(e, t, n, s) {
1990
2048
  if (s == null)
1991
- s = mt(n);
2049
+ s = pt(e);
1992
2050
  else if (s === "complex64")
1993
2051
  throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");
1994
- if (de(n) || he(n)) {
2052
+ if (me(e) || ge(e)) {
1995
2053
  if (s !== "float32" && s !== "int32")
1996
2054
  throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${s}.`);
1997
- return g.backend.createTensorFromGPUData(n, t || e, s);
2055
+ return g.backend.createTensorFromGPUData(e, t || n, s);
1998
2056
  }
1999
- if (!R(n) && !Array.isArray(n) && typeof n != "number" && typeof n != "boolean" && typeof n != "string")
2057
+ if (!F(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string")
2000
2058
  throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");
2001
2059
  if (t != null) {
2002
2060
  xt(t);
2003
- const r = z(t), a = z(e);
2061
+ const r = z(t), a = z(n);
2004
2062
  y(r === a, () => `Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`);
2005
- for (let o = 0; o < e.length; ++o) {
2006
- const i = e[o], c = o === e.length - 1 ? i !== z(t.slice(o)) : !0;
2007
- y(e[o] === t[o] || !c, () => `Error creating a new Tensor. Inferred shape (${e}) does not match the provided shape (${t}). `);
2063
+ for (let o = 0; o < n.length; ++o) {
2064
+ const i = n[o], c = o === n.length - 1 ? i !== z(t.slice(o)) : !0;
2065
+ y(n[o] === t[o] || !c, () => `Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `);
2008
2066
  }
2009
2067
  }
2010
- return !R(n) && !Array.isArray(n) && (n = [n]), t = t || e, n = s !== "string" ? ce(n, s) : ct(n, [], !0), g.makeTensor(n, t, s);
2068
+ return !F(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ? Lt(e, s) : ct(e, [], !0), g.makeTensor(e, t, s);
2011
2069
  }
2012
2070
  class st {
2013
2071
  /**
@@ -2021,31 +2079,31 @@ class st {
2021
2079
  return new st(t).slice();
2022
2080
  }
2023
2081
  constructor(t) {
2024
- if (this.shards = [], this.previousShardIndex = 0, t == null || (t instanceof Array || (t = [t]), t = t.map((s) => R(s) ? s.buffer : s), t.length === 0))
2082
+ if (this.shards = [], this.previousShardIndex = 0, t == null || (t instanceof Array || (t = [t]), t = t.map((s) => F(s) ? s.buffer : s), t.length === 0))
2025
2083
  return;
2026
2084
  this.bufferUniformSize = t[0].byteLength;
2027
- let e = 0;
2085
+ let n = 0;
2028
2086
  for (let s = 0; s < t.length; s++) {
2029
2087
  const r = t[s];
2030
2088
  s !== t.length - 1 && r.byteLength !== this.bufferUniformSize && (this.bufferUniformSize = void 0);
2031
- const a = e + r.byteLength;
2032
- this.shards.push({ buffer: r, start: e, end: a }), e = a;
2089
+ const a = n + r.byteLength;
2090
+ this.shards.push({ buffer: r, start: n, end: a }), n = a;
2033
2091
  }
2034
2092
  this.shards.length === 0 && (this.byteLength = 0), this.byteLength = this.shards[this.shards.length - 1].end;
2035
2093
  }
2036
- slice(t = 0, e = this.byteLength) {
2094
+ slice(t = 0, n = this.byteLength) {
2037
2095
  if (this.shards.length === 0)
2038
2096
  return new ArrayBuffer(0);
2039
- if (t = isNaN(Number(t)) ? 0 : t, e = isNaN(Number(e)) ? 0 : e, t = Math.max(0, t), e = Math.min(this.byteLength, e), e <= t)
2097
+ if (t = isNaN(Number(t)) ? 0 : t, n = isNaN(Number(n)) ? 0 : n, t = Math.max(0, t), n = Math.min(this.byteLength, n), n <= t)
2040
2098
  return new ArrayBuffer(0);
2041
2099
  const s = this.findShardForByte(t);
2042
2100
  if (s === -1)
2043
2101
  throw new Error(`Could not find start shard for byte ${t}`);
2044
- const r = e - t, a = new ArrayBuffer(r), o = new Uint8Array(a);
2102
+ const r = n - t, a = new ArrayBuffer(r), o = new Uint8Array(a);
2045
2103
  let i = 0;
2046
2104
  for (let c = s; c < this.shards.length; c++) {
2047
- const l = this.shards[c], h = t + i - l.start, d = i, p = Math.min(e, l.end) - l.start, f = new Uint8Array(l.buffer, h, p - h);
2048
- if (o.set(f, d), i += f.length, e < l.end)
2105
+ const l = this.shards[c], h = t + i - l.start, f = i, p = Math.min(n, l.end) - l.start, d = new Uint8Array(l.buffer, h, p - h);
2106
+ if (o.set(d, f), i += d.length, n < l.end)
2049
2107
  break;
2050
2108
  }
2051
2109
  return a;
@@ -2058,22 +2116,22 @@ class st {
2058
2116
  return -1;
2059
2117
  if (this.bufferUniformSize != null)
2060
2118
  return this.previousShardIndex = Math.floor(t / this.bufferUniformSize), this.previousShardIndex;
2061
- function e(r) {
2119
+ function n(r) {
2062
2120
  return t < r.start ? -1 : t >= r.end ? 1 : 0;
2063
2121
  }
2064
- if (e(this.shards[this.previousShardIndex]) === 0)
2122
+ if (n(this.shards[this.previousShardIndex]) === 0)
2065
2123
  return this.previousShardIndex;
2066
- const s = Tn(this.shards, e);
2124
+ const s = An(this.shards, n);
2067
2125
  return s === -1 ? -1 : (this.previousShardIndex = s, this.previousShardIndex);
2068
2126
  }
2069
2127
  }
2070
- function Tn(n, t) {
2071
- let e = 0, s = n.length;
2072
- for (; e <= s; ) {
2073
- const r = Math.floor((s - e) / 2) + e, a = t(n[r]);
2128
+ function An(e, t) {
2129
+ let n = 0, s = e.length;
2130
+ for (; n <= s; ) {
2131
+ const r = Math.floor((s - n) / 2) + n, a = t(e[r]);
2074
2132
  if (a === 0)
2075
2133
  return r;
2076
- a < 0 ? s = r : e = r + 1;
2134
+ a < 0 ? s = r : n = r + 1;
2077
2135
  }
2078
2136
  return -1;
2079
2137
  }
@@ -2093,103 +2151,103 @@ function Tn(n, t) {
2093
2151
  * limitations under the License.
2094
2152
  * =============================================================================
2095
2153
  */
2096
- function ao() {
2154
+ function go() {
2097
2155
  g.disposeVariables();
2098
2156
  }
2099
- function oo() {
2157
+ function mo() {
2100
2158
  return g;
2101
2159
  }
2102
- function io() {
2160
+ function po() {
2103
2161
  return g.memory();
2104
2162
  }
2105
- function E(n, t) {
2106
- return g.tidy(n, t);
2163
+ function E(e, t) {
2164
+ return g.tidy(e, t);
2107
2165
  }
2108
- function M(n) {
2109
- fe(n).forEach((e) => e.dispose());
2166
+ function M(e) {
2167
+ pe(e).forEach((n) => n.dispose());
2110
2168
  }
2111
- function En(n) {
2112
- return g.keep(n);
2169
+ function Bn(e) {
2170
+ return g.keep(e);
2113
2171
  }
2114
- function co() {
2172
+ function yo() {
2115
2173
  return g.backend;
2116
2174
  }
2117
- const Jt = 4;
2118
- async function lo(n, t) {
2119
- const e = [], s = [], r = Array.isArray(n) ? n.map((o) => o.name) : Object.keys(n);
2175
+ const Xt = 4;
2176
+ async function bo(e, t) {
2177
+ const n = [], s = [], r = Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e);
2120
2178
  for (let o = 0; o < r.length; ++o) {
2121
- const i = r[o], c = Array.isArray(n) ? n[o].tensor : n[i];
2179
+ const i = r[o], c = Array.isArray(e) ? e[o].tensor : e[i];
2122
2180
  if (c.dtype !== "float32" && c.dtype !== "int32" && c.dtype !== "bool" && c.dtype !== "string" && c.dtype !== "complex64")
2123
2181
  throw new Error(`Unsupported dtype in weight '${i}': ${c.dtype}`);
2124
2182
  const l = { name: i, shape: c.shape, dtype: c.dtype };
2125
2183
  if (c.dtype === "string") {
2126
2184
  const u = new Promise(async (h) => {
2127
- const d = await c.bytes(), m = d.reduce((w, I) => w + I.length, 0) + Jt * d.length, p = new Uint8Array(m);
2128
- let f = 0;
2129
- for (let w = 0; w < d.length; w++) {
2130
- const I = d[w], O = new Uint8Array(new Uint32Array([I.length]).buffer);
2131
- p.set(O, f), f += Jt, p.set(I, f), f += I.length;
2185
+ const f = await c.bytes(), m = f.reduce((w, I) => w + I.length, 0) + Xt * f.length, p = new Uint8Array(m);
2186
+ let d = 0;
2187
+ for (let w = 0; w < f.length; w++) {
2188
+ const I = f[w], _ = new Uint8Array(new Uint32Array([I.length]).buffer);
2189
+ p.set(_, d), d += Xt, p.set(I, d), d += I.length;
2132
2190
  }
2133
2191
  h(p);
2134
2192
  });
2135
2193
  s.push(u);
2136
2194
  } else
2137
2195
  s.push(c.data());
2138
- t != null && (l.group = t), e.push(l);
2196
+ t != null && (l.group = t), n.push(l);
2139
2197
  }
2140
2198
  const a = await Promise.all(s);
2141
- return { data: An(a), specs: e };
2199
+ return { data: vn(a), specs: n };
2142
2200
  }
2143
- function An(n) {
2144
- if (n === null)
2145
- throw new Error(`Invalid input value: ${JSON.stringify(n)}`);
2201
+ function vn(e) {
2202
+ if (e === null)
2203
+ throw new Error(`Invalid input value: ${JSON.stringify(e)}`);
2146
2204
  let t = 0;
2147
- const e = [];
2148
- n.forEach((a) => {
2149
- if (t += a.byteLength, e.push(a.byteLength === a.buffer.byteLength ? a : new a.constructor(a)), !(a instanceof Float32Array || a instanceof Int32Array || a instanceof Uint8Array))
2205
+ const n = [];
2206
+ e.forEach((a) => {
2207
+ if (t += a.byteLength, n.push(a.byteLength === a.buffer.byteLength ? a : new a.constructor(a)), !(a instanceof Float32Array || a instanceof Int32Array || a instanceof Uint8Array))
2150
2208
  throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`);
2151
2209
  });
2152
2210
  const s = new Uint8Array(t);
2153
2211
  let r = 0;
2154
- return e.forEach((a) => {
2212
+ return n.forEach((a) => {
2155
2213
  s.set(new Uint8Array(a.buffer), r), r += a.byteLength;
2156
2214
  }), s.buffer;
2157
2215
  }
2158
- const Lt = typeof gt < "u" && (typeof Blob > "u" || typeof atob > "u" || typeof btoa > "u");
2159
- function Xt(n) {
2160
- return Lt ? gt.byteLength(n, "utf8") : new Blob([n]).size;
2216
+ const _t = typeof mt < "u" && (typeof Blob > "u" || typeof atob > "u" || typeof btoa > "u");
2217
+ function Yt(e) {
2218
+ return _t ? mt.byteLength(e, "utf8") : new Blob([e]).size;
2161
2219
  }
2162
- function Bn(n) {
2163
- if (Lt)
2164
- return gt.from(n).toString("base64");
2165
- const t = new Uint8Array(n);
2166
- let e = "";
2220
+ function Mn(e) {
2221
+ if (_t)
2222
+ return mt.from(e).toString("base64");
2223
+ const t = new Uint8Array(e);
2224
+ let n = "";
2167
2225
  for (let s = 0, r = t.length; s < r; s++)
2168
- e += String.fromCharCode(t[s]);
2169
- return btoa(e);
2226
+ n += String.fromCharCode(t[s]);
2227
+ return btoa(n);
2170
2228
  }
2171
- function vn(n) {
2172
- if (Lt) {
2173
- const s = gt.from(n, "base64");
2229
+ function Nn(e) {
2230
+ if (_t) {
2231
+ const s = mt.from(e, "base64");
2174
2232
  return s.buffer.slice(s.byteOffset, s.byteOffset + s.byteLength);
2175
2233
  }
2176
- const t = atob(n), e = new Uint8Array(t.length);
2234
+ const t = atob(e), n = new Uint8Array(t.length);
2177
2235
  for (let s = 0; s < t.length; ++s)
2178
- e.set([t.charCodeAt(s)], s);
2179
- return e.buffer;
2236
+ n.set([t.charCodeAt(s)], s);
2237
+ return n.buffer;
2180
2238
  }
2181
- function uo(n) {
2182
- return st.join(n);
2239
+ function wo(e) {
2240
+ return st.join(e);
2183
2241
  }
2184
- function ye(n) {
2185
- if (n.modelTopology instanceof ArrayBuffer)
2242
+ function Se(e) {
2243
+ if (e.modelTopology instanceof ArrayBuffer)
2186
2244
  throw new Error("Expected JSON model topology, received ArrayBuffer.");
2187
2245
  return {
2188
2246
  dateSaved: /* @__PURE__ */ new Date(),
2189
2247
  modelTopologyType: "JSON",
2190
- modelTopologyBytes: n.modelTopology == null ? 0 : Xt(JSON.stringify(n.modelTopology)),
2191
- weightSpecsBytes: n.weightSpecs == null ? 0 : Xt(JSON.stringify(n.weightSpecs)),
2192
- weightDataBytes: n.weightData == null ? 0 : new st(n.weightData).byteLength
2248
+ modelTopologyBytes: e.modelTopology == null ? 0 : Yt(JSON.stringify(e.modelTopology)),
2249
+ weightSpecsBytes: e.weightSpecs == null ? 0 : Yt(JSON.stringify(e.weightSpecs)),
2250
+ weightDataBytes: e.weightData == null ? 0 : new st(e.weightData).byteLength
2193
2251
  };
2194
2252
  }
2195
2253
  /**
@@ -2252,18 +2310,18 @@ class A {
2252
2310
  * @returns All valid handlers for `url`, given the currently registered
2253
2311
  * handler routers.
2254
2312
  */
2255
- static getLoadHandlers(t, e) {
2256
- return A.getHandlers(t, "load", e);
2313
+ static getLoadHandlers(t, n) {
2314
+ return A.getHandlers(t, "load", n);
2257
2315
  }
2258
- static getHandlers(t, e, s) {
2316
+ static getHandlers(t, n, s) {
2259
2317
  const r = [];
2260
- return (e === "load" ? A.getInstance().loadRouters : A.getInstance().saveRouters).forEach((o) => {
2318
+ return (n === "load" ? A.getInstance().loadRouters : A.getInstance().saveRouters).forEach((o) => {
2261
2319
  const i = o(t, s);
2262
2320
  i !== null && r.push(i);
2263
2321
  }), r;
2264
2322
  }
2265
2323
  }
2266
- const ho = (n) => A.getSaveHandlers(n);
2324
+ const So = (e) => A.getSaveHandlers(e);
2267
2325
  /**
2268
2326
  * @license
2269
2327
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -2280,22 +2338,22 @@ const ho = (n) => A.getSaveHandlers(n);
2280
2338
  * limitations under the License.
2281
2339
  * =============================================================================
2282
2340
  */
2283
- const vt = "tensorflowjs", Mt = 1, G = "models_store", L = "model_info_store";
2284
- function be() {
2341
+ const vt = "tensorflowjs", Mt = 1, U = "models_store", L = "model_info_store";
2342
+ function ke() {
2285
2343
  if (!k().getBool("IS_BROWSER"))
2286
2344
  throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");
2287
- const n = typeof window > "u" ? self : window, t = n.indexedDB || n.mozIndexedDB || n.webkitIndexedDB || n.msIndexedDB || n.shimIndexedDB;
2345
+ const e = typeof window > "u" ? self : window, t = e.indexedDB || e.mozIndexedDB || e.webkitIndexedDB || e.msIndexedDB || e.shimIndexedDB;
2288
2346
  if (t == null)
2289
2347
  throw new Error("The current browser does not appear to support IndexedDB.");
2290
2348
  return t;
2291
2349
  }
2292
- function Nt(n) {
2293
- const t = n.result;
2294
- t.createObjectStore(G, { keyPath: "modelPath" }), t.createObjectStore(L, { keyPath: "modelPath" });
2350
+ function Nt(e) {
2351
+ const t = e.result;
2352
+ t.createObjectStore(U, { keyPath: "modelPath" }), t.createObjectStore(L, { keyPath: "modelPath" });
2295
2353
  }
2296
2354
  class W {
2297
2355
  constructor(t) {
2298
- if (this.indexedDB = be(), t == null || !t)
2356
+ if (this.indexedDB = ke(), t == null || !t)
2299
2357
  throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");
2300
2358
  this.modelPath = t;
2301
2359
  }
@@ -2321,36 +2379,36 @@ class W {
2321
2379
  * @returns A `Promise` of `SaveResult`, if the action is put, or a `Promise`
2322
2380
  * of `ModelArtifacts`, if the action is get.
2323
2381
  */
2324
- databaseAction(t, e) {
2382
+ databaseAction(t, n) {
2325
2383
  return new Promise((s, r) => {
2326
2384
  const a = this.indexedDB.open(vt, Mt);
2327
2385
  a.onupgradeneeded = () => Nt(a), a.onsuccess = () => {
2328
2386
  const o = a.result;
2329
- if (e == null) {
2330
- const i = o.transaction(G, "readonly"), l = i.objectStore(G).get(this.modelPath);
2387
+ if (n == null) {
2388
+ const i = o.transaction(U, "readonly"), l = i.objectStore(U).get(this.modelPath);
2331
2389
  l.onsuccess = () => {
2332
2390
  if (l.result == null)
2333
2391
  return o.close(), r(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));
2334
2392
  s(l.result.modelArtifacts);
2335
2393
  }, l.onerror = (u) => (o.close(), r(l.error)), i.oncomplete = () => o.close();
2336
2394
  } else {
2337
- e.weightData = st.join(e.weightData);
2338
- const i = ye(e), c = o.transaction(L, "readwrite");
2395
+ n.weightData = st.join(n.weightData);
2396
+ const i = Se(n), c = o.transaction(L, "readwrite");
2339
2397
  let l = c.objectStore(L), u;
2340
2398
  try {
2341
2399
  u = l.put({ modelPath: this.modelPath, modelArtifactsInfo: i });
2342
- } catch (d) {
2343
- return r(d);
2400
+ } catch (f) {
2401
+ return r(f);
2344
2402
  }
2345
2403
  let h;
2346
2404
  u.onsuccess = () => {
2347
- h = o.transaction(G, "readwrite");
2348
- const d = h.objectStore(G);
2405
+ h = o.transaction(U, "readwrite");
2406
+ const f = h.objectStore(U);
2349
2407
  let m;
2350
2408
  try {
2351
- m = d.put({
2409
+ m = f.put({
2352
2410
  modelPath: this.modelPath,
2353
- modelArtifacts: e,
2411
+ modelArtifacts: n,
2354
2412
  modelArtifactsInfo: i
2355
2413
  });
2356
2414
  } catch (p) {
@@ -2358,10 +2416,10 @@ class W {
2358
2416
  }
2359
2417
  m.onsuccess = () => s({ modelArtifactsInfo: i }), m.onerror = (p) => {
2360
2418
  l = c.objectStore(L);
2361
- const f = l.delete(this.modelPath);
2362
- f.onsuccess = () => (o.close(), r(m.error)), f.onerror = (w) => (o.close(), r(m.error));
2419
+ const d = l.delete(this.modelPath);
2420
+ d.onsuccess = () => (o.close(), r(m.error)), d.onerror = (w) => (o.close(), r(m.error));
2363
2421
  };
2364
- }, u.onerror = (d) => (o.close(), r(u.error)), c.oncomplete = () => {
2422
+ }, u.onerror = (f) => (o.close(), r(u.error)), c.oncomplete = () => {
2365
2423
  h == null ? o.close() : h.oncomplete = () => o.close();
2366
2424
  };
2367
2425
  }
@@ -2370,21 +2428,21 @@ class W {
2370
2428
  }
2371
2429
  }
2372
2430
  W.URL_SCHEME = "indexeddb://";
2373
- const we = (n) => k().getBool("IS_BROWSER") && !Array.isArray(n) && n.startsWith(W.URL_SCHEME) ? Mn(n.slice(W.URL_SCHEME.length)) : null;
2374
- A.registerSaveRouter(we);
2375
- A.registerLoadRouter(we);
2376
- function Mn(n) {
2377
- return new W(n);
2431
+ const Ie = (e) => k().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(W.URL_SCHEME) ? Fn(e.slice(W.URL_SCHEME.length)) : null;
2432
+ A.registerSaveRouter(Ie);
2433
+ A.registerLoadRouter(Ie);
2434
+ function Fn(e) {
2435
+ return new W(e);
2378
2436
  }
2379
- function Nn(n) {
2380
- return n.startsWith(W.URL_SCHEME) ? n.slice(W.URL_SCHEME.length) : n;
2437
+ function Rn(e) {
2438
+ return e.startsWith(W.URL_SCHEME) ? e.slice(W.URL_SCHEME.length) : e;
2381
2439
  }
2382
- class Rn {
2440
+ class Dn {
2383
2441
  constructor() {
2384
- this.indexedDB = be();
2442
+ this.indexedDB = ke();
2385
2443
  }
2386
2444
  async listModels() {
2387
- return new Promise((t, e) => {
2445
+ return new Promise((t, n) => {
2388
2446
  const s = this.indexedDB.open(vt, Mt);
2389
2447
  s.onupgradeneeded = () => Nt(s), s.onsuccess = () => {
2390
2448
  const r = s.result, a = r.transaction(L, "readonly"), i = a.objectStore(L).getAll();
@@ -2393,12 +2451,12 @@ class Rn {
2393
2451
  for (const l of i.result)
2394
2452
  c[l.modelPath] = l.modelArtifactsInfo;
2395
2453
  t(c);
2396
- }, i.onerror = (c) => (r.close(), e(i.error)), a.oncomplete = () => r.close();
2397
- }, s.onerror = (r) => e(s.error);
2454
+ }, i.onerror = (c) => (r.close(), n(i.error)), a.oncomplete = () => r.close();
2455
+ }, s.onerror = (r) => n(s.error);
2398
2456
  });
2399
2457
  }
2400
2458
  async removeModel(t) {
2401
- return t = Nn(t), new Promise((e, s) => {
2459
+ return t = Rn(t), new Promise((n, s) => {
2402
2460
  const r = this.indexedDB.open(vt, Mt);
2403
2461
  r.onupgradeneeded = () => Nt(r), r.onsuccess = () => {
2404
2462
  const a = r.result, o = a.transaction(L, "readwrite"), i = o.objectStore(L), c = i.get(t);
@@ -2408,11 +2466,11 @@ class Rn {
2408
2466
  return a.close(), s(new Error(`Cannot find model with path '${t}' in IndexedDB.`));
2409
2467
  {
2410
2468
  const u = i.delete(t), h = () => {
2411
- l = a.transaction(G, "readwrite");
2412
- const m = l.objectStore(G).delete(t);
2413
- m.onsuccess = () => e(c.result.modelArtifactsInfo), m.onerror = (p) => s(c.error);
2469
+ l = a.transaction(U, "readwrite");
2470
+ const m = l.objectStore(U).delete(t);
2471
+ m.onsuccess = () => n(c.result.modelArtifactsInfo), m.onerror = (p) => s(c.error);
2414
2472
  };
2415
- u.onsuccess = h, u.onerror = (d) => (h(), a.close(), s(c.error));
2473
+ u.onsuccess = h, u.onerror = (f) => (h(), a.close(), s(c.error));
2416
2474
  }
2417
2475
  }, c.onerror = (u) => (a.close(), s(c.error)), o.oncomplete = () => {
2418
2476
  l == null ? a.close() : l.oncomplete = () => a.close();
@@ -2437,28 +2495,28 @@ class Rn {
2437
2495
  * limitations under the License.
2438
2496
  * =============================================================================
2439
2497
  */
2440
- const P = "/", Q = "tensorflowjs_models", Se = "info", Fn = "model_topology", Dn = "weight_specs", $n = "weight_data", xn = "model_metadata";
2441
- function ke(n) {
2498
+ const P = "/", Q = "tensorflowjs_models", Te = "info", $n = "model_topology", xn = "weight_specs", Cn = "weight_data", Pn = "model_metadata";
2499
+ function Ee(e) {
2442
2500
  return {
2443
- info: [Q, n, Se].join(P),
2444
- topology: [Q, n, Fn].join(P),
2445
- weightSpecs: [Q, n, Dn].join(P),
2446
- weightData: [Q, n, $n].join(P),
2447
- modelMetadata: [Q, n, xn].join(P)
2501
+ info: [Q, e, Te].join(P),
2502
+ topology: [Q, e, $n].join(P),
2503
+ weightSpecs: [Q, e, xn].join(P),
2504
+ weightData: [Q, e, Cn].join(P),
2505
+ modelMetadata: [Q, e, Pn].join(P)
2448
2506
  };
2449
2507
  }
2450
- function Ie(n) {
2451
- for (const t of Object.values(n))
2508
+ function Ae(e) {
2509
+ for (const t of Object.values(e))
2452
2510
  window.localStorage.removeItem(t);
2453
2511
  }
2454
- function Cn(n) {
2455
- const t = n.split(P);
2512
+ function Ln(e) {
2513
+ const t = e.split(P);
2456
2514
  if (t.length < 3)
2457
- throw new Error(`Invalid key format: ${n}`);
2515
+ throw new Error(`Invalid key format: ${e}`);
2458
2516
  return t.slice(1, t.length - 1).join(P);
2459
2517
  }
2460
- function Pn(n) {
2461
- return n.startsWith(j.URL_SCHEME) ? n.slice(j.URL_SCHEME.length) : n;
2518
+ function _n(e) {
2519
+ return e.startsWith(j.URL_SCHEME) ? e.slice(j.URL_SCHEME.length) : e;
2462
2520
  }
2463
2521
  class j {
2464
2522
  constructor(t) {
@@ -2466,7 +2524,7 @@ class j {
2466
2524
  throw new Error("The current environment does not support local storage.");
2467
2525
  if (this.LS = window.localStorage, t == null || !t)
2468
2526
  throw new Error("For local storage, modelPath must not be null, undefined or empty.");
2469
- this.modelPath = t, this.keys = ke(this.modelPath);
2527
+ this.modelPath = t, this.keys = Ee(this.modelPath);
2470
2528
  }
2471
2529
  /**
2472
2530
  * Save model artifacts to browser local storage.
@@ -2481,9 +2539,9 @@ class j {
2481
2539
  if (t.modelTopology instanceof ArrayBuffer)
2482
2540
  throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");
2483
2541
  {
2484
- const e = JSON.stringify(t.modelTopology), s = JSON.stringify(t.weightSpecs), r = ye(t), a = st.join(t.weightData);
2542
+ const n = JSON.stringify(t.modelTopology), s = JSON.stringify(t.weightSpecs), r = Se(t), a = st.join(t.weightData);
2485
2543
  try {
2486
- this.LS.setItem(this.keys.info, JSON.stringify(r)), this.LS.setItem(this.keys.topology, e), this.LS.setItem(this.keys.weightSpecs, s), this.LS.setItem(this.keys.weightData, Bn(a));
2544
+ this.LS.setItem(this.keys.info, JSON.stringify(r)), this.LS.setItem(this.keys.topology, n), this.LS.setItem(this.keys.weightSpecs, s), this.LS.setItem(this.keys.weightData, Mn(a));
2487
2545
  const o = {
2488
2546
  format: t.format,
2489
2547
  generatedBy: t.generatedBy,
@@ -2496,7 +2554,7 @@ class j {
2496
2554
  };
2497
2555
  return this.LS.setItem(this.keys.modelMetadata, JSON.stringify(o)), { modelArtifactsInfo: r };
2498
2556
  } catch {
2499
- throw Ie(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`);
2557
+ throw Ae(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`);
2500
2558
  }
2501
2559
  }
2502
2560
  }
@@ -2514,54 +2572,54 @@ class j {
2514
2572
  throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);
2515
2573
  if (t.modelTopologyType !== "JSON")
2516
2574
  throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");
2517
- const e = {}, s = JSON.parse(this.LS.getItem(this.keys.topology));
2575
+ const n = {}, s = JSON.parse(this.LS.getItem(this.keys.topology));
2518
2576
  if (s == null)
2519
2577
  throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);
2520
- e.modelTopology = s;
2578
+ n.modelTopology = s;
2521
2579
  const r = JSON.parse(this.LS.getItem(this.keys.weightSpecs));
2522
2580
  if (r == null)
2523
2581
  throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);
2524
- e.weightSpecs = r;
2582
+ n.weightSpecs = r;
2525
2583
  const a = this.LS.getItem(this.keys.modelMetadata);
2526
2584
  if (a != null) {
2527
2585
  const i = JSON.parse(a);
2528
- e.format = i.format, e.generatedBy = i.generatedBy, e.convertedBy = i.convertedBy, i.signature != null && (e.signature = i.signature), i.userDefinedMetadata != null && (e.userDefinedMetadata = i.userDefinedMetadata), i.modelInitializer != null && (e.modelInitializer = i.modelInitializer), i.initializerSignature != null && (e.initializerSignature = i.initializerSignature), i.trainingConfig != null && (e.trainingConfig = i.trainingConfig);
2586
+ n.format = i.format, n.generatedBy = i.generatedBy, n.convertedBy = i.convertedBy, i.signature != null && (n.signature = i.signature), i.userDefinedMetadata != null && (n.userDefinedMetadata = i.userDefinedMetadata), i.modelInitializer != null && (n.modelInitializer = i.modelInitializer), i.initializerSignature != null && (n.initializerSignature = i.initializerSignature), i.trainingConfig != null && (n.trainingConfig = i.trainingConfig);
2529
2587
  }
2530
2588
  const o = this.LS.getItem(this.keys.weightData);
2531
2589
  if (o == null)
2532
2590
  throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);
2533
- return e.weightData = vn(o), e;
2591
+ return n.weightData = Nn(o), n;
2534
2592
  }
2535
2593
  }
2536
2594
  j.URL_SCHEME = "localstorage://";
2537
- const Te = (n) => k().getBool("IS_BROWSER") && !Array.isArray(n) && n.startsWith(j.URL_SCHEME) ? Ln(n.slice(j.URL_SCHEME.length)) : null;
2538
- A.registerSaveRouter(Te);
2539
- A.registerLoadRouter(Te);
2540
- function Ln(n) {
2541
- return new j(n);
2595
+ const Be = (e) => k().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(j.URL_SCHEME) ? On(e.slice(j.URL_SCHEME.length)) : null;
2596
+ A.registerSaveRouter(Be);
2597
+ A.registerLoadRouter(Be);
2598
+ function On(e) {
2599
+ return new j(e);
2542
2600
  }
2543
- class On {
2601
+ class Gn {
2544
2602
  constructor() {
2545
2603
  y(k().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), y(typeof window > "u" || typeof window.localStorage < "u", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage;
2546
2604
  }
2547
2605
  async listModels() {
2548
- const t = {}, e = Q + P, s = P + Se;
2606
+ const t = {}, n = Q + P, s = P + Te;
2549
2607
  for (let r = 0; r < this.LS.length; ++r) {
2550
2608
  const a = this.LS.key(r);
2551
- if (a.startsWith(e) && a.endsWith(s)) {
2552
- const o = Cn(a);
2609
+ if (a.startsWith(n) && a.endsWith(s)) {
2610
+ const o = Ln(a);
2553
2611
  t[o] = JSON.parse(this.LS.getItem(a));
2554
2612
  }
2555
2613
  }
2556
2614
  return t;
2557
2615
  }
2558
2616
  async removeModel(t) {
2559
- t = Pn(t);
2560
- const e = ke(t);
2561
- if (this.LS.getItem(e.info) == null)
2617
+ t = _n(t);
2618
+ const n = Ee(t);
2619
+ if (this.LS.getItem(n.info) == null)
2562
2620
  throw new Error(`Cannot find model at path '${t}'`);
2563
- const s = JSON.parse(this.LS.getItem(e.info));
2564
- return Ie(e), s;
2621
+ const s = JSON.parse(this.LS.getItem(n.info));
2622
+ return Ae(n), s;
2565
2623
  }
2566
2624
  }
2567
2625
  /**
@@ -2580,7 +2638,7 @@ class On {
2580
2638
  * limitations under the License.
2581
2639
  * =============================================================================
2582
2640
  */
2583
- const Yt = "://";
2641
+ const Qt = "://";
2584
2642
  class $ {
2585
2643
  constructor() {
2586
2644
  this.managers = {};
@@ -2594,16 +2652,16 @@ class $ {
2594
2652
  * @param saveRouter A function that maps a URL-like string onto an instance
2595
2653
  * of `IOHandler` with the `save` method defined or `null`.
2596
2654
  */
2597
- static registerManager(t, e) {
2598
- y(t != null, () => "scheme must not be undefined or null."), t.endsWith(Yt) && (t = t.slice(0, t.indexOf(Yt))), y(t.length > 0, () => "scheme must not be an empty string.");
2655
+ static registerManager(t, n) {
2656
+ y(t != null, () => "scheme must not be undefined or null."), t.endsWith(Qt) && (t = t.slice(0, t.indexOf(Qt))), y(t.length > 0, () => "scheme must not be an empty string.");
2599
2657
  const s = $.getInstance();
2600
- y(s.managers[t] == null, () => `A model store manager is already registered for scheme '${t}'.`), s.managers[t] = e;
2658
+ y(s.managers[t] == null, () => `A model store manager is already registered for scheme '${t}'.`), s.managers[t] = n;
2601
2659
  }
2602
2660
  static getManager(t) {
2603
- const e = $.getInstance().managers[t];
2604
- if (e == null)
2661
+ const n = $.getInstance().managers[t];
2662
+ if (n == null)
2605
2663
  throw new Error(`Cannot find model manager for scheme '${t}'`);
2606
- return e;
2664
+ return n;
2607
2665
  }
2608
2666
  static getSchemes() {
2609
2667
  return Object.keys($.getInstance().managers);
@@ -2625,36 +2683,36 @@ class $ {
2625
2683
  * limitations under the License.
2626
2684
  * =============================================================================
2627
2685
  */
2628
- class _n {
2686
+ class Un {
2629
2687
  constructor() {
2630
2688
  this.messageName = "setTimeoutCustom", this.functionRefs = [], this.handledMessageCount = 0, this.hasEventListener = !1;
2631
2689
  }
2632
- fetch(t, e) {
2633
- return fetch(t, e);
2690
+ fetch(t, n) {
2691
+ return fetch(t, n);
2634
2692
  }
2635
2693
  now() {
2636
2694
  return performance.now();
2637
2695
  }
2638
- encode(t, e) {
2639
- if (e !== "utf-8" && e !== "utf8")
2640
- throw new Error(`Browser's encoder only supports utf-8, but got ${e}`);
2696
+ encode(t, n) {
2697
+ if (n !== "utf-8" && n !== "utf8")
2698
+ throw new Error(`Browser's encoder only supports utf-8, but got ${n}`);
2641
2699
  return this.textEncoder == null && (this.textEncoder = new TextEncoder()), this.textEncoder.encode(t);
2642
2700
  }
2643
- decode(t, e) {
2644
- return new TextDecoder(e).decode(t);
2701
+ decode(t, n) {
2702
+ return new TextDecoder(n).decode(t);
2645
2703
  }
2646
2704
  // If the setTimeout nesting level is greater than 5 and timeout is less
2647
2705
  // than 4ms, timeout will be clamped to 4ms, which hurts the perf.
2648
2706
  // Interleaving window.postMessage and setTimeout will trick the browser and
2649
2707
  // avoid the clamp.
2650
- setTimeoutCustom(t, e) {
2708
+ setTimeoutCustom(t, n) {
2651
2709
  if (typeof window > "u" || !k().getBool("USE_SETTIMEOUTCUSTOM")) {
2652
- setTimeout(t, e);
2710
+ setTimeout(t, n);
2653
2711
  return;
2654
2712
  }
2655
2713
  this.functionRefs.push(t), setTimeout(() => {
2656
2714
  window.postMessage({ name: this.messageName, index: this.functionRefs.length - 1 }, "*");
2657
- }, e), this.hasEventListener || (this.hasEventListener = !0, window.addEventListener("message", (s) => {
2715
+ }, n), this.hasEventListener || (this.hasEventListener = !0, window.addEventListener("message", (s) => {
2658
2716
  if (s.source === window && s.data.name === this.messageName) {
2659
2717
  s.stopPropagation();
2660
2718
  const r = this.functionRefs[s.data.index];
@@ -2663,49 +2721,49 @@ class _n {
2663
2721
  }, !0));
2664
2722
  }
2665
2723
  isTypedArray(t) {
2666
- return ie(t);
2724
+ return le(t);
2667
2725
  }
2668
2726
  }
2669
2727
  if (k().get("IS_BROWSER")) {
2670
- k().setPlatform("browser", new _n());
2728
+ k().setPlatform("browser", new Un());
2671
2729
  try {
2672
- $.registerManager(j.URL_SCHEME, new On());
2730
+ $.registerManager(j.URL_SCHEME, new Gn());
2673
2731
  } catch {
2674
2732
  }
2675
2733
  try {
2676
- $.registerManager(W.URL_SCHEME, new Rn());
2734
+ $.registerManager(W.URL_SCHEME, new Dn());
2677
2735
  } catch {
2678
2736
  }
2679
2737
  }
2680
- const Un = {
2738
+ const zn = {
2681
2739
  // tslint:disable-next-line:no-require-imports
2682
2740
  importFetch: () => require("node-fetch")
2683
2741
  };
2684
- let wt;
2685
- class Gn {
2742
+ let St;
2743
+ class Vn {
2686
2744
  constructor() {
2687
2745
  this.util = require("util"), this.textEncoder = new this.util.TextEncoder();
2688
2746
  }
2689
- fetch(t, e) {
2690
- return k().global.fetch != null ? k().global.fetch(t, e) : (wt == null && (wt = Un.importFetch()), wt(t, e));
2747
+ fetch(t, n) {
2748
+ return k().global.fetch != null ? k().global.fetch(t, n) : (St == null && (St = zn.importFetch()), St(t, n));
2691
2749
  }
2692
2750
  now() {
2693
2751
  const t = Z.hrtime();
2694
2752
  return t[0] * 1e3 + t[1] / 1e6;
2695
2753
  }
2696
- encode(t, e) {
2697
- if (e !== "utf-8" && e !== "utf8")
2698
- throw new Error(`Node built-in encoder only supports utf-8, but got ${e}`);
2754
+ encode(t, n) {
2755
+ if (n !== "utf-8" && n !== "utf8")
2756
+ throw new Error(`Node built-in encoder only supports utf-8, but got ${n}`);
2699
2757
  return this.textEncoder.encode(t);
2700
2758
  }
2701
- decode(t, e) {
2702
- return t.length === 0 ? "" : new this.util.TextDecoder(e).decode(t);
2759
+ decode(t, n) {
2760
+ return t.length === 0 ? "" : new this.util.TextDecoder(n).decode(t);
2703
2761
  }
2704
2762
  isTypedArray(t) {
2705
2763
  return this.util.types.isFloat32Array(t) || this.util.types.isInt32Array(t) || this.util.types.isUint8Array(t) || this.util.types.isUint8ClampedArray(t);
2706
2764
  }
2707
2765
  }
2708
- k().get("IS_NODE") && !k().get("IS_BROWSER") && k().setPlatform("node", new Gn());
2766
+ k().get("IS_NODE") && !k().get("IS_BROWSER") && k().setPlatform("node", new Vn());
2709
2767
  /**
2710
2768
  * @license
2711
2769
  * Copyright 2020 Google Inc. All Rights Reserved.
@@ -2722,8 +2780,8 @@ k().get("IS_NODE") && !k().get("IS_BROWSER") && k().setPlatform("node", new Gn()
2722
2780
  * limitations under the License.
2723
2781
  * =============================================================================
2724
2782
  */
2725
- function zn(n, t = "float32", e) {
2726
- return t = t || "float32", xt(n), new hn(n, t, e);
2783
+ function Wn(e, t = "float32", n) {
2784
+ return t = t || "float32", xt(e), new dn(e, t, n);
2727
2785
  }
2728
2786
  /**
2729
2787
  * @license
@@ -2741,16 +2799,16 @@ function zn(n, t = "float32", e) {
2741
2799
  * limitations under the License.
2742
2800
  * =============================================================================
2743
2801
  */
2744
- function Vn(n, t) {
2745
- const e = T(n, "x", "cast");
2746
- if (!$e(t))
2802
+ function jn(e, t) {
2803
+ const n = T(e, "x", "cast");
2804
+ if (!Pe(t))
2747
2805
  throw new Error(`Failed to cast to unknown dtype ${t}`);
2748
- if (t === "string" && e.dtype !== "string" || t !== "string" && e.dtype === "string")
2806
+ if (t === "string" && n.dtype !== "string" || t !== "string" && n.dtype === "string")
2749
2807
  throw new Error("Only strings can be casted to strings");
2750
- const s = { x: e }, r = { dtype: t };
2751
- return g.runKernel(re, s, r);
2808
+ const s = { x: n }, r = { dtype: t };
2809
+ return g.runKernel(oe, s, r);
2752
2810
  }
2753
- const Rt = /* @__PURE__ */ N({ cast_: Vn });
2811
+ const Ft = /* @__PURE__ */ N({ cast_: jn });
2754
2812
  /**
2755
2813
  * @license
2756
2814
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2767,11 +2825,11 @@ const Rt = /* @__PURE__ */ N({ cast_: Vn });
2767
2825
  * limitations under the License.
2768
2826
  * =============================================================================
2769
2827
  */
2770
- function Wn(n) {
2771
- const e = { x: T(n, "x", "clone", "string_or_numeric") };
2772
- return g.runKernel(ae, e);
2828
+ function Kn(e) {
2829
+ const n = { x: T(e, "x", "clone", "string_or_numeric") };
2830
+ return g.runKernel(ie, n);
2773
2831
  }
2774
- const jn = /* @__PURE__ */ N({ clone_: Wn });
2832
+ const qn = /* @__PURE__ */ N({ clone_: Kn });
2775
2833
  /**
2776
2834
  * @license
2777
2835
  * Copyright 2020 Google Inc. All Rights Reserved.
@@ -2788,8 +2846,8 @@ const jn = /* @__PURE__ */ N({ clone_: Wn });
2788
2846
  * limitations under the License.
2789
2847
  * =============================================================================
2790
2848
  */
2791
- function Kn(n, t = !1) {
2792
- console.log(n.toString(t));
2849
+ function Hn(e, t = !1) {
2850
+ console.log(e.toString(t));
2793
2851
  }
2794
2852
  /**
2795
2853
  * @license
@@ -2807,14 +2865,14 @@ function Kn(n, t = !1) {
2807
2865
  * limitations under the License.
2808
2866
  * =============================================================================
2809
2867
  */
2810
- me();
2811
- const qn = {
2812
- buffer: zn,
2813
- cast: Rt,
2814
- clone: jn,
2815
- print: Kn
2868
+ be();
2869
+ const Jn = {
2870
+ buffer: Wn,
2871
+ cast: Ft,
2872
+ clone: qn,
2873
+ print: Hn
2816
2874
  };
2817
- fn(qn);
2875
+ mn(Jn);
2818
2876
  /**
2819
2877
  * @license
2820
2878
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2831,13 +2889,13 @@ fn(qn);
2831
2889
  * limitations under the License.
2832
2890
  * =============================================================================
2833
2891
  */
2834
- function Hn(n, t) {
2835
- let e = T(n, "a", "add"), s = T(t, "b", "add");
2836
- [e, s] = q(e, s);
2837
- const r = { a: e, b: s };
2838
- return g.runKernel(se, r);
2892
+ function Xn(e, t) {
2893
+ let n = T(e, "a", "add"), s = T(t, "b", "add");
2894
+ [n, s] = q(n, s);
2895
+ const r = { a: n, b: s };
2896
+ return g.runKernel(ae, r);
2839
2897
  }
2840
- const S = /* @__PURE__ */ N({ add_: Hn });
2898
+ const S = /* @__PURE__ */ N({ add_: Xn });
2841
2899
  /**
2842
2900
  * @license
2843
2901
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2854,13 +2912,13 @@ const S = /* @__PURE__ */ N({ add_: Hn });
2854
2912
  * limitations under the License.
2855
2913
  * =============================================================================
2856
2914
  */
2857
- function Jn(n, t) {
2858
- let e = T(n, "a", "floorDiv"), s = T(t, "b", "floorDiv");
2859
- [e, s] = q(e, s);
2860
- const r = { a: e, b: s };
2861
- return g.runKernel(He, r);
2915
+ function Yn(e, t) {
2916
+ let n = T(e, "a", "floorDiv"), s = T(t, "b", "floorDiv");
2917
+ [n, s] = q(n, s);
2918
+ const r = { a: n, b: s };
2919
+ return g.runKernel(Ye, r);
2862
2920
  }
2863
- const Xn = /* @__PURE__ */ N({ floorDiv_: Jn });
2921
+ const Qn = /* @__PURE__ */ N({ floorDiv_: Yn });
2864
2922
  /**
2865
2923
  * @license
2866
2924
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2877,14 +2935,14 @@ const Xn = /* @__PURE__ */ N({ floorDiv_: Jn });
2877
2935
  * limitations under the License.
2878
2936
  * =============================================================================
2879
2937
  */
2880
- function Yn(n, t) {
2881
- let e = T(n, "a", "div"), s = T(t, "b", "div");
2882
- if ([e, s] = q(e, s), e.dtype === "int32" && s.dtype === "int32")
2883
- return Xn(e, s);
2884
- const r = { a: e, b: s }, a = {};
2885
- return g.runKernel(Ke, r, a);
2886
- }
2887
- const x = /* @__PURE__ */ N({ div_: Yn });
2938
+ function Zn(e, t) {
2939
+ let n = T(e, "a", "div"), s = T(t, "b", "div");
2940
+ if ([n, s] = q(n, s), n.dtype === "int32" && s.dtype === "int32")
2941
+ return Qn(n, s);
2942
+ const r = { a: n, b: s }, a = {};
2943
+ return g.runKernel(Je, r, a);
2944
+ }
2945
+ const x = /* @__PURE__ */ N({ div_: Zn });
2888
2946
  /**
2889
2947
  * @license
2890
2948
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2901,13 +2959,13 @@ const x = /* @__PURE__ */ N({ div_: Yn });
2901
2959
  * limitations under the License.
2902
2960
  * =============================================================================
2903
2961
  */
2904
- function Qn(n, t) {
2905
- let e = T(n, "a", "mul"), s = T(t, "b", "mul");
2906
- [e, s] = q(e, s);
2907
- const r = { a: e, b: s };
2908
- return g.runKernel(Xe, r);
2962
+ function ts(e, t) {
2963
+ let n = T(e, "a", "mul"), s = T(t, "b", "mul");
2964
+ [n, s] = q(n, s);
2965
+ const r = { a: n, b: s };
2966
+ return g.runKernel(Ze, r);
2909
2967
  }
2910
- const b = /* @__PURE__ */ N({ mul_: Qn });
2968
+ const b = /* @__PURE__ */ N({ mul_: ts });
2911
2969
  /**
2912
2970
  * @license
2913
2971
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -2924,17 +2982,17 @@ const b = /* @__PURE__ */ N({ mul_: Qn });
2924
2982
  * limitations under the License.
2925
2983
  * =============================================================================
2926
2984
  */
2927
- function Zn(n) {
2928
- const t = T(n, "x", "abs");
2985
+ function es(e) {
2986
+ const t = T(e, "x", "abs");
2929
2987
  if (t.dtype === "complex64") {
2930
- const e = { x: t };
2931
- return g.runKernel(je, e);
2988
+ const n = { x: t };
2989
+ return g.runKernel(He, n);
2932
2990
  } else {
2933
- const e = { x: t };
2934
- return g.runKernel(We, e);
2991
+ const n = { x: t };
2992
+ return g.runKernel(qe, n);
2935
2993
  }
2936
2994
  }
2937
- const ts = /* @__PURE__ */ N({ abs_: Zn });
2995
+ const ns = /* @__PURE__ */ N({ abs_: es });
2938
2996
  /**
2939
2997
  * @license
2940
2998
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2951,10 +3009,10 @@ const ts = /* @__PURE__ */ N({ abs_: Zn });
2951
3009
  * limitations under the License.
2952
3010
  * =============================================================================
2953
3011
  */
2954
- function es(n, t, e) {
2955
- xt(n), e = e || mt(t);
2956
- const s = { shape: n, value: t, dtype: e };
2957
- return g.runKernel(qe, {}, s);
3012
+ function ss(e, t, n) {
3013
+ xt(e), n = n || pt(t);
3014
+ const s = { shape: e, value: t, dtype: n };
3015
+ return g.runKernel(Xe, {}, s);
2958
3016
  }
2959
3017
  /**
2960
3018
  * @license
@@ -2972,29 +3030,37 @@ function es(n, t, e) {
2972
3030
  * limitations under the License.
2973
3031
  * =============================================================================
2974
3032
  */
2975
- function fo(n, t) {
2976
- const e = [];
3033
+ function ko(e, t) {
3034
+ const n = e.length, s = [];
3035
+ for (let r = 0; r < n; r++) {
3036
+ const a = n - 1 - r, o = e[a] || 1;
3037
+ (t[t.length - 1 - r] || 1) > 1 && o === 1 && s.unshift(a);
3038
+ }
3039
+ return s;
3040
+ }
3041
+ function Io(e, t) {
3042
+ const n = [];
2977
3043
  for (let s = 0; s < t.length; s++) {
2978
- const r = n[n.length - s - 1], a = t.length - s - 1, o = t[a];
2979
- (r == null || r === 1 && o > 1) && e.unshift(a);
3044
+ const r = e[e.length - s - 1], a = t.length - s - 1, o = t[a];
3045
+ (r == null || r === 1 && o > 1) && n.unshift(a);
2980
3046
  }
2981
- return e;
3047
+ return n;
2982
3048
  }
2983
- function ns(n, t) {
2984
- const e = Math.max(n.length, t.length), s = new Array(e);
2985
- for (let r = 0; r < e; r++) {
2986
- let a = n[n.length - r - 1];
3049
+ function rs(e, t) {
3050
+ const n = Math.max(e.length, t.length), s = new Array(n);
3051
+ for (let r = 0; r < n; r++) {
3052
+ let a = e[e.length - r - 1];
2987
3053
  a == null && (a = 1);
2988
3054
  let o = t[t.length - r - 1];
2989
3055
  if (o == null && (o = 1), a === 1)
2990
- s[e - r - 1] = o;
3056
+ s[n - r - 1] = o;
2991
3057
  else if (o === 1)
2992
- s[e - r - 1] = a;
3058
+ s[n - r - 1] = a;
2993
3059
  else if (a !== o) {
2994
- const i = `Operands could not be broadcast together with shapes ${n} and ${t}.`;
3060
+ const i = `Operands could not be broadcast together with shapes ${e} and ${t}.`;
2995
3061
  throw Error(i);
2996
3062
  } else
2997
- s[e - r - 1] = a;
3063
+ s[n - r - 1] = a;
2998
3064
  }
2999
3065
  return s;
3000
3066
  }
@@ -3014,11 +3080,11 @@ function ns(n, t) {
3014
3080
  * limitations under the License.
3015
3081
  * =============================================================================
3016
3082
  */
3017
- function ss(n) {
3018
- const e = { x: T(n, "x", "zerosLike") };
3019
- return g.runKernel(tn, e);
3083
+ function as(e) {
3084
+ const n = { x: T(e, "x", "zerosLike") };
3085
+ return g.runKernel(sn, n);
3020
3086
  }
3021
- const C = /* @__PURE__ */ N({ zerosLike_: ss });
3087
+ const C = /* @__PURE__ */ N({ zerosLike_: as });
3022
3088
  /**
3023
3089
  * @license
3024
3090
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -3035,13 +3101,13 @@ const C = /* @__PURE__ */ N({ zerosLike_: ss });
3035
3101
  * limitations under the License.
3036
3102
  * =============================================================================
3037
3103
  */
3038
- function rs(n, t) {
3039
- let e = T(n, "base", "pow"), s = T(t, "exp", "pow");
3040
- [e, s] = q(e, s);
3041
- const r = { a: e, b: s };
3042
- return g.runKernel(Ye, r);
3104
+ function os(e, t) {
3105
+ let n = T(e, "base", "pow"), s = T(t, "exp", "pow");
3106
+ [n, s] = q(n, s);
3107
+ const r = { a: n, b: s };
3108
+ return g.runKernel(tn, r);
3043
3109
  }
3044
- const Qt = /* @__PURE__ */ N({ pow_: rs });
3110
+ const Zt = /* @__PURE__ */ N({ pow_: os });
3045
3111
  /**
3046
3112
  * @license
3047
3113
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -3058,12 +3124,12 @@ const Qt = /* @__PURE__ */ N({ pow_: rs });
3058
3124
  * limitations under the License.
3059
3125
  * =============================================================================
3060
3126
  */
3061
- function K(n, t) {
3062
- if ((R(n) && t !== "string" || Array.isArray(n)) && t !== "complex64")
3127
+ function K(e, t) {
3128
+ if ((F(e) && t !== "string" || Array.isArray(e)) && t !== "complex64")
3063
3129
  throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");
3064
- if (t === "string" && R(n) && !(n instanceof Uint8Array))
3130
+ if (t === "string" && F(e) && !(e instanceof Uint8Array))
3065
3131
  throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");
3066
- return In(n, [], [], t);
3132
+ return En(e, [], [], t);
3067
3133
  }
3068
3134
  /**
3069
3135
  * @license
@@ -3081,11 +3147,11 @@ function K(n, t) {
3081
3147
  * limitations under the License.
3082
3148
  * =============================================================================
3083
3149
  */
3084
- function as(n) {
3085
- const e = { x: T(n, "x", "sqrt", "float32") };
3086
- return g.runKernel(Qe, e);
3150
+ function is(e) {
3151
+ const n = { x: T(e, "x", "sqrt", "float32") };
3152
+ return g.runKernel(en, n);
3087
3153
  }
3088
- const nt = /* @__PURE__ */ N({ sqrt_: as });
3154
+ const nt = /* @__PURE__ */ N({ sqrt_: is });
3089
3155
  /**
3090
3156
  * @license
3091
3157
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -3102,11 +3168,11 @@ const nt = /* @__PURE__ */ N({ sqrt_: as });
3102
3168
  * limitations under the License.
3103
3169
  * =============================================================================
3104
3170
  */
3105
- function os(n) {
3106
- const t = T(n, "x", "square"), e = {};
3107
- return g.runKernel("Square", { x: t }, e);
3171
+ function cs(e) {
3172
+ const t = T(e, "x", "square"), n = {};
3173
+ return g.runKernel("Square", { x: t }, n);
3108
3174
  }
3109
- const V = /* @__PURE__ */ N({ square_: os });
3175
+ const V = /* @__PURE__ */ N({ square_: cs });
3110
3176
  /**
3111
3177
  * @license
3112
3178
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -3123,25 +3189,40 @@ const V = /* @__PURE__ */ N({ square_: os });
3123
3189
  * limitations under the License.
3124
3190
  * =============================================================================
3125
3191
  */
3126
- function is(n, t) {
3127
- y(kt(n), () => "The f passed in variableGrads(f) must be a function"), y(t == null || Array.isArray(t) && t.every((l) => l instanceof ft), () => "The varList passed in variableGrads(f, varList) must be an array of variables");
3128
- const e = t != null;
3129
- if (!e) {
3192
+ function To(e) {
3193
+ return y(ht(e), () => "The f passed in grads(f) must be a function"), (t, n) => {
3194
+ y(Array.isArray(t), () => "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");
3195
+ const s = In(t, "args", "tf.grads", "string_or_numeric"), r = n != null ? T(n, "dy", "tf.grads") : null;
3196
+ return g.tidy(() => {
3197
+ const { value: a, grads: o } = g.gradients(() => e(...s), s, r);
3198
+ return r != null && De(a.shape, r.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), us(o), o;
3199
+ });
3200
+ };
3201
+ }
3202
+ function ls(e, t) {
3203
+ y(ht(e), () => "The f passed in variableGrads(f) must be a function"), y(t == null || Array.isArray(t) && t.every((l) => l instanceof gt), () => "The varList passed in variableGrads(f, varList) must be an array of variables");
3204
+ const n = t != null;
3205
+ if (!n) {
3130
3206
  t = [];
3131
3207
  for (const l in g.registeredVariables)
3132
3208
  t.push(g.registeredVariables[l]);
3133
3209
  }
3134
- const s = e ? t.filter((l) => !l.trainable) : null, r = t.length;
3210
+ const s = n ? t.filter((l) => !l.trainable) : null, r = t.length;
3135
3211
  t = t.filter((l) => l.trainable), y(t.length > 0, () => `variableGrads() expects at least one of the input variables to be trainable, but none of the ${r} variables is trainable.`);
3136
- const a = !0, { value: o, grads: i } = g.gradients(n, t, null, a);
3212
+ const a = !0, { value: o, grads: i } = g.gradients(e, t, null, a);
3137
3213
  y(i.some((l) => l != null), () => "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()."), y(o.rank === 0, () => `The f passed in variableGrads(f) must return a scalar, but it returned a rank-${o.rank} tensor`);
3138
3214
  const c = {};
3139
3215
  return t.forEach((l, u) => {
3140
3216
  i[u] != null && (c[l.name] = i[u]);
3141
3217
  }), s?.forEach((l) => c[l.name] = null), { value: o, grads: c };
3142
3218
  }
3143
- function go(n) {
3144
- return g.customGrad(n);
3219
+ function Eo(e) {
3220
+ return g.customGrad(e);
3221
+ }
3222
+ function us(e) {
3223
+ if (e.filter((n) => n == null).length > 0)
3224
+ throw new Error(`Cannot compute gradient of y=f(x) with respect to x. Make sure that
3225
+ the f you passed encloses all operations that lead from x to y.`);
3145
3226
  }
3146
3227
  /**
3147
3228
  * @license
@@ -3159,13 +3240,13 @@ function go(n) {
3159
3240
  * limitations under the License.
3160
3241
  * =============================================================================
3161
3242
  */
3162
- function cs(n, t) {
3163
- let e = T(n, "a", "sub"), s = T(t, "b", "sub");
3164
- [e, s] = q(e, s);
3165
- const r = { a: e, b: s };
3166
- return g.runKernel(Ze, r);
3243
+ function hs(e, t) {
3244
+ let n = T(e, "a", "sub"), s = T(t, "b", "sub");
3245
+ [n, s] = q(n, s);
3246
+ const r = { a: n, b: s };
3247
+ return g.runKernel(nn, r);
3167
3248
  }
3168
- const tt = /* @__PURE__ */ N({ sub_: cs });
3249
+ const tt = /* @__PURE__ */ N({ sub_: hs });
3169
3250
  /**
3170
3251
  * @license
3171
3252
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -3182,13 +3263,13 @@ const tt = /* @__PURE__ */ N({ sub_: cs });
3182
3263
  * limitations under the License.
3183
3264
  * =============================================================================
3184
3265
  */
3185
- function ls(n, t) {
3186
- let e = T(n, "a", "maximum"), s = T(t, "b", "maximum");
3187
- [e, s] = q(e, s), e.dtype === "bool" && (e = Rt(e, "int32"), s = Rt(s, "int32")), ns(e.shape, s.shape);
3188
- const r = { a: e, b: s };
3189
- return g.runKernel(Je, r);
3266
+ function fs(e, t) {
3267
+ let n = T(e, "a", "maximum"), s = T(t, "b", "maximum");
3268
+ [n, s] = q(n, s), n.dtype === "bool" && (n = Ft(n, "int32"), s = Ft(s, "int32")), rs(n.shape, s.shape);
3269
+ const r = { a: n, b: s };
3270
+ return g.runKernel(Qe, r);
3190
3271
  }
3191
- const us = /* @__PURE__ */ N({ maximum_: ls });
3272
+ const ds = /* @__PURE__ */ N({ maximum_: fs });
3192
3273
  /**
3193
3274
  * @license
3194
3275
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -3205,8 +3286,8 @@ const us = /* @__PURE__ */ N({ maximum_: ls });
3205
3286
  * limitations under the License.
3206
3287
  * =============================================================================
3207
3288
  */
3208
- const hs = /* @__PURE__ */ new Map(), ds = /* @__PURE__ */ new Map();
3209
- class fs {
3289
+ const gs = /* @__PURE__ */ new Map(), ms = /* @__PURE__ */ new Map();
3290
+ class ps {
3210
3291
  /**
3211
3292
  * Return the class name for this class to use in serialization contexts.
3212
3293
  *
@@ -3230,11 +3311,11 @@ class fs {
3230
3311
  * @param config The Configuration for the object.
3231
3312
  */
3232
3313
  /** @nocollapse */
3233
- static fromConfig(t, e) {
3234
- return new t(e);
3314
+ static fromConfig(t, n) {
3315
+ return new t(n);
3235
3316
  }
3236
3317
  }
3237
- class U {
3318
+ class G {
3238
3319
  constructor() {
3239
3320
  this.classNameMap = {};
3240
3321
  }
@@ -3242,19 +3323,19 @@ class U {
3242
3323
  * Returns the singleton instance of the map.
3243
3324
  */
3244
3325
  static getMap() {
3245
- return U.instance == null && (U.instance = new U()), U.instance;
3326
+ return G.instance == null && (G.instance = new G()), G.instance;
3246
3327
  }
3247
3328
  /**
3248
3329
  * Registers the class as serializable.
3249
3330
  */
3250
3331
  static register(t) {
3251
- U.getMap().classNameMap[t.className] = [t, t.fromConfig];
3332
+ G.getMap().classNameMap[t.className] = [t, t.fromConfig];
3252
3333
  }
3253
3334
  }
3254
- function gs(n, t, e) {
3255
- y(n.className != null, () => "Class being registered does not have the static className property defined."), y(typeof n.className == "string", () => "className is required to be a string, but got type " + typeof n.className), y(n.className.length > 0, () => "Class being registered has an empty-string as its className, which is disallowed."), typeof t > "u" && (t = "Custom"), typeof e > "u" && (e = n.className);
3256
- const s = e, r = t + ">" + s;
3257
- return U.register(n), hs.set(r, n), ds.set(n, r), n;
3335
+ function ys(e, t, n) {
3336
+ y(e.className != null, () => "Class being registered does not have the static className property defined."), y(typeof e.className == "string", () => "className is required to be a string, but got type " + typeof e.className), y(e.className.length > 0, () => "Class being registered has an empty-string as its className, which is disallowed."), typeof t > "u" && (t = "Custom"), typeof n > "u" && (n = e.className);
3337
+ const s = n, r = t + ">" + s;
3338
+ return G.register(e), gs.set(r, e), ms.set(e, r), e;
3258
3339
  }
3259
3340
  /**
3260
3341
  * @license
@@ -3272,7 +3353,7 @@ function gs(n, t, e) {
3272
3353
  * limitations under the License.
3273
3354
  * =============================================================================
3274
3355
  */
3275
- class H extends fs {
3356
+ class H extends ps {
3276
3357
  /**
3277
3358
  * Executes `f()` and minimizes the scalar output of `f()` by computing
3278
3359
  * gradients of y with respect to the list of trainable variables provided by
@@ -3287,14 +3368,14 @@ class H extends fs {
3287
3368
  *
3288
3369
  * @doc {heading: 'Training', subheading: 'Optimizers'}
3289
3370
  */
3290
- minimize(t, e = !1, s) {
3371
+ minimize(t, n = !1, s) {
3291
3372
  const { value: r, grads: a } = this.computeGradients(t, s);
3292
3373
  if (s != null) {
3293
3374
  const o = s.map((i) => ({ name: i.name, tensor: a[i.name] }));
3294
3375
  this.applyGradients(o);
3295
3376
  } else
3296
3377
  this.applyGradients(a);
3297
- return M(a), e ? r : (r.dispose(), null);
3378
+ return M(a), n ? r : (r.dispose(), null);
3298
3379
  }
3299
3380
  /**
3300
3381
  * The number of iterations that this optimizer instance has been invoked for.
@@ -3318,8 +3399,8 @@ class H extends fs {
3318
3399
  *
3319
3400
  * @doc {heading: 'Training', subheading: 'Optimizers'}
3320
3401
  */
3321
- computeGradients(t, e) {
3322
- return is(t, e);
3402
+ computeGradients(t, n) {
3403
+ return ls(t, n);
3323
3404
  }
3324
3405
  /**
3325
3406
  * Dispose the variables (if any) owned by this optimizer instance.
@@ -3352,7 +3433,7 @@ class H extends fs {
3352
3433
  }
3353
3434
  }
3354
3435
  Object.defineProperty(H, Symbol.hasInstance, {
3355
- value: (n) => n.minimize != null && n.computeGradients != null && n.applyGradients != null
3436
+ value: (e) => e.minimize != null && e.computeGradients != null && e.applyGradients != null
3356
3437
  });
3357
3438
  /**
3358
3439
  * @license
@@ -3370,13 +3451,13 @@ Object.defineProperty(H, Symbol.hasInstance, {
3370
3451
  * limitations under the License.
3371
3452
  * =============================================================================
3372
3453
  */
3373
- class ms extends H {
3454
+ class bs extends H {
3374
3455
  /** @nocollapse */
3375
3456
  static get className() {
3376
3457
  return "Adadelta";
3377
3458
  }
3378
- constructor(t, e, s = null) {
3379
- super(), this.learningRate = t, this.rho = e, this.epsilon = s, this.accumulatedGrads = [], this.accumulatedUpdates = [], s == null && (this.epsilon = g.backend.epsilon());
3459
+ constructor(t, n, s = null) {
3460
+ super(), this.learningRate = t, this.rho = n, this.epsilon = s, this.accumulatedGrads = [], this.accumulatedUpdates = [], s == null && (this.epsilon = g.backend.epsilon());
3380
3461
  }
3381
3462
  applyGradients(t) {
3382
3463
  (Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t)).forEach((s, r) => {
@@ -3393,8 +3474,8 @@ class ms extends H {
3393
3474
  return;
3394
3475
  const c = this.accumulatedGrads[r].variable, l = this.accumulatedUpdates[r].variable;
3395
3476
  E(() => {
3396
- const u = S(b(c, this.rho), b(V(i), 1 - this.rho)), h = b(x(nt(S(l, this.epsilon)), nt(S(c, this.epsilon))), i), d = S(b(l, this.rho), b(V(h), 1 - this.rho));
3397
- c.assign(u), l.assign(d);
3477
+ const u = S(b(c, this.rho), b(V(i), 1 - this.rho)), h = b(x(nt(S(l, this.epsilon)), nt(S(c, this.epsilon))), i), f = S(b(l, this.rho), b(V(h), 1 - this.rho));
3478
+ c.assign(u), l.assign(f);
3398
3479
  const m = S(b(h, -this.learningRate), a);
3399
3480
  a.assign(m);
3400
3481
  });
@@ -3405,15 +3486,15 @@ class ms extends H {
3405
3486
  }
3406
3487
  async getWeights() {
3407
3488
  const t = [...this.accumulatedGrads, ...this.accumulatedUpdates];
3408
- return [await this.saveIterations()].concat(t.map((e) => ({ name: e.originalName, tensor: e.variable })));
3489
+ return [await this.saveIterations()].concat(t.map((n) => ({ name: n.originalName, tensor: n.variable })));
3409
3490
  }
3410
3491
  async setWeights(t) {
3411
3492
  t = await this.extractIterations(t);
3412
- const e = t.length / 2, s = !1;
3413
- this.accumulatedGrads = t.slice(0, e).map((r) => ({
3493
+ const n = t.length / 2, s = !1;
3494
+ this.accumulatedGrads = t.slice(0, n).map((r) => ({
3414
3495
  originalName: r.name,
3415
3496
  variable: r.tensor.variable(s)
3416
- })), this.accumulatedUpdates = t.slice(e, e * 2).map((r) => ({
3497
+ })), this.accumulatedUpdates = t.slice(n, n * 2).map((r) => ({
3417
3498
  originalName: r.name,
3418
3499
  variable: r.tensor.variable(s)
3419
3500
  }));
@@ -3426,8 +3507,8 @@ class ms extends H {
3426
3507
  };
3427
3508
  }
3428
3509
  /** @nocollapse */
3429
- static fromConfig(t, e) {
3430
- return new t(e.learningRate, e.rho, e.epsilon);
3510
+ static fromConfig(t, n) {
3511
+ return new t(n.learningRate, n.rho, n.epsilon);
3431
3512
  }
3432
3513
  }
3433
3514
  /**
@@ -3446,20 +3527,20 @@ class ms extends H {
3446
3527
  * limitations under the License.
3447
3528
  * =============================================================================
3448
3529
  */
3449
- class ps extends H {
3530
+ class ws extends H {
3450
3531
  /** @nocollapse */
3451
3532
  static get className() {
3452
3533
  return "Adagrad";
3453
3534
  }
3454
- constructor(t, e = 0.1) {
3455
- super(), this.learningRate = t, this.initialAccumulatorValue = e, this.accumulatedGrads = [];
3535
+ constructor(t, n = 0.1) {
3536
+ super(), this.learningRate = t, this.initialAccumulatorValue = n, this.accumulatedGrads = [];
3456
3537
  }
3457
3538
  applyGradients(t) {
3458
3539
  (Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t)).forEach((s, r) => {
3459
3540
  const a = g.registeredVariables[s];
3460
3541
  this.accumulatedGrads[r] == null && (this.accumulatedGrads[r] = {
3461
3542
  originalName: `${s}/accumulator`,
3462
- variable: E(() => es(a.shape, this.initialAccumulatorValue).variable(!1))
3543
+ variable: E(() => ss(a.shape, this.initialAccumulatorValue).variable(!1))
3463
3544
  });
3464
3545
  const o = Array.isArray(t) ? t[r].tensor : t[s];
3465
3546
  if (o == null)
@@ -3481,8 +3562,8 @@ class ps extends H {
3481
3562
  }
3482
3563
  async setWeights(t) {
3483
3564
  t = await this.extractIterations(t);
3484
- const e = !1;
3485
- this.accumulatedGrads = t.map((s) => ({ originalName: s.name, variable: s.tensor.variable(e) }));
3565
+ const n = !1;
3566
+ this.accumulatedGrads = t.map((s) => ({ originalName: s.name, variable: s.tensor.variable(n) }));
3486
3567
  }
3487
3568
  getConfig() {
3488
3569
  return {
@@ -3491,8 +3572,8 @@ class ps extends H {
3491
3572
  };
3492
3573
  }
3493
3574
  /** @nocollapse */
3494
- static fromConfig(t, e) {
3495
- return new t(e.learningRate, e.initialAccumulatorValue);
3575
+ static fromConfig(t, n) {
3576
+ return new t(n.learningRate, n.initialAccumulatorValue);
3496
3577
  }
3497
3578
  }
3498
3579
  /**
@@ -3511,21 +3592,21 @@ class ps extends H {
3511
3592
  * limitations under the License.
3512
3593
  * =============================================================================
3513
3594
  */
3514
- class ys extends H {
3595
+ class Ss extends H {
3515
3596
  /** @nocollapse */
3516
3597
  static get className() {
3517
3598
  return "Adam";
3518
3599
  }
3519
- constructor(t, e, s, r = null) {
3520
- super(), this.learningRate = t, this.beta1 = e, this.beta2 = s, this.epsilon = r, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], E(() => {
3521
- this.accBeta1 = K(e).variable(), this.accBeta2 = K(s).variable();
3600
+ constructor(t, n, s, r = null) {
3601
+ super(), this.learningRate = t, this.beta1 = n, this.beta2 = s, this.epsilon = r, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], E(() => {
3602
+ this.accBeta1 = K(n).variable(), this.accBeta2 = K(s).variable();
3522
3603
  }), r == null && (this.epsilon = g.backend.epsilon());
3523
3604
  }
3524
3605
  applyGradients(t) {
3525
- const e = Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t);
3606
+ const n = Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t);
3526
3607
  E(() => {
3527
3608
  const s = tt(1, this.accBeta1), r = tt(1, this.accBeta2);
3528
- e.forEach((a, o) => {
3609
+ n.forEach((a, o) => {
3529
3610
  const i = g.registeredVariables[a], c = !1;
3530
3611
  this.accumulatedFirstMoment[o] == null && (this.accumulatedFirstMoment[o] = {
3531
3612
  originalName: `${a}/m`,
@@ -3537,9 +3618,9 @@ class ys extends H {
3537
3618
  const l = Array.isArray(t) ? t[o].tensor : t[a];
3538
3619
  if (l == null)
3539
3620
  return;
3540
- const u = this.accumulatedFirstMoment[o].variable, h = this.accumulatedSecondMoment[o].variable, d = S(b(u, this.beta1), b(l, 1 - this.beta1)), m = S(b(h, this.beta2), b(V(l), 1 - this.beta2)), p = x(d, s), f = x(m, r);
3541
- u.assign(d), h.assign(m);
3542
- const w = S(b(x(p, S(nt(f), this.epsilon)), -this.learningRate), i);
3621
+ const u = this.accumulatedFirstMoment[o].variable, h = this.accumulatedSecondMoment[o].variable, f = S(b(u, this.beta1), b(l, 1 - this.beta1)), m = S(b(h, this.beta2), b(V(l), 1 - this.beta2)), p = x(f, s), d = x(m, r);
3622
+ u.assign(f), h.assign(m);
3623
+ const w = S(b(x(p, S(nt(d), this.epsilon)), -this.learningRate), i);
3543
3624
  i.assign(w);
3544
3625
  }), this.accBeta1.assign(b(this.accBeta1, this.beta1)), this.accBeta2.assign(b(this.accBeta2, this.beta2));
3545
3626
  }), this.incrementIterations();
@@ -3549,17 +3630,17 @@ class ys extends H {
3549
3630
  }
3550
3631
  async getWeights() {
3551
3632
  const t = [...this.accumulatedFirstMoment, ...this.accumulatedSecondMoment];
3552
- return [await this.saveIterations()].concat(t.map((e) => ({ name: e.originalName, tensor: e.variable })));
3633
+ return [await this.saveIterations()].concat(t.map((n) => ({ name: n.originalName, tensor: n.variable })));
3553
3634
  }
3554
3635
  async setWeights(t) {
3555
3636
  t = await this.extractIterations(t), E(() => {
3556
- this.accBeta1.assign(Qt(this.beta1, this.iterations_ + 1)), this.accBeta2.assign(Qt(this.beta2, this.iterations_ + 1));
3637
+ this.accBeta1.assign(Zt(this.beta1, this.iterations_ + 1)), this.accBeta2.assign(Zt(this.beta2, this.iterations_ + 1));
3557
3638
  });
3558
- const e = t.length / 2, s = !1;
3559
- this.accumulatedFirstMoment = t.slice(0, e).map((r) => ({
3639
+ const n = t.length / 2, s = !1;
3640
+ this.accumulatedFirstMoment = t.slice(0, n).map((r) => ({
3560
3641
  originalName: r.name,
3561
3642
  variable: r.tensor.variable(s)
3562
- })), this.accumulatedSecondMoment = t.slice(e, e * 2).map((r) => ({
3643
+ })), this.accumulatedSecondMoment = t.slice(n, n * 2).map((r) => ({
3563
3644
  originalName: r.name,
3564
3645
  variable: r.tensor.variable(s)
3565
3646
  }));
@@ -3573,8 +3654,8 @@ class ys extends H {
3573
3654
  };
3574
3655
  }
3575
3656
  /** @nocollapse */
3576
- static fromConfig(t, e) {
3577
- return new t(e.learningRate, e.beta1, e.beta2, e.epsilon);
3657
+ static fromConfig(t, n) {
3658
+ return new t(n.learningRate, n.beta1, n.beta2, n.epsilon);
3578
3659
  }
3579
3660
  }
3580
3661
  /**
@@ -3593,21 +3674,21 @@ class ys extends H {
3593
3674
  * limitations under the License.
3594
3675
  * =============================================================================
3595
3676
  */
3596
- class bs extends H {
3677
+ class ks extends H {
3597
3678
  /** @nocollapse */
3598
3679
  static get className() {
3599
3680
  return "Adamax";
3600
3681
  }
3601
- constructor(t, e, s, r = null, a = 0) {
3602
- super(), this.learningRate = t, this.beta1 = e, this.beta2 = s, this.epsilon = r, this.decay = a, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], E(() => {
3603
- this.iteration = K(0).variable(), this.accBeta1 = K(e).variable();
3682
+ constructor(t, n, s, r = null, a = 0) {
3683
+ super(), this.learningRate = t, this.beta1 = n, this.beta2 = s, this.epsilon = r, this.decay = a, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], E(() => {
3684
+ this.iteration = K(0).variable(), this.accBeta1 = K(n).variable();
3604
3685
  }), r == null && (this.epsilon = g.backend.epsilon());
3605
3686
  }
3606
3687
  applyGradients(t) {
3607
- const e = Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t);
3688
+ const n = Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t);
3608
3689
  E(() => {
3609
3690
  const s = tt(1, this.accBeta1), r = x(-this.learningRate, S(b(this.iteration, this.decay), 1));
3610
- e.forEach((a, o) => {
3691
+ n.forEach((a, o) => {
3611
3692
  const i = g.registeredVariables[a], c = !1;
3612
3693
  this.accumulatedFirstMoment[o] == null && (this.accumulatedFirstMoment[o] = {
3613
3694
  originalName: `${a}/m`,
@@ -3619,9 +3700,9 @@ class bs extends H {
3619
3700
  const l = Array.isArray(t) ? t[o].tensor : t[a];
3620
3701
  if (l == null)
3621
3702
  return;
3622
- const u = this.accumulatedFirstMoment[o].variable, h = this.accumulatedWeightedInfNorm[o].variable, d = S(b(u, this.beta1), b(l, 1 - this.beta1)), m = b(h, this.beta2), p = ts(l), f = us(m, p);
3623
- u.assign(d), h.assign(f);
3624
- const w = S(b(x(r, s), x(d, S(f, this.epsilon))), i);
3703
+ const u = this.accumulatedFirstMoment[o].variable, h = this.accumulatedWeightedInfNorm[o].variable, f = S(b(u, this.beta1), b(l, 1 - this.beta1)), m = b(h, this.beta2), p = ns(l), d = ds(m, p);
3704
+ u.assign(f), h.assign(d);
3705
+ const w = S(b(x(r, s), x(f, S(d, this.epsilon))), i);
3625
3706
  i.assign(w);
3626
3707
  }), this.iteration.assign(S(this.iteration, 1)), this.accBeta1.assign(b(this.accBeta1, this.beta1));
3627
3708
  }), this.incrementIterations();
@@ -3645,8 +3726,8 @@ class bs extends H {
3645
3726
  };
3646
3727
  }
3647
3728
  /** @nocollapse */
3648
- static fromConfig(t, e) {
3649
- return new t(e.learningRate, e.beta1, e.beta2, e.epsilon, e.decay);
3729
+ static fromConfig(t, n) {
3730
+ return new t(n.learningRate, n.beta1, n.beta2, n.epsilon, n.decay);
3650
3731
  }
3651
3732
  }
3652
3733
  /**
@@ -3665,7 +3746,7 @@ class bs extends H {
3665
3746
  * limitations under the License.
3666
3747
  * =============================================================================
3667
3748
  */
3668
- class Ee extends H {
3749
+ class ve extends H {
3669
3750
  /** @nocollapse */
3670
3751
  static get className() {
3671
3752
  return "SGD";
@@ -3689,7 +3770,7 @@ class Ee extends H {
3689
3770
  * Sets the learning rate of the optimizer.
3690
3771
  */
3691
3772
  setLearningRate(t) {
3692
- this.learningRate = t, this.c != null && this.c.dispose(), this.c = En(K(-t));
3773
+ this.learningRate = t, this.c != null && this.c.dispose(), this.c = Bn(K(-t));
3693
3774
  }
3694
3775
  dispose() {
3695
3776
  this.c.dispose();
@@ -3705,8 +3786,8 @@ class Ee extends H {
3705
3786
  return { learningRate: this.learningRate };
3706
3787
  }
3707
3788
  /** @nocollapse */
3708
- static fromConfig(t, e) {
3709
- return new t(e.learningRate);
3789
+ static fromConfig(t, n) {
3790
+ return new t(n.learningRate);
3710
3791
  }
3711
3792
  }
3712
3793
  /**
@@ -3725,14 +3806,14 @@ class Ee extends H {
3725
3806
  * limitations under the License.
3726
3807
  * =============================================================================
3727
3808
  */
3728
- class ws extends Ee {
3809
+ class Is extends ve {
3729
3810
  /** @nocollapse */
3730
3811
  // Name matters for Python compatibility.
3731
3812
  static get className() {
3732
3813
  return "Momentum";
3733
3814
  }
3734
- constructor(t, e, s = !1) {
3735
- super(t), this.learningRate = t, this.momentum = e, this.useNesterov = s, this.accumulations = [], this.m = K(this.momentum);
3815
+ constructor(t, n, s = !1) {
3816
+ super(t), this.learningRate = t, this.momentum = n, this.useNesterov = s, this.accumulations = [], this.m = K(this.momentum);
3736
3817
  }
3737
3818
  applyGradients(t) {
3738
3819
  (Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t)).forEach((s, r) => {
@@ -3765,8 +3846,8 @@ class ws extends Ee {
3765
3846
  }
3766
3847
  async setWeights(t) {
3767
3848
  t = await this.extractIterations(t);
3768
- const e = !1;
3769
- this.accumulations = t.map((s) => ({ originalName: s.name, variable: s.tensor.variable(e) }));
3849
+ const n = !1;
3850
+ this.accumulations = t.map((s) => ({ originalName: s.name, variable: s.tensor.variable(n) }));
3770
3851
  }
3771
3852
  getConfig() {
3772
3853
  return {
@@ -3776,8 +3857,8 @@ class ws extends Ee {
3776
3857
  };
3777
3858
  }
3778
3859
  /** @nocollapse */
3779
- static fromConfig(t, e) {
3780
- return new t(e.learningRate, e.momentum, e.useNesterov);
3860
+ static fromConfig(t, n) {
3861
+ return new t(n.learningRate, n.momentum, n.useNesterov);
3781
3862
  }
3782
3863
  }
3783
3864
  /**
@@ -3796,13 +3877,13 @@ class ws extends Ee {
3796
3877
  * limitations under the License.
3797
3878
  * =============================================================================
3798
3879
  */
3799
- class Ss extends H {
3880
+ class Ts extends H {
3800
3881
  /** @nocollapse */
3801
3882
  static get className() {
3802
3883
  return "RMSProp";
3803
3884
  }
3804
- constructor(t, e = 0.9, s = 0, r = null, a = !1) {
3805
- if (super(), this.learningRate = t, this.decay = e, this.momentum = s, this.epsilon = r, this.accumulatedMeanSquares = [], this.accumulatedMoments = [], this.accumulatedMeanGrads = [], this.centered = a, r == null && (this.epsilon = g.backend.epsilon()), t == null)
3885
+ constructor(t, n = 0.9, s = 0, r = null, a = !1) {
3886
+ if (super(), this.learningRate = t, this.decay = n, this.momentum = s, this.epsilon = r, this.accumulatedMeanSquares = [], this.accumulatedMoments = [], this.accumulatedMeanGrads = [], this.centered = a, r == null && (this.epsilon = g.backend.epsilon()), t == null)
3806
3887
  throw new Error("learningRate for RMSPropOptimizer must be defined.");
3807
3888
  }
3808
3889
  applyGradients(t) {
@@ -3825,14 +3906,14 @@ class Ss extends H {
3825
3906
  E(() => {
3826
3907
  const u = S(b(c, this.decay), b(V(i), 1 - this.decay));
3827
3908
  if (this.centered) {
3828
- const h = this.accumulatedMeanGrads[r].variable, d = S(b(h, this.decay), b(i, 1 - this.decay)), m = x(b(i, this.learningRate), nt(tt(u, S(V(d), this.epsilon)))), p = S(b(l, this.momentum), m);
3829
- c.assign(u), h.assign(d), l.assign(p);
3830
- const f = tt(a, p);
3831
- a.assign(f);
3909
+ const h = this.accumulatedMeanGrads[r].variable, f = S(b(h, this.decay), b(i, 1 - this.decay)), m = x(b(i, this.learningRate), nt(tt(u, S(V(f), this.epsilon)))), p = S(b(l, this.momentum), m);
3910
+ c.assign(u), h.assign(f), l.assign(p);
3911
+ const d = tt(a, p);
3912
+ a.assign(d);
3832
3913
  } else {
3833
- const h = S(b(c, this.decay), b(V(i), 1 - this.decay)), d = S(b(l, this.momentum), x(b(i, this.learningRate), nt(S(h, this.epsilon))));
3834
- c.assign(h), l.assign(d);
3835
- const m = tt(a, d);
3914
+ const h = S(b(c, this.decay), b(V(i), 1 - this.decay)), f = S(b(l, this.momentum), x(b(i, this.learningRate), nt(S(h, this.epsilon))));
3915
+ c.assign(h), l.assign(f);
3916
+ const m = tt(a, f);
3836
3917
  a.assign(m);
3837
3918
  }
3838
3919
  });
@@ -3843,18 +3924,18 @@ class Ss extends H {
3843
3924
  }
3844
3925
  async getWeights() {
3845
3926
  const t = [...this.accumulatedMeanSquares, ...this.accumulatedMoments];
3846
- return this.centered && t.push(...this.accumulatedMeanGrads), [await this.saveIterations()].concat(t.map((e) => ({ name: e.originalName, tensor: e.variable })));
3927
+ return this.centered && t.push(...this.accumulatedMeanGrads), [await this.saveIterations()].concat(t.map((n) => ({ name: n.originalName, tensor: n.variable })));
3847
3928
  }
3848
3929
  async setWeights(t) {
3849
3930
  t = await this.extractIterations(t);
3850
- const e = this.centered ? t.length / 3 : t.length / 2, s = !1;
3851
- this.accumulatedMeanSquares = t.slice(0, e).map((r) => ({
3931
+ const n = this.centered ? t.length / 3 : t.length / 2, s = !1;
3932
+ this.accumulatedMeanSquares = t.slice(0, n).map((r) => ({
3852
3933
  originalName: r.name,
3853
3934
  variable: r.tensor.variable(s)
3854
- })), this.accumulatedMoments = t.slice(e, e * 2).map((r) => ({
3935
+ })), this.accumulatedMoments = t.slice(n, n * 2).map((r) => ({
3855
3936
  originalName: r.name,
3856
3937
  variable: r.tensor.variable(s)
3857
- })), this.centered && (this.accumulatedMeanGrads = t.slice(e * 2, e * 3).map((r) => ({
3938
+ })), this.centered && (this.accumulatedMeanGrads = t.slice(n * 2, n * 3).map((r) => ({
3858
3939
  originalName: r.name,
3859
3940
  variable: r.tensor.variable(s)
3860
3941
  })));
@@ -3869,8 +3950,8 @@ class Ss extends H {
3869
3950
  };
3870
3951
  }
3871
3952
  /** @nocollapse */
3872
- static fromConfig(t, e) {
3873
- return new t(e.learningRate, e.decay, e.momentum, e.epsilon, e.centered);
3953
+ static fromConfig(t, n) {
3954
+ return new t(n.learningRate, n.decay, n.momentum, n.epsilon, n.centered);
3874
3955
  }
3875
3956
  }
3876
3957
  /**
@@ -3889,18 +3970,18 @@ class Ss extends H {
3889
3970
  * limitations under the License.
3890
3971
  * =============================================================================
3891
3972
  */
3892
- const ks = [
3893
- ms,
3894
- ps,
3895
- ys,
3973
+ const Es = [
3896
3974
  bs,
3897
3975
  ws,
3898
3976
  Ss,
3899
- Ee
3977
+ ks,
3978
+ Is,
3979
+ Ts,
3980
+ ve
3900
3981
  ];
3901
- function Is() {
3902
- for (const n of ks)
3903
- gs(n);
3982
+ function As() {
3983
+ for (const e of Es)
3984
+ ys(e);
3904
3985
  }
3905
3986
  /**
3906
3987
  * @license
@@ -3918,220 +3999,237 @@ function Is() {
3918
3999
  * limitations under the License.
3919
4000
  * =============================================================================
3920
4001
  */
3921
- Is();
4002
+ As();
3922
4003
  export {
3923
- Ur as $,
3924
- ys as A,
3925
- Ks as B,
3926
- Zs as C,
3927
- Sn as D,
4004
+ ns as $,
4005
+ Ss as A,
4006
+ Zs as B,
4007
+ or as C,
4008
+ ss as D,
3928
4009
  g as E,
3929
- In as F,
3930
- Nr as G,
3931
- Rr as H,
3932
- ya as I,
3933
- Qt as J,
3934
- or as K,
3935
- Da as L,
3936
- vs as M,
3937
- Qs as N,
3938
- te as O,
3939
- ha as P,
3940
- Ma as Q,
3941
- ma as R,
3942
- _a as S,
3943
- qr as T,
3944
- Rt as U,
3945
- La as V,
3946
- na as W,
3947
- sa as X,
3948
- Ka as Y,
3949
- S as Z,
3950
- Tr as _,
4010
+ Bn as F,
4011
+ Pr as G,
4012
+ To as H,
4013
+ Fs as I,
4014
+ kn as J,
4015
+ En as K,
4016
+ Lr as L,
4017
+ ta as M,
4018
+ Ea as N,
4019
+ Zt as O,
4020
+ ba as P,
4021
+ dr as Q,
4022
+ Ia as R,
4023
+ qa as S,
4024
+ Oa as T,
4025
+ De as U,
4026
+ ar as V,
4027
+ ne as W,
4028
+ aa as X,
4029
+ xe as Y,
4030
+ V as Z,
4031
+ oa as _,
3951
4032
  M as a,
3952
- Oa as a$,
3953
- Re as a0,
3954
- Ua as a1,
3955
- Zr as a2,
3956
- ts as a3,
3957
- nt as a4,
3958
- V as a5,
3959
- Qr as a6,
3960
- R as a7,
3961
- D as a8,
3962
- k as a9,
3963
- ns as aA,
3964
- Ir as aB,
3965
- Na as aC,
3966
- br as aD,
3967
- wr as aE,
3968
- kr as aF,
3969
- Er as aG,
3970
- zn as aH,
3971
- vr as aI,
3972
- Fr as aJ,
3973
- Dr as aK,
3974
- $r as aL,
3975
- Lr as aM,
3976
- Or as aN,
3977
- _r as aO,
3978
- Gr as aP,
3979
- ra as aQ,
3980
- Pa as aR,
3981
- zr as aS,
3982
- Vr as aT,
3983
- Hr as aU,
3984
- Xr as aV,
3985
- ta as aW,
3986
- aa as aX,
3987
- ua as aY,
3988
- la as aZ,
3989
- da as a_,
3990
- fe as aa,
3991
- so as ab,
3992
- dt as ac,
3993
- $s as ad,
3994
- xs as ae,
3995
- Cs as af,
3996
- Ne as ag,
3997
- zs as ah,
3998
- Ws as ai,
3999
- Ca as aj,
4000
- Fa as ak,
4001
- Wa as al,
4002
- qs as am,
4003
- Mr as an,
4004
- Hs as ao,
4005
- ja as ap,
4006
- Ys as aq,
4007
- tr as ar,
4008
- nr as as,
4009
- sr as at,
4010
- ar as au,
4011
- ir as av,
4012
- cr as aw,
4013
- lr as ax,
4014
- hr as ay,
4015
- dr as az,
4033
+ ko as a$,
4034
+ nt as a0,
4035
+ Qa as a1,
4036
+ Ca as a2,
4037
+ Fr as a3,
4038
+ qr as a4,
4039
+ S as a5,
4040
+ la as a6,
4041
+ ua as a7,
4042
+ Za as a8,
4043
+ F as a9,
4044
+ Ta as aA,
4045
+ Aa as aB,
4046
+ Ra as aC,
4047
+ $a as aD,
4048
+ Ds as aE,
4049
+ ro as aF,
4050
+ no as aG,
4051
+ eo as aH,
4052
+ Rt as aI,
4053
+ x as aJ,
4054
+ Io as aK,
4055
+ oo as aL,
4056
+ yr as aM,
4057
+ $r as aN,
4058
+ ao as aO,
4059
+ da as aP,
4060
+ ma as aQ,
4061
+ ga as aR,
4062
+ Na as aS,
4063
+ va as aT,
4064
+ to as aU,
4065
+ yo as aV,
4066
+ xs as aW,
4067
+ jt as aX,
4068
+ ue as aY,
4069
+ $t as aZ,
4070
+ $s as a_,
4071
+ D as aa,
4072
+ k as ab,
4073
+ pe as ac,
4074
+ fo as ad,
4075
+ dt as ae,
4076
+ za as af,
4077
+ _a as ag,
4078
+ er as ah,
4079
+ rr as ai,
4080
+ rs as aj,
4081
+ Pa as ak,
4082
+ Ar as al,
4083
+ Br as am,
4084
+ Rr as an,
4085
+ Wn as ao,
4086
+ xr as ap,
4087
+ _r as aq,
4088
+ Or as ar,
4089
+ Gr as as,
4090
+ Wr as at,
4091
+ jr as au,
4092
+ Kr as av,
4093
+ ha as aw,
4094
+ Jr as ax,
4095
+ ia as ay,
4096
+ Sa as az,
4016
4097
  b,
4017
- Ar as b$,
4018
- fa as b0,
4019
- pa as b1,
4020
- ba as b2,
4021
- Ea as b3,
4022
- Aa as b4,
4023
- Ba as b5,
4024
- va as b6,
4025
- Ra as b7,
4026
- $a as b8,
4027
- Ns as b9,
4028
- ps as bA,
4029
- co as bB,
4030
- gs as bC,
4031
- fs as bD,
4032
- U as bE,
4033
- We as bF,
4034
- Rs as bG,
4035
- Fs as bH,
4036
- se as bI,
4037
- Ds as bJ,
4038
- Ps as bK,
4039
- Ls as bL,
4040
- Os as bM,
4041
- Gs as bN,
4042
- _s as bO,
4043
- Us as bP,
4044
- js as bQ,
4045
- Vs as bR,
4046
- Js as bS,
4047
- re as bT,
4048
- Xs as bU,
4049
- je as bV,
4050
- rr as bW,
4051
- mr as bX,
4052
- yr as bY,
4053
- pr as bZ,
4054
- Sr as b_,
4055
- Ya as ba,
4056
- Xa as bb,
4057
- Ja as bc,
4058
- Ha as bd,
4059
- Ft as be,
4060
- x as bf,
4061
- er as bg,
4062
- fo as bh,
4063
- to as bi,
4064
- fr as bj,
4065
- gr as bk,
4066
- Za as bl,
4067
- ur as bm,
4068
- Br as bn,
4069
- Qa as bo,
4070
- oa as bp,
4071
- ca as bq,
4072
- ia as br,
4073
- Ia as bs,
4074
- Sa as bt,
4075
- qa as bu,
4076
- Ee as bv,
4077
- ws as bw,
4078
- Ss as bx,
4079
- ms as by,
4080
- bs as bz,
4081
- go as c,
4082
- He as c0,
4083
- ae as c1,
4084
- xr as c2,
4085
- Cr as c3,
4086
- Pr as c4,
4087
- Wr as c5,
4088
- Kr as c6,
4089
- jr as c7,
4090
- Je as c8,
4091
- Yr as c9,
4092
- Jr as ca,
4093
- ea as cb,
4094
- Xe as cc,
4095
- Ye as cd,
4096
- ga as ce,
4097
- Ke as cf,
4098
- Ta as cg,
4099
- ka as ch,
4100
- xa as ci,
4101
- Qe as cj,
4102
- za as ck,
4103
- Ga as cl,
4104
- Ze as cm,
4105
- Va as cn,
4106
- us as co,
4107
- tn as cp,
4108
- Pe as cq,
4109
- H as cr,
4110
- Bs as cs,
4111
- ho as ct,
4112
- lo as cu,
4113
- uo as cv,
4114
- ao as d,
4115
- oo as e,
4098
+ Vs as b$,
4099
+ Ps as b0,
4100
+ Cs as b1,
4101
+ Lt as b2,
4102
+ te as b3,
4103
+ uo as b4,
4104
+ de as b5,
4105
+ dn as b6,
4106
+ Re as b7,
4107
+ $e as b8,
4108
+ Rs as b9,
4109
+ ya as bA,
4110
+ pa as bB,
4111
+ wa as bC,
4112
+ ja as bD,
4113
+ Da as bE,
4114
+ xa as bF,
4115
+ La as bG,
4116
+ Ga as bH,
4117
+ so as bI,
4118
+ cr as bJ,
4119
+ io as bK,
4120
+ Sr as bL,
4121
+ kr as bM,
4122
+ ve as bN,
4123
+ Is as bO,
4124
+ Ts as bP,
4125
+ bs as bQ,
4126
+ ks as bR,
4127
+ ws as bS,
4128
+ ys as bT,
4129
+ ps as bU,
4130
+ G as bV,
4131
+ qe as bW,
4132
+ Ls as bX,
4133
+ _s as bY,
4134
+ ae as bZ,
4135
+ Os as b_,
4136
+ ho as ba,
4137
+ Gs as bb,
4138
+ Us as bc,
4139
+ zs as bd,
4140
+ Js as be,
4141
+ Ys as bf,
4142
+ Ya as bg,
4143
+ tr as bh,
4144
+ Cr as bi,
4145
+ ir as bj,
4146
+ lr as bk,
4147
+ ur as bl,
4148
+ fr as bm,
4149
+ gr as bn,
4150
+ mr as bo,
4151
+ pr as bp,
4152
+ br as bq,
4153
+ wr as br,
4154
+ Nr as bs,
4155
+ Mr as bt,
4156
+ Hr as bu,
4157
+ Va as bv,
4158
+ Xr as bw,
4159
+ ea as bx,
4160
+ sa as by,
4161
+ fa as bz,
4162
+ Eo as c,
4163
+ Ws as c0,
4164
+ js as c1,
4165
+ Hs as c2,
4166
+ Ks as c3,
4167
+ qs as c4,
4168
+ Qs as c5,
4169
+ Xs as c6,
4170
+ nr as c7,
4171
+ oe as c8,
4172
+ sr as c9,
4173
+ en as cA,
4174
+ Ja as cB,
4175
+ Ha as cC,
4176
+ nn as cD,
4177
+ Xa as cE,
4178
+ ds as cF,
4179
+ sn as cG,
4180
+ Oe as cH,
4181
+ H as cI,
4182
+ Ns as cJ,
4183
+ So as cK,
4184
+ bo as cL,
4185
+ wo as cM,
4186
+ He as ca,
4187
+ hr as cb,
4188
+ Ir as cc,
4189
+ Er as cd,
4190
+ Tr as ce,
4191
+ vr as cf,
4192
+ Dr as cg,
4193
+ Ye as ch,
4194
+ ie as ci,
4195
+ Ur as cj,
4196
+ zr as ck,
4197
+ Vr as cl,
4198
+ Yr as cm,
4199
+ Zr as cn,
4200
+ Qr as co,
4201
+ Qe as cp,
4202
+ ra as cq,
4203
+ na as cr,
4204
+ ca as cs,
4205
+ Ze as ct,
4206
+ tn as cu,
4207
+ ka as cv,
4208
+ Je as cw,
4209
+ Fa as cx,
4210
+ Ma as cy,
4211
+ Ua as cz,
4212
+ go as d,
4213
+ mo as e,
4116
4214
  K as f,
4117
- no as g,
4215
+ lo as g,
4118
4216
  T as h,
4119
- ro as i,
4217
+ In as i,
4120
4218
  y as j,
4121
4219
  xt as k,
4122
- Le as l,
4123
- io as m,
4220
+ Ge as l,
4221
+ po as m,
4124
4222
  z as n,
4125
4223
  N as o,
4126
4224
  q as p,
4127
- wa as q,
4128
- eo as r,
4225
+ Ba as q,
4226
+ co as r,
4129
4227
  tt as s,
4130
4228
  E as t,
4131
- jn as u,
4132
- is as v,
4133
- es as w,
4134
- En as x,
4135
- Ms as y,
4229
+ Ka as u,
4230
+ ls as v,
4231
+ qn as w,
4232
+ Ft as x,
4233
+ Wa as y,
4136
4234
  C as z
4137
4235
  };