def __init__(
        self,
        backbone: nn.Module,
        head: nn.Module,
        algorithm_cls: Type[LightningModule],
        ways: int,
        shots: int,
        meta_batch_size: int,
        queries: int = 1,
        num_task: int = -1,
        epoch_length: Optional[int] = None,
        test_epoch_length: Optional[int] = None,
        test_ways: Optional[int] = None,
        test_shots: Optional[int] = None,
        test_queries: Optional[int] = None,
        test_num_task: Optional[int] = None,
        default_transforms_fn: Optional[Callable] = None,
        seed: int = 42,
        **algorithm_kwargs,
    ):
        """The ``Learn2LearnAdapter`` is an :class:`~flash.core.adapter.Adapter` for integrating with `learn 2 learn`
        library (https://github.com/learnables/learn2learn).

        Args:
            task: Task to be used. This adapter should work with any Flash Classification task
            backbone: Feature extractor to be used.
            head: Predictive head.
            algorithm_cls: Algorithm class coming
                from: https://github.com/learnables/learn2learn/tree/master/learn2learn/algorithms/lightning
            ways: Number of classes conserved for generating the task.
            shots: Number of samples used for adaptation.
            meta_batch_size: Number of task to be sampled and optimized over before doing a meta optimizer step.
            queries: Number of samples used for computing the meta loss after the adaption on the `shots` samples.
            num_task: Total number of tasks to be sampled during training. If -1, a new task will always be sampled.
            epoch_length: Total number of tasks to be sampled to make an epoch.
            test_ways: Number of classes conserved for generating the validation and testing task.
            test_shots: Number of samples used for adaptation during validation and testing phase.
            test_queries: Number of samples used for computing the meta loss during validation or testing
                after the adaption on `shots` samples.
            epoch_length: Total number of tasks to be sampled to make an epoch during validation and testing phase.
            default_transforms_fn: A Callable to create the task transform.
                The callable should take the dataset, ways and shots as arguments.
            algorithm_kwargs: Keyword arguments to be provided to the algorithm class from learn2learn
        """

        super().__init__()

        self.backbone = backbone
        self.head = head
        self.algorithm_cls = algorithm_cls
        self.meta_batch_size = meta_batch_size

        self.num_task = num_task
        self.default_transforms_fn = default_transforms_fn
        self.seed = seed
        self.epoch_length = epoch_length or meta_batch_size

        self.ways = ways
        self.shots = shots
        self.queries = queries

        self.test_ways = test_ways or ways
        self.test_shots = test_shots or shots
        self.test_queries = test_queries or queries
        self.test_num_task = test_num_task or num_task
        self.test_epoch_length = test_epoch_length or self.epoch_length

        params = inspect.signature(self.algorithm_cls).parameters

        algorithm_kwargs["train_ways"] = ways
        algorithm_kwargs["train_shots"] = shots
        algorithm_kwargs["train_queries"] = queries

        algorithm_kwargs["test_ways"] = self.test_ways
        algorithm_kwargs["test_shots"] = self.test_shots
        algorithm_kwargs["test_queries"] = self.test_queries

        if "model" in params:
            algorithm_kwargs["model"] = Model(backbone=backbone, head=head)

        if "features" in params:
            algorithm_kwargs["features"] = Model(backbone=backbone, head=None)

        if "classifier" in params:
            algorithm_kwargs["classifier"] = head

        self.model = self.algorithm_cls(**algorithm_kwargs)

        # Patch log to avoid error with learn2learn and PL 1.5
        self.model.log = functools.partial(self._patch_log, self.model.log)

        # this algorithm requires a special treatment
        self._algorithm_has_validated = self.algorithm_cls != l2l.algorithms.LightningPrototypicalNetworks
The ``Learn2LearnAdapter`` is an :class:`~flash.core.adapter.Adapter` for integrating with `learn 2 learn`
        library (https://github.com/learnables/learn2learn).

        Args:
            task: Task to be used. This adapter should work with any Flash Classification task
            backbone: Feature extractor to be used.
            head: Predictive head.
            algorithm_cls: Algorithm class coming
                from: https://github.com/learnables/learn2learn/tree/master/learn2learn/algorithms/lightning
            ways: Number of classes conserved for generating the task.
            shots: Number of samples used for adaptation.
            meta_batch_size: Number of task to be sampled and optimized over before doing a meta optimizer step.
            queries: Number of samples used for computing the meta loss after the adaption on the `shots` samples.
            num_task: Total number of tasks to be sampled during training. If -1, a new task will always be sampled.
            epoch_length: Total number of tasks to be sampled to make an epoch.
            test_ways: Number of classes conserved for generating the validation and testing task.
            test_shots: Number of samples used for adaptation during validation and testing phase.
            test_queries: Number of samples used for computing the meta loss during validation or testing
                after the adaption on `shots` samples.
            epoch_length: Total number of tasks to be sampled to make an epoch during validation and testing phase.
            default_transforms_fn: A Callable to create the task transform.
                The callable should take the dataset, ways and shots as arguments.
            algorithm_kwargs: Keyword arguments to be provided to the algorithm class from learn2learn
        
src/flash/image/classification/adapters.py