class_docstr: Handler for Asynchronous Step Closures
  Args:
      max_queue_size: The maximum length of the closure queue after which
      the training loop will block until closures are evaluated.
      By default, a reasonable limit of a maximum of 100 on the queue.
      This value can be set using the `XLA_MAX_ASYNC_QUEUE` environment
      variable.
code: def run(self, closure):
      with self._closure_lock:
          self._closure_queue.put(closure, block=True)
          if (
              self._closure_event_loop is None
              or not self._closure_event_loop.is_alive()
          ):
              try:
                  e = self._closure_exception.get(block=False)
                  raise RuntimeError(
                      "Cannot run asynchronous closure due to previously raised exception"
                  ) from e
              except EmptyQueue:
                  self._closure_event_loop = None
                  self.start_event_loop()
  
file_path: pytorch/torch/_lazy/closure.py
imports: import os
  import threading
  from queue import Empty, Queue
  from torch._lazy.device_context import get_device_context
label_desc: Use image node_id 3 for calling the AsyncClosureHandler obj's underlying member method code with example usage: obj.run(closure) without return types