import "../index-DSGwv2Yx.js";
import "../random_width-B_fVXhGx.js";
import "../zeros_like-rOHr54NY.js";
import "../Generator.js";
import "../index-Cp39cXWe.js";
import "../dataset-DlqAN81i.js";
import "../ops/cpu/attentionMask.js";
import "../ops/webgl/attentionMask.js";
import "../ops/grads/attentionMask.js";
import "../ops/cpu/rope.js";
import "../ops/webgl/rope.js";
import "../rope-CC5RjmKU.js";
import "../ops/cpu/appendCache.js";
import "../ops/webgl/appendCache.js";
import "../ops/grads/softmax16.js";
import "../matMul16-BIT70Vya.js";
import "../ops/webgl/matMul16.js";
import "../ops/cpu/matMul16.js";
import "../pack16-WlOSOuZA.js";
import "../ops/transpose16.js";
import "../ops/reshape16.js";
import "../ops/cpu/qkv.js";
import "../ops/webgl/qkv.js";
import "../ops/grads/qkv.js";
import "../ops/cpu/normRMS.js";
import "../ops/webgl/normRMS.js";
import "../ops/grads/normRMS.js";
import "../ops/dropout16.js";
import "../ops/webgl/dropout16.js";
import "../ops/grads/add16.js";
import "../jszip.min-BZhlzntC.js";
import "../index-DvYrXKkX.js";
import "../ops/cpu/adamAdjust.js";
import "../ops/webgl/adamAdjust.js";
import "../ops/cpu/adamMoments.js";
import "../ops/webgl/adamMoments.js";
import "../ops/cpu/gatherSub.js";
import "../ops/webgl/gatherSub.js";
import "../ops/cpu/scatterSub.js";
import "../ops/webgl/scatterSub.js";
import { PAGE_FACTOR as m, shuffle as h } from "./DatasetBuilder.js";
import { tokensFromTasks as k } from "./tasks/Task.js";
import "../papaparse.min-C0cScC2i.js";
import "../ops/cpu/matMulGelu.js";
import "../matMulGelu-CsZnh18H.js";
import "../ops/grads/matMulGelu.js";
import "../ops/cpu/gelu.js";
import "../ops/webgl/gelu.js";
import "../gelu-DpTCC3eB.js";
import "../ops/webgl/log.js";
import "../checks/normRMS.js";
import "../checks/normRMSGrad.js";
async function dt(p, g, o, s, l = 0.1) {
  const i = p instanceof Uint16Array ? p : await k(p, g), r = /* @__PURE__ */ new Set();
  if (l > 0) {
    const t = Math.floor(i.length / (o.blockSize * m)), n = Math.max(1, Math.floor(t * l));
    for (; r.size < n; ) {
      const d = Math.floor(Math.random() * t);
      r.add(d);
    }
  }
  const a = new Uint32Array(
    i.length - r.size * o.blockSize * m
  ), e = new Uint32Array(r.size * o.blockSize * m);
  let c = 0, f = 0;
  for (let t = 0; t < i.length; t++) {
    const n = Math.floor(t / (o.blockSize * m));
    r.has(n) ? f < e.length && (e[f++] = t) : c < a.length && (a[c++] = t);
  }
  const { dataset: x, state: w } = await o.createTextDataset(
    i,
    s,
    h(a)
  ), { dataset: z, state: M } = await o.createTextDataset(
    i,
    s,
    h(e)
  );
  return { trainDataset: x, validationDataset: z, size: i.length, validationState: M, trainState: w };
}
export {
  dt as createTrainValidationSplit
};
