class_docstr: Evaluator that is used for classification.
  
  Available callback metrics in :class:`Classification` are:
  
  - train_loss
  - train_acc
  - val_loss
  - val_acc
  
  Parameters
  ----------
  criterion : nn.Module
      Class for criterion module (not an instance). default: ``nn.CrossEntropyLoss``
  learning_rate : float
      Learning rate. default: 0.001
  weight_decay : float
      L2 weight decay. default: 0
  optimizer : Optimizer
      Class for optimizer (not an instance). default: ``Adam``
  train_dataloaders : DataLoader
      Used in ``trainer.fit()``. A PyTorch DataLoader with training samples.
      If the ``lightning_module`` has a predefined train_dataloader method this will be skipped.
  val_dataloaders : DataLoader or List of DataLoader
      Used in ``trainer.fit()``. Either a single PyTorch Dataloader or a list of them, specifying validation samples.
      If the ``lightning_module`` has a predefined val_dataloaders method this will be skipped.
  datamodule
      Used in ``trainer.fit()``. See `Lightning DataModule <https://pytorch-lightning.readthedocs.io/en/stable/data/datamodule.html>`__.
  export_onnx : bool
      If true, model will be exported to ``model.onnx`` before training starts. default true
  num_classes : int
      Number of classes for classification task.
      Required for torchmetrics >= 0.11.0. default: None
  trainer_kwargs : dict
      Optional keyword arguments passed to trainer. See
      `Lightning documentation <https://pytorch-lightning.readthedocs.io/en/stable/common/trainer.html>`__ for details.
  
  Examples
  --------
  >>> evaluator = Classification()
  
  To use customized criterion and optimizer:
  
  >>> evaluator = Classification(nn.LabelSmoothingCrossEntropy, optimizer=torch.optim.SGD)
  
  Extra keyword arguments will be passed to trainer, some of which might be necessary to enable GPU acceleration:
  
  >>> evaluator = Classification(accelerator='gpu', devices=2, strategy='ddp')
class_docstr_tok: ["Evaluator","that","is","used","for","classification",".","Available","callback","metrics","in",":","class",":","`","Classification","`","are",":","-","train_loss","-","train_acc","-","val_loss","-","val_acc","Parameters","--","--","--","--","--","criterion",":","nn.Module","Class","for","criterion","module","(","not","an","instance",")",".","default",":","``","nn.CrossEntropyLoss","``","learning_rate",":","float","Learning","rate",".","default",":","0.001","weight_decay",":","float","L2","weight","decay",".","default",":","0","optimizer",":","Optimizer","Class","for","optimizer","(","not","an","instance",")",".","default",":","``","Adam","``","train_dataloaders",":","DataLoader","Used","in","``","trainer.fit","(",")","``",".","A","PyTorch","DataLoader","with","training","samples",".","If","the","``","lightning_module","``","has","a","predefined","train_dataloader","method","this","will","be","skipped",".","val_dataloaders",":","DataLoader","or","List","of","DataLoader","Used","in","``","trainer.fit","(",")","``",".","Either","a","single","PyTorch","Dataloader","or","a","list","of","them",",","specifying","validation","samples",".","If","the","``","lightning_module","``","has","a","predefined","val_dataloaders","method","this","will","be","skipped",".","datamodule","Used","in","``","trainer.fit","(",")","``",".","See","`","Lightning","DataModule","<","https",":","\/\/pytorch-lightning.readthedocs.io\/en\/stable\/data\/datamodule.html",">","`","__",".","export_onnx",":","bool","If","true",",","model","will","be","exported","to","``","model.onnx","``","before","training","starts",".","default","true","num_classes",":","int","Number","of","classes","for","classification","task",".","Required","for","torchmetrics",">","=","0.11.0.","default",":","None","trainer_kwargs",":","dict","Optional","keyword","arguments","passed","to","trainer",".","See","`","Lightning","documentation","<","https",":","\/\/pytorch-lightning.readthedocs.io\/en\/stable\/common\/trainer.html",">","`","__","for","details",".","Examples","--","--","--","--",">",">",">","evaluator","=","Classification","(",")","To","use","customized","criterion","and","optimizer",":",">",">",">","evaluator","=","Classification","(","nn.LabelSmoothingCrossEntropy",",","optimizer=torch.optim.SGD",")","Extra","keyword","arguments","will","be","passed","to","trainer",",","some","of","which","might","be","necessary","to","enable","GPU","acceleration",":",">",">",">","evaluator","=","Classification","(","accelerator='gpu","'",",","devices=2",",","strategy='ddp","'",")"]
code: def __init__(
      self,
      criterion: Type[nn.Module] = nn.CrossEntropyLoss,
      learning_rate: float = 0.001,
      weight_decay: float = 0.0,
      optimizer: Type[optim.Optimizer] = optim.Adam,
      train_dataloaders: Optional[DataLoader] = None,
      val_dataloaders: Union[DataLoader, List[DataLoader], None] = None,
      datamodule: Optional[pl.LightningDataModule] = None,
      export_onnx: bool = False,
      train_dataloader: Optional[DataLoader] = None,
      num_classes: Optional[int] = None,
      **trainer_kwargs,
  ):
      if train_dataloader is not None:
          warnings.warn(
              "`train_dataloader` is deprecated and replaced with `train_dataloaders`.",
              DeprecationWarning,
          )
          train_dataloaders = train_dataloader
      module = ClassificationModule(
          criterion=criterion,
          learning_rate=learning_rate,
          weight_decay=weight_decay,
          optimizer=optimizer,
          export_onnx=export_onnx,
          num_classes=num_classes,
      )
      super().__init__(
          module,
          Trainer(**trainer_kwargs),
          train_dataloaders=train_dataloaders,
          val_dataloaders=val_dataloaders,
          datamodule=datamodule,
      )
  
imports: import logging
  import os
  import warnings
  from pathlib import Path
  from typing import Any, Dict, Union, Optional, List, Type
  import pytorch_lightning
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import torchmetrics
  import torchmetrics.classification
  import torch.utils.data
  import nni
  from nni.common.serializer import is_traceable
  from nni.nas.evaluator import MutableEvaluator
label_desc: Use image node_id 1 to create a new Classification object from inherited base classes: Lightning with example: obj = Classification(criterion, learning_rate, weight_decay, optimizer, train_dataloaders, val_dataloaders, datamodule, export_onnx, train_dataloader, num_classes)