import { createSoftmaxCrossEntropyWithGrad as n } from "./sparseCrossEntropy.js";
function i(t, s, r, c, o) {
  try {
    return n(
      r,
      c,
      o && o > 0 ? o : void 0
    )(t, s);
  } catch (a) {
    throw console.error("Error computing loss:", a), new Error(`Loss computation failed: ${a}`);
  }
}
function l(t, s) {
  try {
    const r = t.argMax(-1), c = r.equal(s).cast("float32"), o = c.mean();
    return r.dispose(), c.dispose(), o;
  } catch (r) {
    throw console.error("Error computing accuracy:", r), new Error(`Accuracy computation failed: ${r}`);
  }
}
export {
  l as calculateAccuracy,
  i as calculateLoss
};
