class_docstr: Implementation of VideoLoader.
  
  The VideoLoader is a wrapper around the torchvision video interface. With
  the VideoLoader you can read specific frames or the next frames of a video.
  It automatically switches to the `video_loader` backend if available. Reading
  sequential frames is significantly faster since it uses the VideoReader
  class from torchvision.
  
  The video loader automatically detects if you read out subsequent frames and
  will use the fast read method if possible.
  
  Attributes:
      path:
          Root directory path.
      timestamps:
          Function that loads file at path.
      backend:
          Tuple of allowed extensions.
      transform:
          Function that takes a PIL image and returns transformed version
      target_transform:
          As transform but for targets
      is_valid_file:
          Used to check corrupt files
      eps:
          Small value to account for floating point imprecisions.
  
  Examples:
      >>> from torchvision import io
      >>>
      >>> # get timestamps
      >>> ts, fps = io.read_video_timestamps('myvideo.mp4', pts_unit = 'sec')
      >>>
      >>> # create a VideoLoader
      >>> video_loader = VideoLoader('myvideo.mp4', ts)
      >>>
      >>> # get frame at specific timestamp
      >>> frame = video_loader.read_frame(ts[21])
      >>>
      >>> # get next frame
      >>> frame = video_loader.read_frame()
class_docstr_tok: ["Implementation","of","VideoLoader",".","The","VideoLoader","is","a","wrapper","around","the","torchvision","video","interface",".","With","the","VideoLoader","you","can","read","specific","frames","or","the","next","frames","of","a","video",".","It","automatically","switches","to","the","`","video_loader","`","backend","if","available",".","Reading","sequential","frames","is","significantly","faster","since","it","uses","the","VideoReader","class","from","torchvision",".","The","video","loader","automatically","detects","if","you","read","out","subsequent","frames","and","will","use","the","fast","read","method","if","possible",".","Attributes",":","path",":","Root","directory","path",".","timestamps",":","Function","that","loads","file","at","path",".","backend",":","Tuple","of","allowed","extensions",".","transform",":","Function","that","takes","a","PIL","image","and","returns","transformed","version","target_transform",":","As","transform","but","for","targets","is_valid_file",":","Used","to","check","corrupt","files","eps",":","Small","value","to","account","for","floating","point","imprecisions",".","Examples",":",">",">",">","from","torchvision","import","io",">",">",">",">",">",">","#","get","timestamps",">",">",">","ts",",","fps","=","io.read_video_timestamps","(","'myvideo.mp4","'",",","pts_unit","=","'sec","'",")",">",">",">",">",">",">","#","create","a","VideoLoader",">",">",">","video_loader","=","VideoLoader","(","'myvideo.mp4","'",",","ts",")",">",">",">",">",">",">","#","get","frame","at","specific","timestamp",">",">",">","frame","=","video_loader.read_frame","(","ts","[","21","]",")",">",">",">",">",">",">","#","get","next","frame",">",">",">","frame","=","video_loader.read_frame","(",")"]
code: def __init__(
      self,
      path: str,
      timestamps: List[float],
      backend: str = "video_reader",
      eps: float = 1e-6,
  ):
      self.path = path
      self.timestamps = timestamps
      self.current_index = None
      self.pts_unit = "sec"
      self.backend = backend
      self.eps = eps
  
      has_video_reader = io._HAS_VIDEO_OPT and hasattr(
          io, "VideoReader"
      )
  
      if has_video_reader and self.backend == "video_reader":
          self.reader = io.VideoReader(path=self.path)
      else:
          self.reader = None
  
imports: import os
  import threading
  import warnings
  import weakref
  from fractions import Fraction
  from typing import Any, Dict, List, Tuple
  import numpy
  import torch
  import torchvision
  from PIL import Image
  from torch.utils.data import DataLoader, Dataset
  from torchvision import datasets, io
  from tqdm import tqdm
label_desc: Use image node_id 1 to create a new VideoLoader object from inherited base classes: threading with example: obj = VideoLoader(path, timestamps, backend, eps)