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.
docstr: Start closure event loop if not started
docstr_tok: ["Start","closure","event","loop","if","not","started"]
code: def start_event_loop(self):
      """Start closure event loop if not started"""
      if self._closure_event_loop is None:
  
          def event_loop():
              # Run loop until closure event is set and closure queue is empty
              while True:
                  try:
                      closure = self._closure_queue.get(
                          block=True, timeout=3
                      )
                      closure()
                      self._closure_queue.task_done()
                  except EmptyQueue:
                      with self._closure_lock:
                          if self._closure_queue.empty():
                              self._closure_event_loop_finished.set()
                              return
                  except Exception as e:
                      self._closure_exception.put(e)
                      return
  
          self._closure_event_loop = threading.Thread(target=event_loop)
          self._closure_event_loop.start()
  
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 2 for calling the AsyncClosureHandler obj's underlying member method code with example usage: obj.start_event_loop() without return types