code: def init_trainer(optimizer_or_trainer):
      """Initialize trainer or optimizer to work with AMP dynamic loss scaling.
  
      Parameters
      ----------
      optimizer_or_trainer : Optimizer or Trainer
          MXNet Optimizer or Gluon trainer to initialize with AMP
      """
      global _amp_loss_scale_initialized
      global _amp_initialized
      global _loss_scaler
      assert (
          _amp_initialized
      ), "AMP not initialized, did you forget to call amp.init()?"
      if not _amp_loss_scale_initialized:
          _amp_loss_scale_initialized = True
          loss_scaler = _loss_scaler
      else:
          loss_scaler = LossScaler()
      # _wrap_output
      if isinstance(optimizer_or_trainer, trainer.Trainer):
          optimizer_or_trainer._amp_loss_scaler = loss_scaler
          optimizer_or_trainer._amp_original_scale = (
              optimizer_or_trainer._scale
          )
          trainer.Trainer.amp_loss_scale = property(
              lambda self: self._amp_loss_scaler.loss_scale
          )
      elif isinstance(optimizer_or_trainer, opt.Optimizer):
          raise TypeError(
              "AMP is currently only compatible with Gluon Trainer"
          )
      else:
          raise TypeError(
              "optimizer_or_trainer should be a Gluon Trainer or "
              f"an optimizer, instead is {type(optimizer_or_trainer)}"
          )
  
imports: from array import array
  import ctypes
  import inspect
  import logging
  import contextlib
  import sys
  import numpy
  from mxnet import numpy
  from ..None import symbol
  from ..device import gpu
  from ..symbol import Symbol
  from ..symbol import contrib
  from ..None import ndarray
  from ..ndarray import NDArray, dtype_np_to_mx, get_dtype_type, get_dtype_name, bfloat16
  from .None import lists
  from ..gluon import Block, HybridBlock, trainer
  from ..None import base
  from ..base import _NP_OP_PREFIX, _NP_OP_SUBMODULE_LIST, _NP_EXT_OP_PREFIX, _NP_EXT_OP_SUBMODULE_LIST, _NP_INTERNAL_OP_PREFIX, c_str_array, c_str, c_array_buf, SymbolHandle, check_call, _LIB
  from ..None import optimizer
  from .loss_scaler import LossScaler
  from ..operator import get_all_registered_operators_grouped
  from ..util import wrap_ctx_to_device_func
label_desc: Use image node_id 9 for calling a global function with example usage: init_trainer(optimizer_or_trainer) without return types