def _normalize_sequence(array, value, fname):
    """
    values = _normalize_sequence(array, value, fname)
    If `value` is a sequence, checks that it has an element for each dimension
    of `array`. Otherwise, returns a sequence that repeats `value` once for
    each dimension of array.
    Parameters
    ----------
    array : Tensor
    value : sequence or scalar
    fname : str
        Function name. Used in error messages
    Returns
    -------
    values : sequence
    """
    try:
        value = list(value)
    except TypeError:
        return [value for s in array.shape]

    if len(value) != array.ndim:
        raise ValueError(
            f"caer.{fname}: argument is sequence, but has wrong size ({len(value)} "
            f"for an array of {array.ndim} dimensions)"
        )
    return value