def _ffcv_infer_encoder(value, ffcv_parameters: "FFCVParameters") -> Optional["Field"]:
    """
    Infers the field encoder 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.
    :return: A :class:`Field` instance or None if it cannot be
        inferred.
    """
    from ffcv.fields import (
        IntField,
        FloatField,
        NDArrayField,
        TorchTensorField,
    )

    if isinstance(value, int):
        return IntField()

    if isinstance(value, float):
        return FloatField()

    if isinstance(value, np.ndarray):
        return NDArrayField(value.dtype, shape=value.shape)

    if isinstance(value, Tensor):
        return TorchTensorField(value.dtype, shape=value.shape)

    if isinstance(value, Image):
        return _image_encoder(ffcv_parameters)

    return None

    Infers the field encoder 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.
    :return: A :class:`Field` instance or None if it cannot be
        inferred.
    
avalanche/benchmarks/utils/ffcv_support/ffcv_support_internals.py