class_docstr: Delays object construction to achieve serializability.
  
  Assuming we want to pass a non-serializable Python object, say an environment
  object, to an Actor, the following will lead to a serialization error:
  
      program.add_node(lp.CourierNode(Actor, envloader.load_from_settings(
          platform='Atari',
          settings={
              'levelName': 'pong',
              'env_loader.version': requested_version,
              'zero_indexed_actions': True,
              'interleaved_pixels': True,
          })))
  
  This helper class delays the object construction and fixes this error. The
  object is constructed when the Actor is actually instantiated remotely, where
  the Actor constructed will receive an actual environment object (just like how
  handles are dereferenced automatically):
  
      program.add_node(lp.CourierNode(Actor, lp.Deferred(
          envloader.load_from_settings,
          platform='Atari',
          settings={
              'levelName': 'pong',
              'env_loader.version': requested_version,
              'zero_indexed_actions': True,
              'interleaved_pixels': True,
          })))
code: def dereference(self) -> T:
      if isinstance(self._deferred_object, _Uninitialized):
          args, kwargs = tree.map_structure(
              maybe_dereference, (self._args, self._kwargs)
          )
          if not _LP_CATCH_DEFERRED_EXCEPTION.value:
              # Allows the user to pdb where the exception happens, but won't show
              # where the deferred object was originally defined.
              return self._constructor(*args, **kwargs)
  
          try:
              self._deferred_object = self._constructor(*args, **kwargs)
          except Exception as e:
              new_message = _EXCEPTION_MESSAGE.format(
                  init_stack="".join(self._init_stack),
                  # For clarity during pdb, we also inline the internal error message.
                  error_msg=str(e),
              )
              raise RuntimeError(new_message) from e
  
      return self._deferred_object
  
file_path: launchpad/launchpad/nodes/dereference.py
imports: import abc
  from typing import Callable, Generic, TypeVar, Union
  from absl import flags
  import tree
label_desc: Use image node_id 2 for calling the Deferred obj's underlying member method code with example usage: obj.dereference() and returns: self, self