class_docstr: Base class for different image classification models
class_docstr_tok: ["Base","class","for","different","image","classification","models"]
docstr: Add image classification model-specific arguments
docstr_tok: ["Add","image","classification","model-specific","arguments"]
code: def add_arguments(
      cls, parser: argparse.ArgumentParser
  ) -> argparse.ArgumentParser:
      """Add image classification model-specific arguments"""
      if cls != BaseImageEncoder:
          # Don't re-register arguments in subclasses that don't override `add_arguments()`.
          return parser
      group = parser.add_argument_group(title=cls.__name__)
  
      group.add_argument(
          "--model.classification.classifier-dropout",
          type=float,
          default=0.0,
          help="Dropout rate in classifier",
      )
  
      group.add_argument(
          "--model.classification.name",
          type=str,
          default=None,
          help="Model name",
      )
      group.add_argument(
          "--model.classification.n-classes",
          type=int,
          default=1000,
          help="Number of classes in the dataset",
      )
      group.add_argument(
          "--model.classification.pretrained",
          type=str,
          default=None,
          help="Path of the pretrained backbone",
      )
      group.add_argument(
          "--model.classification.freeze-batch-norm",
          action="store_true",
          help="Freeze batch norm layers",
      )
      group.add_argument(
          "--model.classification.activation.name",
          default=None,
          type=str,
          help="Non-linear function name (e.g., relu)",
      )
      group.add_argument(
          "--model.classification.activation.inplace",
          action="store_true",
          help="Inplace non-linear functions",
      )
      group.add_argument(
          "--model.classification.activation.neg-slope",
          default=0.1,
          type=float,
          help="Negative slope in leaky relu",
      )
  
      group.add_argument(
          "--model.classification.finetune-pretrained-model",
          action="store_true",
          help="Finetune a pretrained model",
      )
      group.add_argument(
          "--model.classification.n-pretrained-classes",
          type=int,
          default=None,
          help="Number of pre-trained classes",
      )
  
      group.add_argument(
          "--model.classification.gradient-checkpointing",
          action="store_true",
          help="Checkpoint output of each spatial level in the classification backbone. Note that"
          "we only take care of checkpointing in {}. If custom forward functions are used, please"
          "implement checkpointing accordingly",
      )
  
      group.add_argument(
          "--model.classification.enable-layer-wise-lr-decay",
          action="store_true",
          default=False,
          help="Enable layer-wise LR.",
      )
      group.add_argument(
          "--model.classification.layer-wise-lr-decay-rate",
          type=float,
          default=1.0,
          help="Layer-wise LR decay range. Each model needs to define how layer-wise LR should be decayed."
          "For ViT, we decay layer_wise_lr_decay_rate ** (n_layers - i), where i is the layer index.",
      )
  
      return parser
  
imports: import argparse
  from typing import Any, Dict, List, Mapping, Optional, Tuple
  import torch
  from torch import Tensor, nn
  from torch.utils.checkpoint import checkpoint
  from common import is_test_env
  from cvnets.layers import LinearLayer
  from cvnets.misc.init_utils import initialize_fc_layer
  from cvnets.models import MODEL_REGISTRY, BaseAnyNNModel
  from cvnets.neural_augmentor import build_neural_augmentor
  from utils import logger
label_desc: Use image node_id 2 for calling the BaseImageEncoder obj's underlying member method code with example usage: obj.add_arguments(cls, parser) and returns: parser, parser