class_docstr: VideoManager object for getting frames from video source for inference
  using multithreading for read and write frames.
class_docstr_tok: ["VideoManager","object","for","getting","frames","from","video","source","for","inference","using","multithreading","for","read","and","write","frames","."]
code: def __next__(self):
      # If there is nothing in the task queue.
      if self.read_queue.qsize() == 0:
          return self.not_end, None
      else:
          with self.put_id_lock:
              put_id = self.put_id
          was_read, task = None, None
          # If mode is to predict most recent read clip.
          if self.num_skip == 0:
              # Write all previous clips to write queue.
              with self.write_lock:
                  while True:
                      was_read, task = self.read_queue.get()
                      if task.id == put_id:
                          break
                      self.write_queue[task.id] = (was_read, task)
          else:
              was_read, task = self.read_queue.get()
          # If we reach the end of the video.
          if not was_read:
              # Put to write queue.
              with self.write_lock:
                  self.write_queue[put_id] = was_read, copy.deepcopy(
                      task
                  )
              task = None
          return was_read, task
  
imports: import atexit
  import copy
  import queue
  import threading
  import time
  import cv2
  import slowfast.utils.logging
  from slowfast.visualization.utils import TaskInfo
label_desc: Use image node_id 5 for calling the ThreadVideoManager obj's underlying member method code with example usage: obj.__next__() and returns: self,  None, was_read,  task