clearAndClose(keepIds) {
        this.tensors.forEach((tensor)=>{
            if (keepIds == null || !keepIds.has(tensor.tensor.id)) tensor.tensor.dispose();
        });
        this.tensors = [];
        this.closed_ = true;
        this.idTensor.dispose();
    }
Dispose the tensors and idTensor and mark the TensoryArray as closed.