function calc_unsqueeze_dims(dims, dim) {
    // Dimension out of range (e.g., "expected to be in range of [-4, 3], but got 4")
    // + 1 since we allow inserting at the end (i.e. dim = -1)
    dim = safeIndex(dim, dims.length + 1);
    dims = dims.slice();
    // Insert 1 into specified dimension
    dims.splice(dim, 0, 1);
    return dims;
}
Helper function to calculate new dimensions when performing an unsqueeze operation.
@param {number[]} dims The dimensions of the tensor.
@param {number} dim The dimension to unsqueeze.
@returns {number[]} The new dimensions.
@private