async function csvToTensors(data, labels, use, batchSize) {
  // Only keep the queries for the intents we are interested in.
  const filtered = data.filter(d => labels.indexOf(d.intent) >= 0);
  console.log(`Converting ${filtered.length} queries to tensors.`);

  // Shuffle the data before we tensorify it and write it out.
  tf.util.shuffle(filtered);

  const xs = filtered.map(d => d.query);
  const ys = filtered.map(d => labels.indexOf(d.intent));

  const xsBatches = chunk(xs, batchSize);
  const ysBatches = chunk(ys, batchSize);

  tf.util.assert(
      xsBatches.length === ysBatches.length,
      () => 'batched xs and ys do not have the same length');

  const xsBatchedTensors = [];
  const ysBatchedTensors = [];

  for (let i = 0; i < xsBatches.length; i++) {
    console.time(
        `Converted batch ${i} of ${xsBatches.length} (${batchSize}): `);

    const queries = xsBatches[i];
    const batchLabels = ysBatches[i];

    // Convert the labels to one-hot representation
    // And embed the query with the universal sentence encoder
    const oneHot = tf.oneHot(batchLabels, labels.length);
    const embedding = await use.embed(queries);

    xsBatchedTensors.push(embedding);
    ysBatchedTensors.push(oneHot);

    console.timeEnd(
        `Converted batch ${i} of ${xsBatches.length} (${batchSize}): `);
  }

  const xsTensor = tf.concat(xsBatchedTensors);
  const ysTensor = tf.concat(ysBatchedTensors);

  tf.dispose([xsBatchedTensors, ysBatchedTensors]);

  return {
    xs: xsTensor,
    ys: ysTensor,
  };
}
Takes a CSV file of queries and intents and embeds all the queries using the
universal sentence encoder and one-hot-encodes the queries.
The output of this script will be an JSON file with the following format

 {
   xs: number[][], // Array of tensor-like objects for queries
   ys: number[][], // Array of tensor-like objects for intents (labels)
 }

The script will also output a `metadata.json` file with the following format:

 {
   labels: string[], array of strings to invert one-hot encodings
   xsShape: [number, number], tensor shape of xs
   ysShape: [number, number], tensor shape of ys
 }