class_docstr: This wrapper handles torch models for image classification.
  
  It can either support models from torchvision.models (resnet18, alexnet, ...) or a
  simple CNN for MNIST (simple-cnn, see SimpleCnn class).
class_docstr_tok: ["This","wrapper","handles","torch","models","for","image","classification",".","It","can","either","support","models","from","torchvision.models","(","resnet18",",","alexnet",",","...",")","or","a","simple","CNN","for","MNIST","(","simple-cnn",",","see","SimpleCnn","class",")","."]
docstr: Create the optimizer based on the config
docstr_tok: ["Create","the","optimizer","based","on","the","config"]
code: def _create_optimizer(self) -> optim.Optimizer:
      """Create the optimizer based on the config"""
      model_params = self.model.parameters()
      optimizer_name = self.config.get("optimizer", "adam")
      logger.info(f"    optimizer: {optimizer_name}")
      if optimizer_name == "adam":
          kwargs = utils.filter_dict(
              self.config,
              ["lr", "betas", "eps", "weight_decay", "amsgrad"],
          )
          logger.info(f"    optimizer args: {kwargs}")
          return optim.Adam(model_params, **kwargs)
      elif optimizer_name == "adadelta":
          kwargs = utils.filter_dict(
              self.config, ["lr", "rho", "eps", "weight_decay"]
          )
          logger.info(f"    optimizer args: {kwargs}")
          return optim.Adadelta(model_params, **kwargs)
      elif optimizer_name == "adagrad":
          kwargs = utils.filter_dict(
              self.config,
              [
                  "lr",
                  "lr_decay",
                  "weight_decay",
                  "initial_accumulator_value",
                  "eps",
              ],
          )
          logger.info(f"    optimizer args: {kwargs}")
          return optim.Adagrad(model_params, **kwargs)
      elif optimizer_name == "rmsprop":
          kwargs = utils.filter_dict(
              self.config,
              [
                  "lr",
                  "alpha",
                  "eps",
                  "weight_decay",
                  "momentum",
                  "centered",
              ],
          )
          logger.info(f"    optimizer args: {kwargs}")
          return optim.RMSprop(model_params, **kwargs)
      elif optimizer_name == "sgd":
          kwargs = utils.filter_dict(
              self.config,
              ["momentum", "dampening", "weight_decay", "nesterov"],
          )
          logger.info(f"    optimizer args: {kwargs}")
          # In contrast to other optimizers, lr is a required param for SGD.
          return optim.SGD(
              model_params, lr=self.config.get("lr", 0.1), **kwargs
          )
      else:
          raise ValueError(f"Optimizer not known: {optimizer_name}")
  
imports: import comet_ml
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torch.utils.data import DataLoader
  import torchvision
  from ignite.engine import Events, create_supervised_trainer, create_supervised_evaluator
  from ignite.metrics import Accuracy, Loss
  import numpy
  from loguru import logger
  from ..model_wrapper import ModelWrapper
  from .None import preprocessing, visualization
  from ..None import utils
label_desc: Use image node_id 2 for calling the TorchImageClassificationWrapper obj's underlying member method code with example usage: obj._create_optimizer() and returns: optim, optim, optim, optim, optim