class_docstr: Manages all the learning details needed when training an agent.
  
  These include:
    * Using distribution strategies correctly
    * Summaries
    * Checkpoints
    * Minimizing entering/exiting TF context:
        Especially in the case of TPUs scheduling a single TPU program to
        perform multiple train steps is critical for performance.
    * Generalizes the train call to be done correctly across CPU, GPU, or TPU
      executions managed by DistributionStrategies. This uses `strategy.run` and
      then makes sure to do a reduce operation over the `LossInfo` returned by
      the agent.
class_docstr_tok: ["Manages","all","the","learning","details","needed","when","training","an","agent",".","These","include",":","*","Using","distribution","strategies","correctly","*","Summaries","*","Checkpoints","*","Minimizing","entering\/exiting","TF","context",":","Especially","in","the","case","of","TPUs","scheduling","a","single","TPU","program","to","perform","multiple","train","steps","is","critical","for","performance",".","*","Generalizes","the","train","call","to","be","done","correctly","across","CPU",",","GPU",",","or","TPU","executions","managed","by","DistributionStrategies",".","This","uses","`","strategy.run","`","and","then","makes","sure","to","do","a","reduce","operation","over","the","`","LossInfo","`","returned","by","the","agent","."]
code: def single_train_step(self, iterator):
      sample = next(iterator)
  
      if self._direct_sampling:
          experience, sample_info = sample, None
      elif self._use_reverb_v2:
          experience, sample_info = sample.data, sample.info
      else:
          experience, sample_info = sample
  
      if self.use_kwargs_in_agent_train:
          loss_info = self.strategy.run(
              self._agent.train,
              kwargs=experience,
              options=self._strategy_run_options,
          )
      else:
          loss_info = self.strategy.run(
              self._agent.train,
              args=(experience,),
              options=self._strategy_run_options,
          )
  
      if self.after_train_strategy_step_fn:
          if self.use_kwargs_in_agent_train:
              self.strategy.run(
                  self.after_train_strategy_step_fn,
                  kwargs=dict(
                      experience=(experience, sample_info),
                      loss_info=loss_info,
                  ),
                  options=self._strategy_run_options,
              )
          else:
              self.strategy.run(
                  self.after_train_strategy_step_fn,
                  args=((experience, sample_info), loss_info),
                  options=self._strategy_run_options,
              )
  
      return loss_info
  
file_path: agents/tf_agents/train/learner.py
imports: import os
  from typing import Any, Optional, Tuple
  from absl import logging
  import gin
  import tensorflow.compat.v2
  from tf_agents.agents import tf_agent
  from tf_agents.specs import tensor_spec
  from tf_agents.train import interval_trigger
  from tf_agents.typing import types
  from tf_agents.utils import common
label_desc: Use image node_id 6 for calling the Learner obj's underlying member method code with example usage: obj.single_train_step(iterator) and returns: loss_info