class_docstr: ## Trainer
class_docstr_tok: ["#","#","Trainer"]
docstr: ### Run training loop
docstr_tok: ["#","#","#","Run","training","loop"]
code: def run_training_loop(self):
      """
      ### Run training loop
      """
  
      # Last 100 episode information
      tracker.set_queue("reward", 100, True)
      tracker.set_queue("length", 100, True)
  
      # Copy to target network initially
      self.target_model.load_state_dict(self.model.state_dict())
  
      for update in monit.loop(self.updates):
          # $\epsilon$, exploration fraction
          exploration = self.exploration_coefficient(update)
          tracker.add("exploration", exploration)
          # $\beta$ for prioritized replay
          beta = self.prioritized_replay_beta(update)
          tracker.add("beta", beta)
  
          # Sample with current policy
          self.sample(exploration)
  
          # Start training after the buffer is full
          if self.replay_buffer.is_full():
              # Train the model
              self.train(beta)
  
              # Periodically update target network
              if update % self.update_target_model == 0:
                  self.target_model.load_state_dict(
                      self.model.state_dict()
                  )
  
          # Save tracked indicators.
          tracker.save()
          # Add a new line to the screen periodically
          if (update + 1) % 1_000 == 0:
              logger.log()
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/rl/dqn/experiment.py
imports: import numpy
  import torch
  from labml import tracker, experiment, logger, monit
  from labml.internal.configs.dynamic_hyperparam import FloatDynamicHyperParam
  from labml_helpers.schedule import Piecewise
  from labml_nn.rl.dqn import QFuncLoss
  from labml_nn.rl.dqn.model import Model
  from labml_nn.rl.dqn.replay_buffer import ReplayBuffer
  from labml_nn.rl.game import Worker
label_desc: Use image node_id 5 for calling the Trainer obj's underlying member method code with example usage: obj.run_training_loop() without return types