class_docstr: Tandem DQN agent.
docstr: Runs a single tandem training step.
  
  Runs training if both:
    (1) A minimum number of frames have been added to the replay buffer.
    (2) `training_steps` is a multiple of `update_period`.
  
  Also, syncs weights from online to target if training steps is a multiple of
  target update period.
docstr_tok: ["Runs","a","single","tandem","training","step",".","Runs","training","if","both",":","(","1",")","A","minimum","number","of","frames","have","been","added","to","the","replay","buffer",".","(","2",")","`","training_steps","`","is","a","multiple","of","`","update_period","`",".","Also",",","syncs","weights","from","online","to","target","if","training","steps","is","a","multiple","of","target","update","period","."]
code: def _train_step(self):
      """Runs a single tandem training step.
  
      Runs training if both:
        (1) A minimum number of frames have been added to the replay buffer.
        (2) `training_steps` is a multiple of `update_period`.
  
      Also, syncs weights from online to target if training steps is a multiple of
      target update period.
      """
      # Run a train op at the rate of self.update_period if enough training steps
      # have been run. This matches the Nature DQN behaviour.
      if self._replay.add_count > self.min_replay_history:
          if self.training_steps % self.update_period == 0:
              self._sample_from_replay_buffer()
              (
                  self.active_optimizer_state,
                  self.active_online_params,
                  active_loss,
              ) = dqn_agent.train(
                  self.network_def,
                  self.active_online_params,
                  self.active_target_params,
                  self.active_optimizer,
                  self.active_optimizer_state,
                  self.replay_elements["state"],
                  self.replay_elements["action"],
                  self.replay_elements["next_state"],
                  self.replay_elements["reward"],
                  self.replay_elements["terminal"],
                  self.cumulative_gamma,
                  self._double_dqn,
              )
              (
                  self.passive_optimizer_state,
                  self.passive_online_params,
                  passive_loss,
              ) = dqn_agent.train(
                  self.network_def,
                  self.passive_online_params,
                  self.passive_target_params,
                  self.passive_optimizer,
                  self.passive_optimizer_state,
                  self.replay_elements["state"],
                  self.replay_elements["action"],
                  self.replay_elements["next_state"],
                  self.replay_elements["reward"],
                  self.replay_elements["terminal"],
                  self.cumulative_gamma,
                  self._double_dqn,
              )
              if (
                  self.summary_writer is not None
                  and self.training_steps > 0
                  and self.training_steps
                  % self.summary_writing_frequency
                  == 0
              ):
                  with self.summary_writer.as_default():
                      tf.summary.scalar(
                          "Losses/Active",
                          active_loss,
                          step=self.training_steps,
                      )
                      tf.summary.scalar(
                          "Losses/Passive",
                          passive_loss,
                          step=self.training_steps,
                      )
                  self.summary_writer.flush()
          if self.training_steps % self.target_update_period == 0:
              self._sync_weights()
  
      self.training_steps += 1
  
imports: import functools
  from absl import logging
  from dopamine.jax import losses
  from dopamine.jax.agents.dqn import dqn_agent
  import gin
  import jax
  import jax.numpy
  import numpy
  import optax
  import tensorflow
label_desc: Use image node_id 7 for calling the TandemDQNAgent obj's underlying member method code with example usage: obj._train_step() without return types