def to_tuple(input_size: int | ListConfig) -> tuple[int, int]:
    """Convert input size to a tuple of (height, width).

    This function takes either a single integer or a sequence of two integers and
    converts it to a tuple representing image dimensions (height, width). If a single
    integer is provided, it is used for both dimensions.

    Args:
        input_size: Input size specification. Can be either:
            - A single ``int`` that will be used for both height and width
            - A ``ListConfig`` or sequence containing exactly 2 integers for height
              and width

    Returns:
        tuple[int, int]: A tuple of ``(height, width)`` dimensions

    Examples:
        Create a square tuple from single integer:

        >>> to_tuple(256)
        (256, 256)

        Create a tuple from list of dimensions:

        >>> to_tuple([256, 256])
        (256, 256)

    Raises:
        ValueError: If ``input_size`` is a sequence without exactly 2 elements
        TypeError: If ``input_size`` is neither an integer nor a sequence of
            integers

    Note:
        When using a sequence input, the first value is interpreted as height and
        the second as width.
    """
    ret_val: tuple[int, int]
    if isinstance(input_size, int):
        ret_val = cast(tuple[int, int], (input_size,) * 2)
    elif isinstance(input_size, ListConfig | Sequence):
        if len(input_size) != 2:
            msg = "Expected a single integer or tuple of length 2 for width and height."
            raise ValueError(msg)

        ret_val = cast(tuple[int, int], tuple(input_size))
    else:
        msg = f"Expected either int or ListConfig, got {type(input_size)}"
        raise TypeError(msg)
    return ret_val
Convert input size to a tuple of (height, width).

    This function takes either a single integer or a sequence of two integers and
    converts it to a tuple representing image dimensions (height, width). If a single
    integer is provided, it is used for both dimensions.

    Args:
        input_size: Input size specification. Can be either:
            - A single ``int`` that will be used for both height and width
            - A ``ListConfig`` or sequence containing exactly 2 integers for height
              and width

    Returns:
        tuple[int, int]: A tuple of ``(height, width)`` dimensions

    Examples:
        Create a square tuple from single integer:

        >>> to_tuple(256)
        (256, 256)

        Create a tuple from list of dimensions:

        >>> to_tuple([256, 256])
        (256, 256)

    Raises:
        ValueError: If ``input_size`` is a sequence without exactly 2 elements
        TypeError: If ``input_size`` is neither an integer nor a sequence of
            integers

    Note:
        When using a sequence input, the first value is interpreted as height and
        the second as width.
    
src/anomalib/utils/config.py