class_docstr: Estimator implementation for Image Classification.
  
  Parameters
  ----------
  config : dict
      Config in nested dict.
  logger : logging.Logger
      Optional logger for this estimator, can be `None` when default setting is used.
  reporter : callable
      The reporter for metric checkpointing.
  net : mx.gluon.Block
      The custom network. If defined, the model name in config will be ignored so your
      custom network will be used for training rather than pulling it from model zoo.
class_docstr_tok: ["Estimator","implementation","for","Image","Classification",".","Parameters","--","--","--","--","--","config",":","dict","Config","in","nested","dict",".","logger",":","logging.Logger","Optional","logger","for","this","estimator",",","can","be","`","None","`","when","default","setting","is","used",".","reporter",":","callable","The","reporter","for","metric","checkpointing",".","net",":","mx.gluon.Block","The","custom","network",".","If","defined",",","the","model","name","in","config","will","be","ignored","so","your","custom","network","will","be","used","for","training","rather","than","pulling","it","from","model","zoo","."]
code: def _init_network(self, **kwargs):
      load_only = kwargs.get("load_only", False)
      if not self.num_class and self._problem_type != REGRESSION:
          raise ValueError(
              "This is a classification problem and we are not able to create network when `num_class` is unknown. \
                  It should be inferred from dataset or resumed from saved states."
          )
      assert len(self.classes) == self.num_class
      # ctx
      valid_gpus = []
      if self._cfg.gpus:
          valid_gpus = self._validate_gpus(self._cfg.gpus)
          if not valid_gpus:
              self._logger.warning(
                  "No gpu detected, fallback to cpu. You can ignore this warning if this is intended."
              )
          elif len(valid_gpus) != len(self._cfg.gpus):
              self._logger.warning(
                  f"Loaded on gpu({valid_gpus}), different from gpu({self._cfg.gpus})."
              )
      self.ctx = [mx.gpu(int(i)) for i in valid_gpus]
      self.ctx = self.ctx if self.ctx else [mx.cpu()]
  
      # network
      if self._custom_net is None:
          model_name = self._cfg.img_cls.model.lower()
          input_size = self.input_size
          if "inception" in model_name or "googlenet" in model_name:
              self.input_size = 299
          elif "resnest101" in model_name:
              self.input_size = 256
          elif "resnest200" in model_name:
              self.input_size = 320
          elif "resnest269" in model_name:
              self.input_size = 416
          elif "cifar" in model_name:
              self.input_size = 28
      else:
          self._logger.debug(
              "Custom network specified, ignore the model name in config..."
          )
          self.net = copy.deepcopy(self._custom_net)
          model_name = ""
          self.input_size = input_size = self._cfg.train.input_size
  
      if input_size != self.input_size:
          self._logger.info(
              f"Change input size to {self.input_size}, given model type: {model_name}"
          )
  
      use_pretrained = (
          not load_only and self._cfg.img_cls.use_pretrained
      )
      if self._problem_type == REGRESSION:
          self.num_class = 0
      out_channels = max(self.num_class, 1)
      if use_pretrained:
          kwargs = {
              "ctx": self.ctx,
              "pretrained": True,
              "classes": 1000 if "cifar" not in model_name else 10,
          }
      else:
          kwargs = {
              "ctx": self.ctx,
              "pretrained": False,
              "classes": out_channels,
          }
      if self._cfg.img_cls.use_gn:
          kwargs["norm_layer"] = nn.GroupNorm
      if model_name.startswith("vgg"):
          kwargs["batch_norm"] = self._cfg.img_cls.batch_norm
      elif model_name.startswith("resnext"):
          kwargs["use_se"] = self._cfg.img_cls.use_se
  
      if self._cfg.img_cls.last_gamma:
          kwargs["last_gamma"] = True
  
      if model_name:
          self.net = get_model(model_name, **kwargs)
      if model_name and use_pretrained:
          # reset last fully connected layer
          fc_layer_found = False
          for fc_name in ("output", "fc"):
              fc_layer = getattr(self.net, fc_name, None)
              if fc_layer is not None:
                  fc_layer_found = True
                  break
          if fc_layer_found:
              in_channels = list(fc_layer.collect_params().values())[
                  0
              ].shape[1]
              if isinstance(fc_layer, gluon.nn.Dense):
                  new_fc_layer = gluon.nn.Dense(
                      out_channels, in_units=in_channels
                  )
              elif isinstance(fc_layer, gluon.nn.Conv2D):
                  new_fc_layer = gluon.nn.Conv2D(
                      out_channels,
                      in_channels=in_channels,
                      kernel_size=1,
                  )
              elif isinstance(fc_layer, gluon.nn.HybridSequential):
                  new_fc_layer = gluon.nn.HybridSequential(
                      prefix="output_"
                  )
                  with new_fc_layer.name_scope():
                      new_fc_layer.add(
                          gluon.nn.Conv2D(
                              out_channels,
                              in_channels=in_channels,
                              kernel_size=1,
                          )
                      )
                      new_fc_layer.add(gluon.nn.Flatten())
              else:
                  raise TypeError(
                      f"Invalid FC layer type {type(fc_layer)} found, expected (Conv2D, Dense)..."
                  )
              new_fc_layer.initialize(mx.init.MSRAPrelu(), ctx=self.ctx)
              self.net.collect_params().setattr(
                  "lr_mult", self._cfg.train.transfer_lr_mult
              )
              new_fc_layer.collect_params().setattr(
                  "lr_mult", self._cfg.train.output_lr_mult
              )
              self._logger.debug(
                  f"Reduce network lr multiplier to {self._cfg.train.transfer_lr_mult}, while keep "
                  + f"last FC layer lr_mult to {self._cfg.train.output_lr_mult}"
              )
              setattr(self.net, fc_name, new_fc_layer)
          else:
              raise RuntimeError(
                  "Unable to modify the last fc layer in network, (output, fc) expected..."
              )
      else:
          self.net.initialize(mx.init.MSRAPrelu(), ctx=self.ctx)
      self.net.cast(self._cfg.train.dtype)
  
      # teacher model for distillation training
      if (
          not load_only
          and self._cfg.train.teacher is not None
          and self._cfg.train.hard_weight < 1.0
          and self.num_class == 1000
      ):
          teacher_name = self._cfg.train.teacher
          self.teacher = get_model(
              teacher_name,
              pretrained=True,
              classes=self.num_class,
              ctx=self.ctx,
          )
          self.teacher.cast(self._cfg.train.dtype)
          self.teacher.collect_params().reset_ctx(self.ctx)
          self.distillation = True
      else:
          self.distillation = False
      self.net.collect_params().reset_ctx(self.ctx)
  
imports: import time
  import os
  import math
  import copy
  from PIL import Image
  import pandas
  import numpy
  import mxnet
  from mxnet import gluon, nd
  from mxnet.optimizer import Optimizer
  from mxnet import autograd
  from mxnet.gluon.data.vision import transforms
  from ....data.transforms.presets.imagenet import transform_eval
  from ....model_zoo import get_model
  from ....utils import LRSequential, LRScheduler
  from ....None import nn
  from ....None import loss
  from ..base_estimator import BaseEstimator, set_default
  from ..constants import BINARY, MULTICLASS, REGRESSION
  from .utils import get_data_loader, get_data_rec, smooth, mixup_transform
  from .default import ImageClassificationCfg
  from ...data.dataset import ImageClassificationDataset
  from ..conf import _BEST_CHECKPOINT_FILE
  from ..utils import EarlyStopperOnPlateau
label_desc: Use image node_id 5 for calling the ImageClassificationEstimator obj's underlying member method code with example usage: obj._init_network() without return types