def _prepare_shape_for_squeeze(shape, axes):
    """
    Creates the squeezed new shape based on the tensor and given axes.

    Args:
        shape (tuple): the shape of the tensor
        axes Union[None, int, tuple(int), list(int)]: the axes with dimensions squeezed.

    Returns:
        new_shape(tuple): the shape with dimensions squeezed.
    """
    new_shape = []
    ndim = len(shape)

    # Convert to set
    if isinstance(axes, int):
        if axes >= ndim or axes < -ndim:
            raise ValueError(
                f"axis {axes} is out of bounds for tensor of dimension {ndim}")
        axes = {axes}

    elif isinstance(axes, (list, tuple)):
        for axis in axes:
            if axis >= ndim or axis < -ndim:
                raise ValueError(
                    f"axis {axis} is out of bounds for tensor of dimension {ndim}")
        axes = set(axes)

    elif axes is not None:
        raise TypeError(
            f"only int, tuple and list are allowed for axes, but got {type(axes)}")

    if axes is None:
        new_shape = [s for s in shape if s != 1]
    else:
        for idx, s in enumerate(shape):
            if s != 1 or (idx not in axes) and (idx - ndim not in axes):
                new_shape.append(s)
            # if an axis is selected with shape entry greater than one, an error is raised.
            if s != 1 and ((idx in axes) or (idx - ndim in axes)):
                raise ValueError(
                    f"axis {axes} has shape entry {s} > 1, cannot be squeezed.")
    return tuple(new_shape)