docstr: Base video dataset.
  
  Args:
      video_source: filename of video.
      transform: transform to be applied to each frame.
      max_num_frames: Max number of frames to iterate across. If `None` is passed,
          then the dataset will iterate until the end of the file.
      color_order: Color order to return frame. Default is RGB.
      multiprocessing: If `True`, open the video source on the fly. This makes
          things process-safe, which is useful when combined with a DataLoader
          with `num_workers>0`. However, when using with `num_workers==0`, it
          makes sense to use `multiprocessing=False`, as the source will then
          only be opened once, at construction, which will be faster in those
          circumstances.
      channel_dim: OpenCV reads with the channel as the last dimension. Use this
          flag to move it elsewhere. By default this is zero, so the channel
          dimension is moved to the front.
  
  Raises:
      RuntimeError: OpenCV not installed.
      NotImplementedError: Unknown color order.
docstr_tok: ["Base","video","dataset",".","Args",":","video_source",":","filename","of","video",".","transform",":","transform","to","be","applied","to","each","frame",".","max_num_frames",":","Max","number","of","frames","to","iterate","across",".","If","`","None","`","is","passed",",","then","the","dataset","will","iterate","until","the","end","of","the","file",".","color_order",":","Color","order","to","return","frame",".","Default","is","RGB",".","multiprocessing",":","If","`","True","`",",","open","the","video","source","on","the","fly",".","This","makes","things","process-safe",",","which","is","useful","when","combined","with","a","DataLoader","with","`","num_workers",">","0","`",".","However",",","when","using","with","`","num_workers==0","`",",","it","makes","sense","to","use","`","multiprocessing=False","`",",","as","the","source","will","then","only","be","opened","once",",","at","construction",",","which","will","be","faster","in","those","circumstances",".","channel_dim",":","OpenCV","reads","with","the","channel","as","the","last","dimension",".","Use","this","flag","to","move","it","elsewhere",".","By","default","this","is","zero",",","so","the","channel","dimension","is","moved","to","the","front",".","Raises",":","RuntimeError",":","OpenCV","not","installed",".","NotImplementedError",":","Unknown","color","order","."]
code: def __init__(
      self,
      video_source: str | int,
      transform: Callable | None = None,
      max_num_frames: int | None = None,
      color_order: str = ColorOrder.RGB,
      multiprocessing: bool = False,
      channel_dim: int = 0,
  ) -> None:
      """
      Base video dataset.
  
      Args:
          video_source: filename of video.
          transform: transform to be applied to each frame.
          max_num_frames: Max number of frames to iterate across. If `None` is passed,
              then the dataset will iterate until the end of the file.
          color_order: Color order to return frame. Default is RGB.
          multiprocessing: If `True`, open the video source on the fly. This makes
              things process-safe, which is useful when combined with a DataLoader
              with `num_workers>0`. However, when using with `num_workers==0`, it
              makes sense to use `multiprocessing=False`, as the source will then
              only be opened once, at construction, which will be faster in those
              circumstances.
          channel_dim: OpenCV reads with the channel as the last dimension. Use this
              flag to move it elsewhere. By default this is zero, so the channel
              dimension is moved to the front.
  
      Raises:
          RuntimeError: OpenCV not installed.
          NotImplementedError: Unknown color order.
      """
      if not has_cv2:
          raise RuntimeError("OpenCV not installed.")
      if color_order not in ColorOrder:
          raise NotImplementedError
  
      self.color_order = color_order
      self.channel_dim = channel_dim
      self.video_source = video_source
      self.multiprocessing = multiprocessing
      if not multiprocessing:
          self.cap = self.open_video(video_source)
      self.transform = transform
      self.max_num_frames = max_num_frames
  
imports: from __future__ import annotations
  import os
  import sys
  import tempfile
  from collections.abc import Callable
  from typing import TYPE_CHECKING, Any
  import numpy
  from torch.utils.data import Dataset, IterableDataset
  from monai.utils.enums import ColorOrder
  from monai.utils.module import optional_import
label_desc: Use image node_id 1 to create a new VideoDataset object  with example: obj = VideoDataset(video_source, transform, max_num_frames, color_order, multiprocessing, channel_dim)