class_docstr: Actor which learns (updates its parameters) when `update` is called.
  
  This combines a base actor and a learner. Whenever `update` is called
  on the wrapping actor the learner will take a step (e.g. one step of gradient
  descent) as long as there is data available for training
  (provided iterator and replay_tables are used to check for that).
  Selecting actions and making observations are handled by the base actor.
  Intended to be used by the `run_experiment` only.
class_docstr_tok: ["Actor","which","learns","(","updates","its","parameters",")","when","`","update","`","is","called",".","This","combines","a","base","actor","and","a","learner",".","Whenever","`","update","`","is","called","on","the","wrapping","actor","the","learner","will","take","a","step","(","e.g",".","one","step","of","gradient","descent",")","as","long","as","there","is","data","available","for","training","(","provided","iterator","and","replay_tables","are","used","to","check","for","that",")",".","Selecting","actions","and","making","observations","are","handled","by","the","base","actor",".","Intended","to","be","used","by","the","`","run_experiment","`","only","."]
code: def _maybe_train(self):
      trained = False
      while True:
          if self._iterator.ready():
              self._learner.step()
              batches = (
                  self._iterator.retrieved_elements()
                  - self._learner_steps
              )
              self._learner_steps += 1
              assert batches == 1, (
                  "Learner step must retrieve exactly one element from the iterator"
                  f" (retrieved {batches}). Otherwise agent can deadlock. Example "
                  "cause is that your chosen agent"
                  "s Builder has a `make_learner` "
                  "factory that prefetches the data but it shouldn"
                  "t."
              )
              trained = True
          else:
              # Wait for the iterator to fetch more data from the table(s) only
              # if there plenty of data to sample from each table.
              for table, sample_size in zip(
                  self._replay_tables, self._sample_sizes
              ):
                  if not table.can_sample(sample_size):
                      return trained
              # Let iterator's prefetching thread get data from the table(s).
              time.sleep(0.001)
  
imports: import sys
  import time
  from typing import Optional, Sequence, Tuple
  import acme
  from acme import core
  from acme import specs
  from acme import types
  from acme.jax import utils
  from acme.jax.experiments import config
  from acme.tf import savers
  from acme.utils import counting
  import dm_env
  import jax
  import reverb
label_desc: Use image node_id 5 for calling the _LearningActor obj's underlying member method code with example usage: obj._maybe_train() and returns: trained