def _check_input(
    series: Union[TimeSeries, Sequence[TimeSeries]],
    name: str,
    width_expected: Optional[int] = None,
    check_deterministic: bool = False,
    check_binary: bool = False,
    check_multivariate: bool = False,
    num_series_expected: Optional[int] = None,
    extra_checks: Optional[Callable] = None,
):
    """
    Input `series` checks used for Aggregators, Detectors, ...

    - `series` must be (sequence of) series with length (`num_series_expected`) where each series must:
        - have width `width_expected` if it is not `None`
        - be deterministic if `check_deterministic=True`
        - be binary if `check_binary=True`
        - be multivariate if `check_multivariate=True`

    By default, all checks except the `TimeSeries` check are disabled.

    Parameters
    ----------
    series
        A (sequence of) multivariate series.
    name
        The name of the series.
    width_expected
        Optionally, the expected number of components/width of each series.
    check_multivariate
        Whether to check if all series are multivariate.
    """
    series = series2seq(series)
    if num_series_expected is not None and len(series) != num_series_expected:
        if num_series_expected == 1:
            err_txt = f"`{name}` must be single `TimeSeries` or a sequence of `TimeSeries` of length `1`."
        else:
            err_txt = f"`{name}` must be a sequence of `TimeSeries` of length `{num_series_expected}`."
        raise_log(
            ValueError(err_txt),
            logger=logger,
        )
    for s in series:
        if not isinstance(s, TimeSeries):
            raise_log(
                ValueError(f"all series in `{name}` must be of type `TimeSeries`."),
                logger=logger,
            )
        if check_deterministic and not s.is_deterministic:
            raise_log(
                ValueError(
                    f"all series in `{name}` must be deterministic (number of samples=1)."
                ),
                logger=logger,
            )
        if check_binary:
            _assert_binary(s, name=name)
        if check_multivariate and s.width <= 1:
            raise_log(
                ValueError(f"all series in `{name}` must be multivariate (width>1)."),
                logger=logger,
            )
        if width_expected is not None and s.width != width_expected:
            raise_log(
                ValueError(
                    f"all series in `{name}` must have `{width_expected}` component(s) (width={width_expected})."
                ),
                logger=logger,
            )
        if extra_checks is not None:
            extra_checks(s)
    return series

    Input `series` checks used for Aggregators, Detectors, ...

    - `series` must be (sequence of) series with length (`num_series_expected`) where each series must:
        - have width `width_expected` if it is not `None`
        - be deterministic if `check_deterministic=True`
        - be binary if `check_binary=True`
        - be multivariate if `check_multivariate=True`

    By default, all checks except the `TimeSeries` check are disabled.

    Parameters
    ----------
    series
        A (sequence of) multivariate series.
    name
        The name of the series.
    width_expected
        Optionally, the expected number of components/width of each series.
    check_multivariate
        Whether to check if all series are multivariate.
    
darts/ad/utils.py