async fitModel(numEpochs, examplesPerEpoch, batchSize, validationSplit) {
    let batchCount = 0;
    const batchesPerEpoch = examplesPerEpoch / batchSize;
    const totalBatches = numEpochs * batchesPerEpoch;
    let t = new Date().getTime();

    onTrainBegin();
    const callbacks = {
      onBatchEnd: async (batch, logs) => {
        // Calculate the training speed in the current batch, in # of
        // examples per second.
        const t1 = new Date().getTime();
        const examplesPerSec = batchSize / ((t1 - t) / 1e3);
        t = t1;
        onTrainBatchEnd(logs, ++batchCount / totalBatches, examplesPerSec);
      },
      onEpochEnd: async (epoch, logs) => {
        onTrainEpochEnd(logs);
      }
    };

    await model.fitModel(
        this.model, this.textData_, numEpochs, examplesPerEpoch, batchSize,
        validationSplit, callbacks);
  }
Train the LSTM model.

@param {number} numEpochs Number of epochs to train the model for.
@param {number} examplesPerEpoch Number of epochs to use in each training
  epochs.
@param {number} batchSize Batch size to use during training.
@param {number} validationSplit Validation split to be used during the
  training epochs.