import { N as d, a9 as A, a8 as O, v as g, av as _, az as w, ad as D, _ as x, $ as b, am as y, aY as M } from "./index-DSGwv2Yx.js";
import { d as T, f as L, h as v, c as W, e as F, a as N, b as C, g as P } from "./axis_util-QWWgLjut.js";
import { a as z, c as B } from "./concat_util-C1Mxe27t.js";
import { c as U, b as H, d as V, f as G, g as Z, h as j, i as q, j as J, k as K, m as X, t as Y } from "./step-DQY6_ABw.js";
import { S as k, a as Q, b as ee, g as te, c as se, s as ne } from "./selu_util-BXdhy_W6.js";
import { c as re, v as oe, a as ie } from "./scatter_nd_util-C-x73Cj6.js";
import { a as ae, c as ue, b as ce, e as pe, d as le, g as fe, m as he, s as ge } from "./complex_util-Yc1A_gV1.js";
function de(e, t) {
  const r = e.shape.length, n = t.shape.length;
  if (r < 1)
    throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${r}.`);
  if (n < 1)
    throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${n}.`);
  if (t.dtype !== "int32")
    throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);
  if (t.shape[n - 1] > r)
    throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[n - 1]} vs. ${r}`);
  if (d(e.shape) === 0)
    throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);
  const s = t.shape, i = s[s.length - 1];
  let o = 1;
  for (let c = 0; c < s.length - 1; ++c)
    o *= s[c];
  const a = e.shape, p = s.slice();
  p.pop();
  let h = 1;
  for (let c = i; c < r; ++c)
    h *= a[c], p.push(a[c]);
  const m = [
    ...A(e.shape).map((c) => c / h),
    1
  ].slice(0, i);
  return [p, o, h, m];
}
var f;
(function(e) {
  e[e.FIRST_DIM_SIZE = 0] = "FIRST_DIM_SIZE", e[e.VALUE_ROWIDS = 1] = "VALUE_ROWIDS", e[e.ROW_LENGTHS = 2] = "ROW_LENGTHS", e[e.ROW_SPLITS = 3] = "ROW_SPLITS", e[e.ROW_LIMITS = 4] = "ROW_LIMITS", e[e.ROW_STARTS = 5] = "ROW_STARTS";
})(f || (f = {}));
function me(e, t, r) {
  let n = new Array();
  if (r == null && t == null)
    return n;
  if (t == null)
    for (; n.length < e + r.length; )
      n.push(-1);
  else
    n = t.slice();
  if (r == null)
    return n;
  if (e + r.length !== n.length)
    throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e + r.length}, but shape.rank = ${n.length}`);
  for (let s = 1; s < r.length; ++s) {
    const i = r[s], o = n[n.length - r.length + s], a = n[o];
    if (i >= 0)
      if (a >= 0) {
        if (a !== i)
          throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${s + e}] = ${i} but shape[${s + e}] = ${a}`);
      } else
        n[o] = i;
  }
  return n;
}
function Ie(e) {
  const t = {
    FIRST_DIM_SIZE: f.FIRST_DIM_SIZE,
    VALUE_ROWIDS: f.VALUE_ROWIDS,
    ROW_LENGTHS: f.ROW_LENGTHS,
    ROW_SPLITS: f.ROW_SPLITS,
    ROW_LIMITS: f.ROW_LIMITS,
    ROW_STARTS: f.ROW_STARTS
  }, r = [];
  for (const n of e)
    if (n in t)
      r.push(t[n]);
    else
      break;
  return r;
}
function Ee(e) {
  return e.length === 0 ? 0 : e[0] === f.FIRST_DIM_SIZE ? e.length - 1 : e.length;
}
function $e(e, t) {
  if (e == null || t == null)
    return;
  const r = e.length, n = t.length;
  if (r >= n)
    throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${r} must be less than ragged tensor input flatValues.rank = ${n})`);
  for (let s = 0; s < Math.min(r, n - 1); ++s) {
    const i = e[s], o = t[s + 1];
    if (i >= 0 && o >= 0 && i !== 1 && i !== o)
      throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${s - e.length}] = ${i} but ragged tensor input.flatValues.shape[${s - e.length}] = ${o}`);
  }
}
const S = 30;
function Se(e) {
  return e <= S ? e : O(e, Math.floor(Math.sqrt(e)));
}
function Re(e, t, r) {
  const n = r * (typeof e == "number" ? e : e[0]), s = t * (typeof e == "number" ? e : e[1]);
  return [n, s];
}
function Ae(e, t, r, n = !0) {
  let s = [];
  if (n)
    s = s.concat(t.slice(0)), s.push(e[0] / r), s = s.concat(e.slice(1));
  else {
    s = s.concat(e[0]);
    const i = t.length;
    for (let o = 0; o < i; ++o)
      s = s.concat([e[o + 1] / t[o], t[o]]);
    s = s.concat(e.slice(i + 1));
  }
  return s;
}
function Oe(e, t, r = !0) {
  const n = [];
  if (r) {
    n.push(t);
    for (let s = t + 1; s < e; ++s)
      s <= 2 * t ? (n.push(s), n.push(s - (t + 1))) : n.push(s);
  } else {
    const s = [], i = [];
    for (let o = 1; o < e; ++o)
      o >= t * 2 + 1 || o % 2 === 1 ? i.push(o) : s.push(o);
    n.push(...s), n.push(0), n.push(...i);
  }
  return n;
}
function _e(e, t, r, n = !0) {
  const s = [];
  n ? s.push(e[0] / r) : s.push(e[0] * r);
  for (let i = 1; i < e.length; ++i)
    i <= t.length ? n ? s.push(t[i - 1] * e[i]) : s.push(e[i] / t[i - 1]) : s.push(e[i]);
  return s;
}
function we(e, t) {
  const r = [0];
  for (let n = 0; n < t; ++n)
    r.push(e[n][0]);
  return r;
}
function De(e, t, r) {
  const n = e.slice(0, 1);
  for (let s = 0; s < r; ++s)
    n.push(e[s + 1] - t[s][0] - t[s][1]);
  return n;
}
const xe = 0.3275911, be = 0.254829592, ye = -0.284496736, Me = 1.421413741, Te = -1.453152027, Le = 1.061405429;
const I = "->", ve = /->/g, E = ",", $ = "...";
function We(e, t) {
  e = e.replace(/\s/g, "");
  const r = (e.length - e.replace(ve, "").length) / I.length;
  if (r < 1)
    throw new Error("Equations without an arrow are not supported.");
  if (r > 1)
    throw new Error(`Equation must contain exactly one arrow ("${I}").`);
  const [n, s] = e.split(I);
  g(n.indexOf($) === -1, () => `The ellipsis notation ("${$}") is not supported yet.`);
  const i = n.split(E), o = i.length;
  if (t !== o)
    throw new Error(`Expected ${o} input tensors, received ${t}`);
  if (o > 2)
    throw new Error("Support for more than 2 input tensors is not implemented yet.");
  const a = [];
  for (let u = 0; u < s.length; ++u) {
    const l = s[u];
    if (!i.some((R) => R.indexOf(l) !== -1))
      throw new Error(`Output subscripts contain the label ${l} not present in the input subscripts.`);
    a.indexOf(l) === -1 && a.push(l);
  }
  for (let u = 0; u < n.length; ++u) {
    const l = n[u];
    a.indexOf(l) === -1 && l !== E && a.push(l);
  }
  const p = new Array(i.length);
  for (let u = 0; u < o; ++u) {
    if (new Set(i[u].split("")).size !== i[u].length)
      throw new Error(`Found duplicate axes in input component ${i[u]}. Support for duplicate axes in input is not implemented yet.`);
    p[u] = [];
    for (let l = 0; l < i[u].length; ++l)
      p[u].push(a.indexOf(i[u][l]));
  }
  const h = a.length, m = s.length, c = [];
  for (let u = m; u < h; ++u)
    c.push(u);
  return { allDims: a, summedDims: c, idDims: p };
}
function Fe(e, t) {
  let r = new Array(e);
  r.fill(-1);
  for (let s = 0; s < t.length; ++s)
    r[t[s]] = s;
  const n = [];
  for (let s = 0; s < e; ++s)
    r[s] === -1 && n.push(s);
  return r = r.filter((s) => s !== -1), { permutationIndices: r, expandDims: n };
}
function Ne(e, t, r) {
  const n = new Array(e);
  for (let s = 0; s < r.length; ++s) {
    const i = r[s].shape;
    for (let o = 0; o < t[s].length; ++o)
      n[t[s][o]] === void 0 ? n[t[s][o]] = i[o] : g(n[t[s][o]] === i[o], () => `Expected dimension ${n[t[s][o]]} at axis ${o} of input shaped ${JSON.stringify(i)}, but got dimension ${i[o]}`);
  }
}
function Ce(e, t) {
  const r = e, n = [];
  let s = 0;
  e.length === 0 && r.push(-1), s = e.length + 1;
  for (let o = 0; o < s; ++o)
    n.push([]);
  const i = [];
  for (let o = 0; o < r.length; ++o) {
    const a = r[o], p = ze(t, a);
    for (const h of p)
      i.indexOf(h) === -1 && (n[o].push(h), i.push(h));
  }
  return { path: r, steps: n };
}
function Pe(e) {
  return e.every((t, r) => t === r);
}
function ze(e, t) {
  const r = [];
  for (let n = 0; n < e.length; ++n)
    (e[n].length === 0 || e[n].indexOf(t) !== -1 || t === -1) && r.push(n);
  return r;
}
function Be(e, t, r = 0) {
  let n = [];
  if (typeof t == "number")
    g(e.shape[r] % t === 0, () => "Number of splits must evenly divide the axis."), n = new Array(t).fill(e.shape[r] / t);
  else {
    const s = t.reduce((o, a) => (a === -1 && (o += 1), o), 0);
    g(s <= 1, () => "There should be only one negative value in split array.");
    const i = t.indexOf(-1);
    if (i !== -1) {
      const o = t.reduce((a, p) => p > 0 ? a + p : a);
      t[i] = e.shape[r] - o;
    }
    g(e.shape[r] === t.reduce((o, a) => o + a), () => "The sum of sizes must match the size of the axis dimension."), n = t;
  }
  return n;
}
function Ue(e) {
  return `Received SparseTensor with denseShape[0] = 0 but
  indices.shape[0] = ${e}`;
}
function He(e, t) {
  return `indices(${e}, 0) is invalid: ${t} < 0`;
}
function Ve(e, t, r) {
  return `indices(${e}, 0) is invalid: ${t} >= ${r}`;
}
function Ge(e, t) {
  return `only one output dimension may be -1, not both ${e} and ${t}`;
}
function Ze(e, t) {
  return `size ${e} must be non-negative, not ${t}`;
}
function je() {
  return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";
}
function qe(e, t) {
  const r = d(e), n = d(t);
  return `Input to reshape is a SparseTensor with ${r}
  dense values, but the requested shape requires a multiple of ${n}. inputShape=${e} outputShape= ${t}`;
}
function Je(e, t) {
  const r = d(e), n = d(t);
  return `Input to reshape is a tensor with ${r} dense values, but the requested shape has ${n}. inputShape=${e} outputShape=${t}`;
}
function Ke() {
  return "segment ids must be >= 0";
}
function Xe() {
  return "segment ids are not increasing";
}
function Ye(e, t) {
  return `Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`;
}
function ke(e, t, r) {
  return `Bad: indices[${e}] == ${t} out of range [0, ${r})`;
}
function Qe(e) {
  try {
    return e.map((t) => _(t));
  } catch (t) {
    throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`);
  }
}
function et(e) {
  return e.map((t) => w(t));
}
const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  ERF_A1: be,
  ERF_A2: ye,
  ERF_A3: Me,
  ERF_A4: Te,
  ERF_A5: Le,
  ERF_P: xe,
  PARALLELIZE_THRESHOLD: S,
  get RowPartitionType() {
    return f;
  },
  SELU_SCALE: k,
  SELU_SCALEALPHA: Q,
  applyActivation: ee,
  assertAndGetBroadcastShape: x,
  assertAxesAreInnerMostDims: T,
  assertParamsConsistent: z,
  assignToTypedArray: ae,
  axesAreInnerMostDims: L,
  calculateShapes: re,
  checkEinsumDimSizes: Ne,
  checkPadOnDimRoundingMode: U,
  combineLocations: v,
  combineRaggedTensorToTensorShapes: me,
  complexWithEvenIndex: ue,
  complexWithOddIndex: ce,
  computeConv2DInfo: H,
  computeConv3DInfo: V,
  computeDefaultPad: G,
  computeDilation2DInfo: Z,
  computeOptimalWindowSize: Se,
  computeOutAndReduceShapes: W,
  computeOutShape: B,
  computePool2DInfo: j,
  computePool3DInfo: q,
  convertConv2DDataFormat: J,
  decodeEinsumEquation: We,
  eitherStridesOrDilationsAreOne: K,
  expandShapeToKeepDim: F,
  exponent: pe,
  exponents: le,
  fromStringArrayToUint8: et,
  fromUint8ToStringArray: Qe,
  getAxesPermutation: N,
  getBroadcastDims: D,
  getComplexWithIndex: fe,
  getEinsumComputePath: Ce,
  getEinsumPermutation: Fe,
  getFusedBiasGradient: te,
  getFusedDyActivation: se,
  getImageCenter: Re,
  getInnerMostAxes: C,
  getPermuted: Oe,
  getRaggedRank: Ee,
  getReductionAxes: b,
  getReshaped: Ae,
  getReshapedPermuted: _e,
  getRowPartitionTypesHelper: Ie,
  getSliceBeginCoords: we,
  getSliceSize: De,
  getSparseFillEmptyRowsIndicesDenseShapeMismatch: Ue,
  getSparseFillEmptyRowsNegativeIndexErrorMessage: He,
  getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: Ve,
  getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: je,
  getSparseReshapeInputOutputMismatchErrorMessage: Je,
  getSparseReshapeInputOutputMultipleErrorMessage: qe,
  getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: Ge,
  getSparseReshapeNegativeOutputDimErrorMessage: Ze,
  getSparseSegmentReductionIndicesOutOfRangeErrorMessage: ke,
  getSparseSegmentReductionNegativeSegmentIdsErrorMessage: Ke,
  getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: Xe,
  getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: Ye,
  getUndoAxesPermutation: P,
  isIdentityPermutation: Pe,
  mergeRealAndImagArrays: he,
  prepareAndValidate: de,
  prepareSplitSize: Be,
  shouldFuse: ne,
  splitRealAndImagArrays: ge,
  stridesOrDilationsArePositive: X,
  tupleValuesAreOne: Y,
  upcastType: y,
  validateDefaultValueShape: $e,
  validateInput: oe,
  validateUpdateShape: ie,
  warn: M
}, Symbol.toStringTag, { value: "Module" }));
export {
  Oe as A,
  _e as B,
  we as C,
  De as D,
  xe as E,
  We as F,
  Ne as G,
  Ce as H,
  Fe as I,
  Pe as J,
  de as K,
  Re as L,
  Be as M,
  S as P,
  f as R,
  Ee as a,
  ut as b,
  Se as c,
  me as d,
  et as e,
  Qe as f,
  Ie as g,
  Ue as h,
  He as i,
  Ve as j,
  Ge as k,
  Ze as l,
  je as m,
  qe as n,
  Je as o,
  Ke as p,
  Xe as q,
  Ye as r,
  ke as s,
  be as t,
  ye as u,
  $e as v,
  Me as w,
  Te as x,
  Le as y,
  Ae as z
};
