class_docstr: Learner for an importanced-weighted advantage actor-critic.
code: def __init__(
      self,
      environment_spec: specs.EnvironmentSpec,
      network: snt.RNNCore,
      dataset: tf.data.Dataset,
      learning_rate: float,
      discount: float = 0.99,
      entropy_cost: float = 0.0,
      baseline_cost: float = 1.0,
      max_abs_reward: Optional[float] = None,
      max_gradient_norm: Optional[float] = None,
      counter: Optional[counting.Counter] = None,
      logger: Optional[loggers.Logger] = None,
  ):
      # Internalise, optimizer, and dataset.
      self._env_spec = environment_spec
      self._optimizer = snt.optimizers.Adam(learning_rate=learning_rate)
      self._network = network
      self._variables = network.variables
      # TODO(b/155086959): Fix type stubs and remove.
      self._iterator = iter(dataset)  # pytype: disable=wrong-arg-types
  
      # Hyperparameters.
      self._discount = discount
      self._entropy_cost = entropy_cost
      self._baseline_cost = baseline_cost
  
      # Set up reward/gradient clipping.
      if max_abs_reward is None:
          max_abs_reward = np.inf
      if max_gradient_norm is None:
          max_gradient_norm = (
              1e10  # A very large number. Infinity results in NaNs.
          )
      self._max_abs_reward = tf.convert_to_tensor(max_abs_reward)
      self._max_gradient_norm = tf.convert_to_tensor(max_gradient_norm)
  
      # Set up logging/counting.
      self._counter = counter or counting.Counter()
      self._logger = logger or loggers.TerminalLogger(
          "learner", time_delta=1.0
      )
  
      self._snapshotter = tf2_savers.Snapshotter(
          objects_to_save={"network": network}, time_delta_minutes=60.0
      )
  
      # Do not record timestamps until after the first learning step is done.
      # This is to avoid including the time it takes for actors to come online and
      # fill the replay buffer.
      self._timestamp = None
  
imports: import time
  from typing import Dict, List, Mapping, Optional
  import acme
  from acme import specs
  from acme.tf import savers
  from acme.tf import utils
  from acme.utils import counting
  from acme.utils import loggers
  import numpy
  import reverb
  import sonnet
  import tensorflow
  import tensorflow_probability
  import tree
  import trfl
label_desc: Use image node_id 1 to create a new IMPALALearner object from inherited base classes: acme, tf2_savers with example: obj = IMPALALearner(environment_spec, network, dataset, learning_rate, discount, entropy_cost, baseline_cost, max_abs_reward, max_gradient_norm, counter, logger)