class_docstr: Mixin class adding a method for (soft) target net(s) synchronizations.
  
  - Adds the `update_target` method to the policy.
    Calling `update_target` updates all target Q-networks' weights from their
    respective "main" Q-networks, based on tau (smooth, partial updating).
class_docstr_tok: ["Mixin","class","adding","a","method","for","(","soft",")","target","net","(","s",")","synchronizations",".","-","Adds","the","`","update_target","`","method","to","the","policy",".","Calling","`","update_target","`","updates","all","target","Q-networks","'","weights","from","their","respective","``","main","''","Q-networks",",","based","on","tau","(","smooth",",","partial","updating",")","."]
code: def update_target(self, tau=None):
      # Update_target_fn will be called periodically to copy Q network to
      # target Q network, using (soft) tau-synching.
      tau = tau or self.config.get("tau", 1.0)
  
      model_state_dict = self.model.state_dict()
  
      # Support partial (soft) synching.
      # If tau == 1.0: Full sync from Q-model to target Q-model.
  
      if self.config.get("_enable_new_api_stack", False):
          target_current_network_pairs = (
              self.model.get_target_network_pairs()
          )
          for (
              target_network,
              current_network,
          ) in target_current_network_pairs:
              current_state_dict = current_network.state_dict()
              new_state_dict = {
                  k: tau * current_state_dict[k] + (1 - tau) * v
                  for k, v in target_network.state_dict().items()
              }
              target_network.load_state_dict(new_state_dict)
      else:
          # Support partial (soft) synching.
          # If tau == 1.0: Full sync from Q-model to target Q-model.
          target_state_dict = next(
              iter(self.target_models.values())
          ).state_dict()
          model_state_dict = {
              k: tau * model_state_dict[k] + (1 - tau) * v
              for k, v in target_state_dict.items()
          }
  
          for target in self.target_models.values():
              target.load_state_dict(model_state_dict)
  
imports: from ray.rllib.policy.policy import Policy, PolicyState
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.policy.torch_policy import TorchPolicy
  from ray.rllib.utils.annotations import DeveloperAPI, override
  from ray.rllib.utils.framework import try_import_torch
  from ray.rllib.utils.schedules import PiecewiseSchedule
label_desc: Use image node_id 2 for calling the TargetNetworkMixin obj's underlying member method code with example usage: obj.update_target(tau) without return types