function stack(tensors, dim = 0) {
    // TODO do validation of shapes
    // NOTE: stack expects each tensor to be equal size
    return cat(tensors.map(t => t.unsqueeze(dim)), dim);
}
Stack an array of tensors along a specified dimension.
@param {Tensor[]} tensors The array of tensors to stack.
@param {number} dim The dimension to stack along.
@returns {Tensor} The stacked tensor.