write(index, tensor) {
        if (this.closed_) throw new Error(`TensorArray ${this.name} has already been closed.`);
        if (index < 0 || !this.dynamicSize && index >= this.maxSize) throw new Error(`Tried to write to index ${index}, but array is not resizeable and size is: ${this.maxSize}`);
        const t = this.tensors[index] || {};
        if (tensor.dtype !== this.dtype) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index},
          because the value dtype is ${tensor.dtype}, but TensorArray dtype is ${this.dtype}.`);
        // Set the shape for the first time write to unknow shape tensor array
        if (this.size() === 0 && (this.elementShape == null || this.elementShape.length === 0)) this.elementShape = tensor.shape;
        (0, _tensorUtils.assertShapesMatchAllowUndefinedSize)(this.elementShape, tensor.shape, `TensorArray ${this.name}: Could not write to TensorArray index ${index}.`);
        if (t.read) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index}, because it has already been read.`);
        if (t.written) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index}, because it has already been written.`);
        t.tensor = tensor;
        (0, _tfjsCore.keep)(tensor);
        t.written = true;
        this.tensors[index] = t;
    }
Write value into the index of the TensorArray.
@param index number the index to write to.
@param tensor