class_docstr: Base class to train the different models in kornia.
  
  .. warning::
      The API is experimental and subject to be modified based on the needs of kornia models.
  
  Args:
      model: the nn.Module to be optimized.
      train_dataloader: the data loader used in the training loop.
      valid_dataloader: the data loader used in the validation loop.
      criterion: the nn.Module with the function that computes the loss.
      optimizer: the torch optimizer object to be used during the optimization.
      scheduler: the torch scheduler object with defiing the scheduling strategy.
      accelerator: the Accelerator object to distribute the training.
      config: a TrainerConfiguration structure containing the experiment hyper parameters.
      callbacks: a dictionary containing the pointers to the functions to overrides. The
        main supported hooks are ``evaluate``, ``preprocess``, ``augmentations`` and ``fit``.
  
  .. important::
      The API heavily relies on `accelerate <https://github.com/huggingface/accelerate/>`_.
      In order to use it, you must: ``pip install kornia[x]``
  
  .. seealso::
      Learn how to use the API in our documentation
      `here <https://kornia.readthedocs.io/en/latest/get-started/training.html>`_.
code: def __init__(
      self,
      model: Module,
      train_dataloader: DataLoader[Any],
      valid_dataloader: DataLoader[Any],
      criterion: Optional[Module],
      optimizer: Optimizer,
      scheduler: lr_scheduler._LRScheduler,
      config: Configuration,
      callbacks: Dict[str, Callable[..., None]] = {},
  ) -> None:
      # setup the accelerator
      if Accelerator is None:
          raise ModuleNotFoundError(
              'accelerate library is not installed: pip install "kornia[x]"'
          )
      self.accelerator = Accelerator()
  
      # setup the data related objects
      self.model = self.accelerator.prepare(model)
      self.train_dataloader = self.accelerator.prepare(train_dataloader)
      self.valid_dataloader = self.accelerator.prepare(valid_dataloader)
      self.criterion = (
          None if criterion is None else criterion.to(self.device)
      )
      self.optimizer = self.accelerator.prepare(optimizer)
      self.scheduler = scheduler
      self.config = config
  
      # configure callbacks
      for fn_name, fn in callbacks.items():
          if fn_name not in callbacks_whitelist:
              raise ValueError(f"Not supported: {fn_name}.")
          setattr(Trainer, fn_name, fn)
  
      # hyper-params
      self.num_epochs = config.num_epochs
  
      self.state = TrainerState.STARTING
  
      self._logger = logging.getLogger("train")
  
imports: import logging
  from typing import Any, Callable, Dict, Optional
  import torch
  from torch.optim import Optimizer, lr_scheduler
  from torch.utils.data import DataLoader
  from kornia.core import Module, Tensor
  from kornia.metrics import AverageMeter
  from .utils import Configuration, StatsTracker, TrainerState
label_desc: Use image node_id 1 to create a new Trainer object  with example: obj = Trainer(model, train_dataloader, valid_dataloader, criterion, optimizer, scheduler, config, callbacks)