docstr: Reset model gradients as well as accumulated gradients to zero. If accumulated gradients
  have not been created yet, it constructs them on CPU.
docstr_tok: ["Reset","model","gradients","as","well","as","accumulated","gradients","to","zero",".","If","accumulated","gradients","have","not","been","created","yet",",","it","constructs","them","on","CPU","."]
code: def reset_accumulated_gradients(self) -> None:
      """
      Reset model gradients as well as accumulated gradients to zero. If accumulated gradients
      have not been created yet, it constructs them on CPU.
      """
      # Set model gradients to zero
      for p in self.model.collect_params().values():
          p.zero_grad()
      # Set accumulated gradients to zero if already initialized, otherwise create a copy
      if self.accumulated_gradients:
          for a in self.accumulated_gradients:
              a *= 0
      else:
          self.accumulated_gradients = [
              g.copy() for g in self._model_grads()
          ]
  
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 9 for calling the MxnetArchitecture obj's underlying member method code with example usage: obj.reset_accumulated_gradients() without return types