def _make_ffcv_decoder(
    dataset,
    user_decoder_def: "DecoderDef",
    ffcv_parameters: "FFCVParameters",
    encoder_dictionary: Optional["FFCVEncodeDef"],
) -> Optional["FFCVDecodeDef"]:
    """
    Infer the decoder pipeline from either a user definition,
    the dataset `_ffcv_decoder` field, of from the examples format.

    :param dataset: The dataset to use. Must have at least
        one example to attempt an inference for data format.
    :param user_decoder_def: An optional user-given decoder definition.
        Can be a dictionary or callable that accepts the ffcv parameters
        and returns the decoder dictionary.
    :param ffcv_parameters: The additional parameters passed
        to the :func:`enable_ffcv` function.
    :param encoder_dictionary: If not None, will be used to infer
        the decoders.
    :return: The decoder pipeline or None if it could not be inferred.
    """
    decode_def = None

    # Use the user-provided pipeline / pipeline factory
    if user_decoder_def is not None:
        decode_def = user_decoder_def
        if callable(decode_def):
            decode_def = decode_def(ffcv_parameters)

    # Check if the dataset has an explicit field/method
    if decode_def is None:
        decode_def = _check_dataset_ffcv_decoder(dataset)
        if callable(decode_def):
            decode_def = decode_def(ffcv_parameters)

    # Try to infer the pipeline from the dataset
    if decode_def is None:
        decode_def = _decoder_infer_all(
            dataset, ffcv_parameters, encoder_dictionary=encoder_dictionary
        )

    return decode_def

    Infer the decoder pipeline from either a user definition,
    the dataset `_ffcv_decoder` field, of from the examples format.

    :param dataset: The dataset to use. Must have at least
        one example to attempt an inference for data format.
    :param user_decoder_def: An optional user-given decoder definition.
        Can be a dictionary or callable that accepts the ffcv parameters
        and returns the decoder dictionary.
    :param ffcv_parameters: The additional parameters passed
        to the :func:`enable_ffcv` function.
    :param encoder_dictionary: If not None, will be used to infer
        the decoders.
    :return: The decoder pipeline or None if it could not be inferred.
    
avalanche/benchmarks/utils/ffcv_support/ffcv_support_internals.py