class_docstr: Manages state and performs updates for IMPALA learner.
docstr: Runs the learner for max_iterations updates.
docstr_tok: ["Runs","the","learner","for","max_iterations","updates","."]
code: def run(self, max_iterations: int = -1):
      """Runs the learner for max_iterations updates."""
      # Start host-to-device transfer worker.
      transfer_thread = threading.Thread(
          target=self.host_to_device_worker
      )
      transfer_thread.start()
  
      (num_frames, params) = self._params_for_actor
      opt_state = self._opt.init(params)
  
      steps = (
          range(max_iterations)
          if max_iterations != -1
          else itertools.count()
      )
      for _ in steps:
          batch = self._device_q.get()
          params, opt_state, logs = self.update(
              params, opt_state, batch
          )
          num_frames += self._frames_per_iter
  
          # Collect parameters to distribute to downstream actors.
          self._params_for_actor = (num_frames, jax.device_get(params))
  
          # Collect and write logs out.
          logs = jax.device_get(logs)
          logs.update(
              {
                  "num_frames": num_frames,
              }
          )
          self._logger.write(logs)
  
      # Shut down.
      self._done = True
      self._logger.close()
      transfer_thread.join()
  
imports: import functools
  import itertools
  import queue
  import threading
  import warnings
  import dm_env
  import haiku
  from examples.impala import agent
  from examples.impala import util
  import jax
  from jax.example_libraries import optimizers
  import jax.numpy
  import numpy
  import optax
  import rlax
label_desc: Use image node_id 7 for calling the Learner obj's underlying member method code with example usage: obj.run(max_iterations) without return types