def expand_dims(
    a: ndarray, axis: int | tuple[int, ...] | list[int]
) -> ndarray:
    """
    Expand the shape of an array.

    Insert a new axis that will appear at the `axis` position in the expanded
    array shape.

    Parameters
    ----------
    a : array_like
        Input array.
    axis : int or tuple of ints
        Position in the expanded axes where the new axis (or axes) is placed.

    Returns
    -------
    result : ndarray
        View of `a` with the number of dimensions increased.

    See Also
    --------
    squeeze : The inverse operation, removing singleton dimensions
    reshape : Insert, remove, and combine dimensions, and resize existing ones
    atleast_1d, atleast_2d, atleast_3d

    Availability
    --------
    Multiple GPUs, Multiple CPUs
    """

    if isinstance(axis, int):
        axis = (axis,)

    out_ndim = len(axis) + a.ndim
    normalized_axis = normalize_axis_tuple(axis, out_ndim)

    shape_it = iter(a.shape)
    shape = [
        1 if ax in normalized_axis else next(shape_it)
        for ax in range(out_ndim)
    ]

    return a.reshape(shape)

    Expand the shape of an array.

    Insert a new axis that will appear at the `axis` position in the expanded
    array shape.

    Parameters
    ----------
    a : array_like
        Input array.
    axis : int or tuple of ints
        Position in the expanded axes where the new axis (or axes) is placed.

    Returns
    -------
    result : ndarray
        View of `a` with the number of dimensions increased.

    See Also
    --------
    squeeze : The inverse operation, removing singleton dimensions
    reshape : Insert, remove, and combine dimensions, and resize existing ones
    atleast_1d, atleast_2d, atleast_3d

    Availability
    --------
    Multiple GPUs, Multiple CPUs
    
cupynumeric/_module/array_dimension.py