def flat_transforms_recursive(transforms: Union[List, Any], position: int) -> List[Any]:
    """
    Flattens a list of transformations.

    :param transforms: The list of transformations to flatten.
    :param position: The position of the transformed element.
    :return: A flat list of transformations.
    """
    if not isinstance(transforms, Iterable):
        transforms = [transforms]

    must_flat = True
    while must_flat:
        must_flat = False
        flattened_list = []

        for transform in transforms:
            flat_strat = getattr(transform, "flat_transforms", None)
            if callable(flat_strat):
                flattened_list.extend(flat_strat(position))
                must_flat = True
            elif isinstance(transform, Compose):
                flattened_list.extend(transform.transforms)
                must_flat = True
            elif isinstance(transform, Sequence):
                flattened_list.extend(transform)
                must_flat = True
            elif transform is None:
                pass
            else:
                flattened_list.append(transform)

        transforms = flattened_list

    return transforms

    Flattens a list of transformations.

    :param transforms: The list of transformations to flatten.
    :param position: The position of the transformed element.
    :return: A flat list of transformations.
    
avalanche/benchmarks/utils/transforms.py