class_docstr: Estimator implementation for CenterNet.
  
  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.
class_docstr_tok: ["Estimator","implementation","for","CenterNet",".","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","."]
code: def _train_loop(
      self, train_data, val_data, train_eval_data, time_limit=math.inf
  ):
      start_tic = time.time()
      wh_loss = MaskedL1Loss(weight=self._cfg.center_net.wh_weight)
      heatmap_loss = HeatmapFocalLoss(from_logits=True)
      center_reg_loss = MaskedL1Loss(
          weight=self._cfg.center_net.center_reg_weight
      )
      heatmap_loss_metric = mx.metric.Loss("HeatmapFocal")
      wh_metric = mx.metric.Loss("WHL1")
      center_reg_metric = mx.metric.Loss("CenterRegL1")
  
      self._logger.info(
          "Start training from [Epoch %d]",
          max(self._cfg.train.start_epoch, self.epoch),
      )
      early_stopper = EarlyStopperOnPlateau(
          patience=self._cfg.train.early_stop_patience,
          min_delta=self._cfg.train.early_stop_min_delta,
          baseline_value=self._cfg.train.early_stop_baseline,
          max_value=self._cfg.train.early_stop_max_value,
      )
      mean_ap = [-1]
      cp_name = ""
      self._time_elapsed += time.time() - start_tic
      for self.epoch in range(
          max(self._cfg.train.start_epoch, self.epoch),
          self._cfg.train.epochs,
      ):
          epoch = self.epoch
          tic = time.time()
          last_tic = time.time()
          if self._best_map >= 1.0:
              self._logger.info(
                  "[Epoch %d] Early stopping as mAP is reaching 1.0",
                  epoch,
              )
              break
          (
              should_stop,
              stop_message,
          ) = early_stopper.get_early_stop_advice()
          if should_stop:
              self._logger.info(
                  "[Epoch {}] ".format(epoch) + stop_message
              )
              break
          wh_metric.reset()
          center_reg_metric.reset()
          heatmap_loss_metric.reset()
          self.net.hybridize()
  
          for i, batch in enumerate(train_data):
              btic = time.time()
              if self._time_elapsed > time_limit:
                  self._logger.warning(
                      f"`time_limit={time_limit}` reached, exit early..."
                  )
                  return {
                      "train_map": float(mean_ap[-1]),
                      "valid_map": self._best_map,
                      "time": self._time_elapsed,
                      "checkpoint": cp_name,
                  }
              split_data = [
                  gluon.utils.split_and_load(
                      batch[ind],
                      ctx_list=self.ctx,
                      batch_axis=0,
                      even_split=False,
                  )
                  for ind in range(6)
              ]
              (
                  data,
                  heatmap_targets,
                  wh_targets,
                  wh_masks,
                  center_reg_targets,
                  center_reg_masks,
              ) = split_data
              batch_size = self._cfg.train.batch_size
              with autograd.record():
                  sum_losses = []
                  heatmap_losses = []
                  wh_losses = []
                  center_reg_losses = []
                  wh_preds = []
                  center_reg_preds = []
                  for (
                      x,
                      heatmap_target,
                      wh_target,
                      wh_mask,
                      center_reg_target,
                      center_reg_mask,
                  ) in zip(*split_data):
                      heatmap_pred, wh_pred, center_reg_pred = self.net(
                          x
                      )
                      wh_preds.append(wh_pred)
                      center_reg_preds.append(center_reg_pred)
                      wh_losses.append(
                          wh_loss(wh_pred, wh_target, wh_mask)
                      )
                      center_reg_losses.append(
                          center_reg_loss(
                              center_reg_pred,
                              center_reg_target,
                              center_reg_mask,
                          )
                      )
                      heatmap_losses.append(
                          heatmap_loss(heatmap_pred, heatmap_target)
                      )
                      curr_loss = (
                          heatmap_losses[-1]
                          + wh_losses[-1]
                          + center_reg_losses[-1]
                      )
                      sum_losses.append(curr_loss)
                  autograd.backward(sum_losses)
              self.trainer.step(len(sum_losses))  # step with # gpus
  
              heatmap_loss_metric.update(0, heatmap_losses)
              wh_metric.update(0, wh_losses)
              center_reg_metric.update(0, center_reg_losses)
              if (
                  self._cfg.train.log_interval
                  and not (i + 1) % self._cfg.train.log_interval
              ):
                  name2, loss2 = wh_metric.get()
                  name3, loss3 = center_reg_metric.get()
                  name4, loss4 = heatmap_loss_metric.get()
                  self._logger.info(
                      "[Epoch {}][Batch {}], Speed: {:.3f} samples/sec, "
                      "LR={}, {}={:.3f}, {}={:.3f}, {}={:.3f}".format(
                          epoch,
                          i,
                          batch_size / (time.time() - last_tic),
                          self.trainer.learning_rate,
                          name2,
                          loss2,
                          name3,
                          loss3,
                          name4,
                          loss4,
                      )
                  )
                  last_tic = time.time()
              self._time_elapsed += time.time() - btic
  
          post_tic = time.time()
          name2, loss2 = wh_metric.get()
          name3, loss3 = center_reg_metric.get()
          name4, loss4 = heatmap_loss_metric.get()
          self._logger.info(
              "[Epoch {}] Training cost: {:.3f}, {}={:.3f}, {}={:.3f}, {}={:.3f}".format(
                  epoch,
                  (time.time() - tic),
                  name2,
                  loss2,
                  name3,
                  loss3,
                  name4,
                  loss4,
              )
          )
          if (epoch % self._cfg.valid.interval == 0) or (
              epoch == self._cfg.train.epochs - 1
          ):
              # consider reduce the frequency of validation to save time
              map_name, mean_ap = self._evaluate(val_data)
              val_msg = "\n".join(
                  [
                      "{}={}".format(k, v)
                      for k, v in zip(map_name, mean_ap)
                  ]
              )
              self._logger.info(
                  "[Epoch %d] Validation: \n%s", epoch, val_msg
              )
              current_map = float(mean_ap[-1])
              if current_map > self._best_map:
                  cp_name = os.path.join(
                      self._logdir, _BEST_CHECKPOINT_FILE
                  )
                  self._logger.info(
                      "[Epoch %d] Current best map: %f vs previous %f, saved to %s",
                      self.epoch,
                      current_map,
                      self._best_map,
                      cp_name,
                  )
                  self.save(cp_name)
                  self._best_map = current_map
              if self._reporter:
                  self._reporter(epoch=epoch, map_reward=current_map)
              early_stopper.update(current_map, epoch=epoch)
          self._time_elapsed += time.time() - post_tic
      # map on train data
      tic = time.time()
      map_name, mean_ap = self._evaluate(train_eval_data)
      self._time_elapsed += time.time() - tic
      return {
          "train_map": float(mean_ap[-1]),
          "valid_map": self._best_map,
          "time": self._time_elapsed,
          "checkpoint": cp_name,
      }
  
imports: import os
  import math
  import time
  import warnings
  from collections import OrderedDict
  from PIL import Image
  import pandas
  import numpy
  import mxnet
  from mxnet import autograd
  from mxnet import gluon
  from ..base_estimator import BaseEstimator, set_default
  from ....data.batchify import Tuple, Stack, Pad
  from ....data.transforms.presets.center_net import CenterNetDefaultTrainTransform
  from ....data.transforms.presets.center_net import CenterNetDefaultValTransform
  from ....data.transforms.presets.center_net import load_test, transform_test
  from ....loss import MaskedL1Loss, HeatmapFocalLoss
  from ....model_zoo import get_model
  from ....model_zoo.center_net import get_center_net, get_base_network
  from ....utils import LRScheduler, LRSequential
  from ....utils.metrics import VOCMApMetric, VOC07MApMetric
  from .default import CenterNetCfg
  from ...data.dataset import ObjectDetectionDataset
  from ..conf import _BEST_CHECKPOINT_FILE
  from ..utils import EarlyStopperOnPlateau
label_desc: Use image node_id 5 for calling the CenterNetEstimator obj's underlying member method code with example usage: obj._train_loop(train_data, val_data, train_eval_data, time_limit) and returns: dict, dict