class_docstr: Estimator implementation for SSD.
  
  Parameters
  ----------
  config : dict
      Config in nested dict.
  logger : logging.Logger, default is None
      Optional logger for this estimator, can be `None` when default setting is used.
  reporter : callable, default is None
      If set, use reporter callback to report the metrics of the current estimator.
  
  Attributes
  ----------
  _logger : logging.Logger
      The customized/default logger for this estimator.
  _logdir : str
      The temporary dir for logs.
  _cfg : autocfg.dataclass
      The configurations.
class_docstr_tok: ["Estimator","implementation","for","SSD",".","Parameters","--","--","--","--","--","config",":","dict","Config","in","nested","dict",".","logger",":","logging.Logger",",","default","is","None","Optional","logger","for","this","estimator",",","can","be","`","None","`","when","default","setting","is","used",".","reporter",":","callable",",","default","is","None","If","set",",","use","reporter","callback","to","report","the","metrics","of","the","current","estimator",".","Attributes","--","--","--","--","--","_logger",":","logging.Logger","The","customized\/default","logger","for","this","estimator",".","_logdir",":","str","The","temporary","dir","for","logs",".","_cfg",":","autocfg.dataclass","The","configurations","."]
code: def _init_network(self, **kwargs):
      load_only = kwargs.get("load_only", False)
      if not self.num_class:
          raise ValueError(
              "Unable 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
  
      # training contexts
      if self._cfg.horovod:
          self.ctx = [mx.gpu(hvd.local_rank())]
      else:
          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})."
                  )
          ctx = [mx.gpu(int(i)) for i in valid_gpus]
          self.ctx = ctx if ctx else [mx.cpu()]
  
      if self._cfg.ssd.transfer is not None:
          assert isinstance(self._cfg.ssd.transfer, str)
          data_shape = int(self._cfg.ssd.transfer.split("_")[1])
          self._cfg.ssd.data_shape = data_shape
          self._logger.info(
              f"Using transfer learning from {self._cfg.ssd.transfer}, the other network parameters are ignored."
          )
          if self._cfg.ssd.syncbn and len(self.ctx) > 1:
              with warnings.catch_warnings(record=True) as _:
                  warnings.simplefilter("always")
                  self.net = get_model(
                      self._cfg.ssd.transfer,
                      pretrained=(not load_only),
                      norm_layer=gluon.contrib.nn.SyncBatchNorm,
                      norm_kwargs={"num_devices": len(self.ctx)},
                  )
                  self.async_net = get_model(
                      self._cfg.ssd.transfer, pretrained=(not load_only)
                  )  # used by cpu worker
              if load_only:
                  with warnings.catch_warnings(record=True) as w:
                      warnings.simplefilter("always")
                      self.net.initialize()
                  self.net.set_nms(nms_thresh=0)
                  self.net(
                      mx.nd.zeros(
                          (
                              1,
                              3,
                              self._cfg.ssd.data_shape,
                              self._cfg.ssd.data_shape,
                          )
                      )
                  )
                  self.net.set_nms(
                      nms_thresh=self._cfg.ssd.nms_thresh,
                      nms_topk=self._cfg.ssd.nms_topk,
                  )
              self.net.reset_class(
                  self.classes,
                  reuse_weights=[
                      cname
                      for cname in self.classes
                      if cname in self.net.classes
                  ],
              )
          else:
              self.net = get_model(
                  self._cfg.ssd.transfer,
                  pretrained=(not load_only),
                  norm_layer=gluon.nn.BatchNorm,
              )
              self.async_net = get_model(
                  self._cfg.ssd.transfer,
                  pretrained=(not load_only),
                  norm_layer=gluon.nn.BatchNorm,
              )
              if load_only:
                  with warnings.catch_warnings(record=True) as w:
                      warnings.simplefilter("always")
                      self.net.initialize()
                  self.net.set_nms(nms_thresh=0)
                  self.net(
                      mx.nd.zeros(
                          (
                              1,
                              3,
                              self._cfg.ssd.data_shape,
                              self._cfg.ssd.data_shape,
                          )
                      )
                  )
                  self.net.set_nms(
                      nms_thresh=self._cfg.ssd.nms_thresh,
                      nms_topk=self._cfg.ssd.nms_topk,
                  )
              self.net.reset_class(
                  self.classes,
                  reuse_weights=[
                      cname
                      for cname in self.classes
                      if cname in self.net.classes
                  ],
              )
      # elif self._cfg.ssd.custom_model:
      else:
          if self._cfg.ssd.syncbn and len(self.ctx) > 1:
              with warnings.catch_warnings(record=True) as w:
                  warnings.simplefilter("always")
                  self.net = custom_ssd(
                      base_network_name=self._cfg.ssd.base_network,
                      base_size=self._cfg.ssd.data_shape,
                      filters=self._cfg.ssd.filters,
                      sizes=self._cfg.ssd.sizes,
                      ratios=self._cfg.ssd.ratios,
                      steps=self._cfg.ssd.steps,
                      classes=self.classes,
                      dataset="auto",
                      pretrained_base=(not load_only),
                      norm_layer=gluon.contrib.nn.SyncBatchNorm,
                      norm_kwargs={"num_devices": len(self.ctx)},
                  )
                  self.async_net = custom_ssd(
                      base_network_name=self._cfg.ssd.base_network,
                      base_size=self._cfg.ssd.data_shape,
                      filters=self._cfg.ssd.filters,
                      sizes=self._cfg.ssd.sizes,
                      ratios=self._cfg.ssd.ratios,
                      steps=self._cfg.ssd.steps,
                      classes=self.classes,
                      dataset="auto",
                      pretrained_base=False,
                  )
          else:
              with warnings.catch_warnings(record=True) as w:
                  warnings.simplefilter("always")
                  self.net = custom_ssd(
                      base_network_name=self._cfg.ssd.base_network,
                      base_size=self._cfg.ssd.data_shape,
                      filters=self._cfg.ssd.filters,
                      sizes=self._cfg.ssd.sizes,
                      ratios=self._cfg.ssd.ratios,
                      steps=self._cfg.ssd.steps,
                      classes=self.classes,
                      dataset=self._cfg.dataset,
                      pretrained_base=(not load_only),
                      norm_layer=gluon.nn.BatchNorm,
                  )
                  self.async_net = self.net
  
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always")
          self.net.initialize()
          self.async_net.initialize()
          # needed for net to be first gpu when using AMP
          self.net.collect_params().reset_ctx(self.ctx)
  
imports: import os
  import math
  import time
  import warnings
  from PIL import Image
  import pandas
  import numpy
  import mxnet
  from mxnet import nd
  from mxnet import gluon
  from mxnet import autograd
  from mxnet.contrib import amp
  from ....None import utils
  from ....data.batchify import Tuple, Stack, Pad
  from ....utils.metrics.voc_detection import VOC07MApMetric, VOCMApMetric
  from ....model_zoo import get_model
  from ....model_zoo import custom_ssd
  from ....data.transforms.presets.ssd import SSDDefaultValTransform
  from ....data.transforms.presets.ssd import load_test, transform_test
  from ....loss import SSDMultiBoxLoss
  from .utils import _get_dataloader, _get_dali_dataloader
  from ..base_estimator import BaseEstimator, set_default
  from .default import SSDCfg
  from ...data.dataset import ObjectDetectionDataset
  from ..conf import _BEST_CHECKPOINT_FILE
  from ..utils import EarlyStopperOnPlateau
label_desc: Use image node_id 7 for calling the SSDEstimator obj's underlying member method code with example usage: obj._init_network() without return types