def _ffcv_infer_decoder(
    value,
    ffcv_parameters: "FFCVParameters",
    encoder: Optional["Field"] = None,
    add_common_collate: bool = True,
) -> Optional[List["Operation"]]:
    """
    Infers the field decoder definition from a given example.

    :param value: The example obtained from the dataset.
    :param ffcv_parameters: The additional parameters passed
        to the :func:`enable_ffcv` function.
    :param encoder: If not None, will try to infer the decoder
        definition from the field.
    :param add_common_collate: If True, will apply a PyTorch-alike
        collate to int and float fields so that they end up being
        a flat PyTorch tensor instead of a list of int/float.
    :return: The decoder pipeline as a list of :class:`Operation`
        or None if the decoder pipeline cannot be inferred.
    """
    from ffcv.transforms import ToTensor, Squeeze

    if encoder is not None:
        if isinstance(encoder, TorchTensorField):
            return [NDArrayDecoder(), ToTensor()]

        encoder_class = encoder.get_decoder_class()
        pipeline: List["Operation"] = [encoder_class()]
        if add_common_collate and encoder_class in [IntDecoder, FloatDecoder]:
            pipeline.extend((ToTensor(), Squeeze()))
        return pipeline

    if isinstance(value, int):
        pipeline: List["Operation"] = [IntDecoder()]

        if add_common_collate:
            pipeline.extend((ToTensor(), Squeeze()))
        return pipeline

    if isinstance(value, float):
        pipeline: List["Operation"] = [FloatDecoder()]

        if add_common_collate:
            pipeline.extend((ToTensor(), Squeeze()))
        return pipeline

    if isinstance(value, np.ndarray):
        return [NDArrayDecoder()]

    if isinstance(value, Tensor):
        return [NDArrayDecoder(), ToTensor()]

    if isinstance(value, Image):
        return [SimpleRGBImageDecoder()]

    return None

    Infers the field decoder definition from a given example.

    :param value: The example obtained from the dataset.
    :param ffcv_parameters: The additional parameters passed
        to the :func:`enable_ffcv` function.
    :param encoder: If not None, will try to infer the decoder
        definition from the field.
    :param add_common_collate: If True, will apply a PyTorch-alike
        collate to int and float fields so that they end up being
        a flat PyTorch tensor instead of a list of int/float.
    :return: The decoder pipeline as a list of :class:`Operation`
        or None if the decoder pipeline cannot be inferred.
    
avalanche/benchmarks/utils/ffcv_support/ffcv_support_internals.py