def validate_batch_path(
    paths: Sequence[str | Path] | None,
    batch_size: int | None = None,
) -> list[str] | None:
    """Validate a batch of input paths.

    This function validates and normalizes a sequence of file system paths. It accepts a
    sequence of string paths or ``pathlib.Path`` objects and converts them to a list of
    string paths. Optionally checks if the number of paths matches an expected batch size.

    Args:
        paths (``Sequence[str | Path] | None``): A sequence of paths to validate, or
            ``None``. Each path can be a string or ``pathlib.Path`` object.
        batch_size (``int | None``, optional): The expected number of paths. If specified,
            validates that the number of paths matches this value. Defaults to ``None``,
            in which case no batch size check is performed.

    Returns:
        ``list[str] | None``: A list of validated paths as strings, or ``None`` if the
        input is ``None``.

    Raises:
        TypeError: If ``paths`` is not ``None`` or a sequence of strings/``Path`` objects.
        ValueError: If ``batch_size`` is specified and the number of paths doesn't match.

    Examples:
        Validate a list of paths with batch size check::

            >>> from pathlib import Path
            >>> paths = ["/path/to/file1.png", Path("/path/to/file2.png")]
            >>> validate_batch_path(paths, batch_size=2)
            ['/path/to/file1.png', '/path/to/file2.png']

        Validate without batch size check::

            >>> validate_batch_path(paths)  # Without specifying batch_size
            ['/path/to/file1.png', '/path/to/file2.png']

        Batch size mismatch raises ValueError::

            >>> validate_batch_path(paths, batch_size=3)
            Traceback (most recent call last):
                ...
            ValueError: Number of paths (2) does not match the specified batch size (3).

        Invalid input type raises TypeError::

            >>> validate_batch_path("not_a_sequence")
            Traceback (most recent call last):
                ...
            TypeError: Paths must be None or a sequence of strings or Path objects...
    """
    if paths is None:
        return None
    if not isinstance(paths, Sequence):
        msg = f"Paths must be None or a sequence of strings or Path objects, got {type(paths)}."
        raise TypeError(msg)
    if batch_size is not None and len(paths) != batch_size:
        msg = f"Number of paths ({len(paths)}) does not match the specified batch size ({batch_size})."
        raise ValueError(msg)

    validated_paths: list[str] = []
    for p in paths:
        if not isinstance(p, str | Path):
            msg = f"Each path in the sequence must be a string or Path object, got {type(p)}."
            raise TypeError(msg)
        validated_paths.append(str(p))
    return validated_paths
Validate a batch of input paths.

    This function validates and normalizes a sequence of file system paths. It accepts a
    sequence of string paths or ``pathlib.Path`` objects and converts them to a list of
    string paths. Optionally checks if the number of paths matches an expected batch size.

    Args:
        paths (``Sequence[str | Path] | None``): A sequence of paths to validate, or
            ``None``. Each path can be a string or ``pathlib.Path`` object.
        batch_size (``int | None``, optional): The expected number of paths. If specified,
            validates that the number of paths matches this value. Defaults to ``None``,
            in which case no batch size check is performed.

    Returns:
        ``list[str] | None``: A list of validated paths as strings, or ``None`` if the
        input is ``None``.

    Raises:
        TypeError: If ``paths`` is not ``None`` or a sequence of strings/``Path`` objects.
        ValueError: If ``batch_size`` is specified and the number of paths doesn't match.

    Examples:
        Validate a list of paths with batch size check::

            >>> from pathlib import Path
            >>> paths = ["/path/to/file1.png", Path("/path/to/file2.png")]
            >>> validate_batch_path(paths, batch_size=2)
            ['/path/to/file1.png', '/path/to/file2.png']

        Validate without batch size check::

            >>> validate_batch_path(paths)  # Without specifying batch_size
            ['/path/to/file1.png', '/path/to/file2.png']

        Batch size mismatch raises ValueError::

            >>> validate_batch_path(paths, batch_size=3)
            Traceback (most recent call last):
                ...
            ValueError: Number of paths (2) does not match the specified batch size (3).

        Invalid input type raises TypeError::

            >>> validate_batch_path("not_a_sequence")
            Traceback (most recent call last):
                ...
            TypeError: Paths must be None or a sequence of strings or Path objects...
    
src/anomalib/data/validators/path.py