code: def read_keyframes(
      video_fpath: str,
      keyframes: FrameTsList,
      video_stream_idx: int = 0,
  ) -> FrameList:  # pyre-ignore[11]
      """
      Reads keyframe data from a video file.
  
      Args:
          video_fpath (str): Video file path
          keyframes (List[int]): List of keyframe timestamps (as counts in
              timebase units to be used in container seek operations)
          video_stream_idx (int): Video stream index (default: 0)
      Returns:
          List[Frame]: list of frames that correspond to the specified timestamps
      """
      try:
          with PathManager.open(video_fpath, "rb") as io:
              container = av.open(io)
              stream = container.streams.video[video_stream_idx]
              frames = []
              for pts in keyframes:
                  try:
                      container.seek(
                          pts, any_frame=False, stream=stream
                      )
                      frame = next(container.decode(video=0))
                      frames.append(frame)
                  except av.AVError as e:
                      logger = logging.getLogger(__name__)
                      logger.warning(
                          f"Read keyframes: Error seeking video file {video_fpath}, "
                          f"video stream {video_stream_idx}, pts {pts}, AV error: {e}"
                      )
                      container.close()
                      return frames
                  except OSError as e:
                      logger = logging.getLogger(__name__)
                      logger.warning(
                          f"Read keyframes: Error seeking video file {video_fpath}, "
                          f"video stream {video_stream_idx}, pts {pts}, OS error: {e}"
                      )
                      container.close()
                      return frames
                  except StopIteration:
                      logger = logging.getLogger(__name__)
                      logger.warning(
                          f"Read keyframes: Error decoding frame from {video_fpath}, "
                          f"video stream {video_stream_idx}, pts {pts}"
                      )
                      container.close()
                      return frames
  
              container.close()
              return frames
      except OSError as e:
          logger = logging.getLogger(__name__)
          logger.warning(
              f"Read keyframes: Error opening video file container {video_fpath}, OS error: {e}"
          )
      except RuntimeError as e:
          logger = logging.getLogger(__name__)
          logger.warning(
              f"Read keyframes: Error opening video file container {video_fpath}, Runtime error: {e}"
          )
      return []
  
file_path: detectron2/projects/DensePose/densepose/data/video/video_keyframe_dataset.py
imports: import csv
  import logging
  import numpy
  from typing import Any, Callable, Dict, List, Optional, Union
  import av
  import torch
  from torch.utils.data.dataset import Dataset
  from detectron2.utils.file_io import PathManager
  from ..utils import maybe_prepend_base_path
  from .frame_selector import FrameSelector, FrameTsList
label_desc: Use image node_id 2 for calling a global function with example usage: read_keyframes(video_fpath, keyframes, video_stream_idx) and returns: list, frames, frames, frames, frames