class_docstr: The network wrapper contains multiple copies of the same network, each one with a different set of weights which is
  updating in a different time scale. The network wrapper will always contain an online network.
  It will contain an additional slow updating target network if it was requested by the user,
  and it will contain a global network shared between different workers, if Coach is run in a single-node
  multi-process distributed mode. The network wrapper contains functionality for managing these networks and syncing
  between them.
class_docstr_tok: ["The","network","wrapper","contains","multiple","copies","of","the","same","network",",","each","one","with","a","different","set","of","weights","which","is","updating","in","a","different","time","scale",".","The","network","wrapper","will","always","contain","an","online","network",".","It","will","contain","an","additional","slow","updating","target","network","if","it","was","requested","by","the","user",",","and","it","will","contain","a","global","network","shared","between","different","workers",",","if","Coach","is","run","in","a","single-node","multi-process","distributed","mode",".","The","network","wrapper","contains","functionality","for","managing","these","networks","and","syncing","between","them","."]
docstr: Applies the gradients accumulated in the online network to the global network or to itself and syncs the
  networks if necessary
  
  :param reset_gradients: If set to True, the accumulated gradients wont be reset to 0 after applying them to
                          the network. this is useful when the accumulated gradients are overwritten instead
                          if accumulated by the accumulate_gradients function. this allows reducing time
                          complexity for this function by around 10%
  :param additional_inputs: optional additional inputs required for when applying the gradients (e.g. batchnorm's
                            update ops also requires the inputs)
docstr_tok: ["Applies","the","gradients","accumulated","in","the","online","network","to","the","global","network","or","to","itself","and","syncs","the","networks","if","necessary",":","param","reset_gradients",":","If","set","to","True",",","the","accumulated","gradients","wont","be","reset","to","0","after","applying","them","to","the","network",".","this","is","useful","when","the","accumulated","gradients","are","overwritten","instead","if","accumulated","by","the","accumulate_gradients","function",".","this","allows","reducing","time","complexity","for","this","function","by","around","10","%",":","param","additional_inputs",":","optional","additional","inputs","required","for","when","applying","the","gradients","(","e.g",".","batchnorm's","update","ops","also","requires","the","inputs",")"]
code: def apply_gradients_and_sync_networks(
      self, reset_gradients=True, additional_inputs=None
  ):
      """
      Applies the gradients accumulated in the online network to the global network or to itself and syncs the
      networks if necessary
  
      :param reset_gradients: If set to True, the accumulated gradients wont be reset to 0 after applying them to
                              the network. this is useful when the accumulated gradients are overwritten instead
                              if accumulated by the accumulate_gradients function. this allows reducing time
                              complexity for this function by around 10%
      :param additional_inputs: optional additional inputs required for when applying the gradients (e.g. batchnorm's
                                update ops also requires the inputs)
  
      """
      if self.global_network:
          self.apply_gradients_to_global_network(
              additional_inputs=additional_inputs
          )
          if reset_gradients:
              self.online_network.reset_accumulated_gradients()
          self.update_online_network()
      else:
          if reset_gradients:
              self.online_network.apply_and_reset_gradients(
                  self.online_network.accumulated_gradients,
                  additional_inputs=additional_inputs,
              )
          else:
              self.online_network.apply_gradients(
                  self.online_network.accumulated_gradients,
                  additional_inputs=additional_inputs,
              )
  
imports: from typing import List, Tuple
  from rl_coach.base_parameters import Frameworks, AgentParameters
  from rl_coach.logger import failed_imports
  from rl_coach.saver import SaverCollection
  from rl_coach.spaces import SpacesDefinition
  from rl_coach.utils import force_list
label_desc: Use image node_id 8 for calling the NetworkWrapper obj's underlying member method code with example usage: obj.apply_gradients_and_sync_networks(reset_gradients, additional_inputs) without return types