docstr: Creates a copy of model gradients and returns them in a list, in the same order as collect_params()
  :param index: device index. Set to -1 to get a tuple of list of NDArrays for all devices
  :return: a generator for model gradient values
docstr_tok: ["Creates","a","copy","of","model","gradients","and","returns","them","in","a","list",",","in","the","same","order","as","collect_params","(",")",":","param","index",":","device","index",".","Set","to","-1","to","get","a","tuple","of","list","of","NDArrays","for","all","devices",":","return",":","a","generator","for","model","gradient","values"]
code: def _model_grads(
      self, index: int = 0
  ) -> Union[
      Generator[NDArray, NDArray, Any],
      Generator[List[NDArray], List[NDArray], Any],
  ]:
      """
      Creates a copy of model gradients and returns them in a list, in the same order as collect_params()
      :param index: device index. Set to -1 to get a tuple of list of NDArrays for all devices
      :return: a generator for model gradient values
      """
      if index < 0:
          return (
              p.list_grad()
              for p in self.model.collect_params().values()
              if p.grad_req != "null"
          )
      else:
          return (
              p.list_grad()[index]
              for p in self.model.collect_params().values()
              if p.grad_req != "null"
          )
  
imports: import copy
  from typing import Any, Dict, Generator, List, Tuple, Union
  import numpy
  import mxnet
  from mxnet import autograd, gluon, nd
  from mxnet.ndarray import NDArray
  from rl_coach.architectures.architecture import Architecture
  from rl_coach.architectures.mxnet_components.heads.head import LOSS_OUT_TYPE_LOSS, LOSS_OUT_TYPE_REGULARIZATION
  from rl_coach.architectures.mxnet_components import utils
  from rl_coach.architectures.mxnet_components.savers import ParameterDictSaver, OnnxSaver
  from rl_coach.base_parameters import AgentParameters
  from rl_coach.logger import screen
  from rl_coach.saver import SaverCollection
  from rl_coach.spaces import SpacesDefinition
  from rl_coach.utils import force_list, squeeze_list
label_desc: Use image node_id 4 for calling the MxnetArchitecture obj's underlying member method code with example usage: obj._model_grads(index) and returns: unknown, unknown