docstr: Given a batch of inputs (i.e. states) and targets (e.g. discounted rewards), computes and accumulates the
  gradients for model parameters. Will run forward and backward pass to compute gradients, clip the gradient
  values if required and then accumulate gradients from all learners. It does not update the model weights,
  that's performed in `apply_and_reset_gradients` method.
  
  Once gradients are accumulated, they are accessed by `accumulated_gradients` property of this class.å
  
  :param inputs: typically the environment states (but can also contain other data for loss)
      (e.g. `{'observation': numpy.ndarray}` with `observation` of shape (batch_size, observation_space_size) or
       (batch_size, observation_space_size, stack_size) or
      `{'observation': numpy.ndarray, 'output_0_0': numpy.ndarray}` with `output_0_0` of shape (batch_size,))
  :param targets: targets for calculating loss. For example discounted rewards for value network
      for calculating the value-network loss would be a target. Length of list and order of arrays in
      the list matches that of network losses which are defined by network parameters
  :param additional_fetches: list of additional values to fetch and return. The type of each list
      element is framework dependent.
  :param importance_weights: ndarray of shape (batch_size,) to multiply with batch loss.
  :param no_accumulation: if True, set gradient values to the new gradients, otherwise sum with previously
      calculated gradients
  :return: tuple of total_loss, losses, norm_unclipped_grads, fetched_tensors
      total_loss (float): sum of all head losses
      losses (list of float): list of all losses. The order is list of target losses followed by list of
          regularization losses. The specifics of losses is dependant on the network parameters
          (number of heads, etc.)
      norm_unclippsed_grads (float): global norm of all gradients before any gradient clipping is applied
      fetched_tensors: all values for additional_fetches
docstr_tok: ["Given","a","batch","of","inputs","(","i.e",".","states",")","and","targets","(","e.g",".","discounted","rewards",")",",","computes","and","accumulates","the","gradients","for","model","parameters",".","Will","run","forward","and","backward","pass","to","compute","gradients",",","clip","the","gradient","values","if","required","and","then","accumulate","gradients","from","all","learners",".","It","does","not","update","the","model","weights",",","that","'s","performed","in","`","apply_and_reset_gradients","`","method",".","Once","gradients","are","accumulated",",","they","are","accessed","by","`","accumulated_gradients","`","property","of","this","class.\u00e5",":","param","inputs",":","typically","the","environment","states","(","but","can","also","contain","other","data","for","loss",")","(","e.g",".","`","{","'observation","'",":","numpy.ndarray","}","`","with","`","observation","`","of","shape","(","batch_size",",","observation_space_size",")","or","(","batch_size",",","observation_space_size",",","stack_size",")","or","`","{","'observation","'",":","numpy.ndarray",",","'output_0_0","'",":","numpy.ndarray","}","`","with","`","output_0_0","`","of","shape","(","batch_size",",",")",")",":","param","targets",":","targets","for","calculating","loss",".","For","example","discounted","rewards","for","value","network","for","calculating","the","value-network","loss","would","be","a","target",".","Length","of","list","and","order","of","arrays","in","the","list","matches","that","of","network","losses","which","are","defined","by","network","parameters",":","param","additional_fetches",":","list","of","additional","values","to","fetch","and","return",".","The","type","of","each","list","element","is","framework","dependent",".",":","param","importance_weights",":","ndarray","of","shape","(","batch_size",",",")","to","multiply","with","batch","loss",".",":","param","no_accumulation",":","if","True",",","set","gradient","values","to","the","new","gradients",",","otherwise","sum","with","previously","calculated","gradients",":","return",":","tuple","of","total_loss",",","losses",",","norm_unclipped_grads",",","fetched_tensors","total_loss","(","float",")",":","sum","of","all","head","losses","losses","(","list","of","float",")",":","list","of","all","losses",".","The","order","is","list","of","target","losses","followed","by","list","of","regularization","losses",".","The","specifics","of","losses","is","dependant","on","the","network","parameters","(","number","of","heads",",","etc",".",")","norm_unclippsed_grads","(","float",")",":","global","norm","of","all","gradients","before","any","gradient","clipping","is","applied","fetched_tensors",":","all","values","for","additional_fetches"]
code: def accumulate_gradients(
      self,
      inputs: Dict[str, np.ndarray],
      targets: List[np.ndarray],
      additional_fetches: list = None,
      importance_weights: np.ndarray = None,
      no_accumulation: bool = False,
  ) -> Tuple[float, List[float], float, list]:
      """
      Given a batch of inputs (i.e. states) and targets (e.g. discounted rewards), computes and accumulates the
      gradients for model parameters. Will run forward and backward pass to compute gradients, clip the gradient
      values if required and then accumulate gradients from all learners. It does not update the model weights,
      that's performed in `apply_and_reset_gradients` method.
  
      Once gradients are accumulated, they are accessed by `accumulated_gradients` property of this class.å
  
      :param inputs: typically the environment states (but can also contain other data for loss)
          (e.g. `{'observation': numpy.ndarray}` with `observation` of shape (batch_size, observation_space_size) or
           (batch_size, observation_space_size, stack_size) or
          `{'observation': numpy.ndarray, 'output_0_0': numpy.ndarray}` with `output_0_0` of shape (batch_size,))
      :param targets: targets for calculating loss. For example discounted rewards for value network
          for calculating the value-network loss would be a target. Length of list and order of arrays in
          the list matches that of network losses which are defined by network parameters
      :param additional_fetches: list of additional values to fetch and return. The type of each list
          element is framework dependent.
      :param importance_weights: ndarray of shape (batch_size,) to multiply with batch loss.
      :param no_accumulation: if True, set gradient values to the new gradients, otherwise sum with previously
          calculated gradients
      :return: tuple of total_loss, losses, norm_unclipped_grads, fetched_tensors
          total_loss (float): sum of all head losses
          losses (list of float): list of all losses. The order is list of target losses followed by list of
              regularization losses. The specifics of losses is dependant on the network parameters
              (number of heads, etc.)
          norm_unclippsed_grads (float): global norm of all gradients before any gradient clipping is applied
          fetched_tensors: all values for additional_fetches
      """
      raise NotImplementedError
  
imports: from typing import Any, Dict, List, Tuple
  import numpy
  from rl_coach.base_parameters import AgentParameters
  from rl_coach.saver import SaverCollection
  from rl_coach.spaces import SpacesDefinition
label_desc: Use image node_id 9 for calling the Architecture obj's underlying member method code with example usage: obj.accumulate_gradients(inputs, targets, additional_fetches, importance_weights, no_accumulation) without return types