def _make_ffcv_encoder(
    dataset, user_encoder_def: "EncoderDef", ffcv_parameters: "FFCVParameters"
) -> Optional["FFCVEncodeDef"]:
    """
    Infer the encoder pipeline from either a user definition,
    the dataset `_ffcv_encoder` 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_encoder_def: An optional user-given encoder definition.
        Can be a dictionary or callable that accepts the ffcv parameters
        and returns the encoder dictionary.
    :param ffcv_parameters: The additional parameters passed
        to the :func:`enable_ffcv` function.
    :return: The encoder pipeline or None if it could not be inferred.
    """
    encoder_def = None

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

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

    # Try to infer the pipeline from the dataset
    if encoder_def is None:
        encoder_def = _encoder_infer_all(dataset, ffcv_parameters)

    return encoder_def

    Infer the encoder pipeline from either a user definition,
    the dataset `_ffcv_encoder` 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_encoder_def: An optional user-given encoder definition.
        Can be a dictionary or callable that accepts the ffcv parameters
        and returns the encoder dictionary.
    :param ffcv_parameters: The additional parameters passed
        to the :func:`enable_ffcv` function.
    :return: The encoder pipeline or None if it could not be inferred.
    
avalanche/benchmarks/utils/ffcv_support/ffcv_support_internals.py