class_docstr: Support for pyAV as backend.
  
  Parameters
  ----------
  request : iio.Request
      A request object that represents the users intent. It provides a
      standard interface to access various the various ImageResources and
      serves them to the plugin as a file object (or file). Check the docs for
      details.
class_docstr_tok: ["Support","for","pyAV","as","backend",".","Parameters","--","--","--","--","--","request",":","iio.Request","A","request","object","that","represents","the","users","intent",".","It","provides","a","standard","interface","to","access","various","the","various","ImageResources","and","serves","them","to","the","plugin","as","a","file","object","(","or","file",")",".","Check","the","docs","for","details","."]
docstr: Seeks to the frame at the given index.
docstr_tok: ["Seeks","to","the","frame","at","the","given","index","."]
code: def _seek(
      self, index, *, constant_framerate: bool = True
  ) -> Generator:
      """Seeks to the frame at the given index."""
  
      if index == self._next_idx:
          return  # fast path :)
  
      # we must decode at least once before we seek otherwise the
      # returned frames become corrupt.
      if self._next_idx == 0:
          next(self._decoder)
          self._next_idx += 1
  
          if index == self._next_idx:
              return  # fast path :)
  
      # remove this branch until I find a way to efficiently find the next
      # keyframe. keeping this as a reminder
      # if self._next_idx < index and index < self._next_keyframe_idx:
      #     frames_to_yield = index - self._next_idx
      if not constant_framerate and index > self._next_idx:
          frames_to_yield = index - self._next_idx
      elif not constant_framerate:
          # seek backwards and can't link idx and pts
          self._container.seek(0)
          self._decoder = self._container.decode(video=0)
          self._next_idx = 0
  
          frames_to_yield = index
      else:
          # we know that the time between consecutive frames is constant
          # hence we can link index and pts
  
          # how many pts lie between two frames
          sec_delta = 1 / self._video_stream.guessed_rate
          pts_delta = sec_delta / self._video_stream.time_base
  
          index_pts = int(index * pts_delta)
  
          # this only seeks to the closed (preceeding) keyframe
          self._container.seek(index_pts, stream=self._video_stream)
          self._decoder = self._container.decode(video=0)
  
          # this may be made faster if we could get the keyframe's time without
          # decoding it
          keyframe = next(self._decoder)
          keyframe_time = keyframe.pts * keyframe.time_base
          keyframe_pts = int(
              keyframe_time / self._video_stream.time_base
          )
          keyframe_index = keyframe_pts // pts_delta
  
          self._container.seek(index_pts, stream=self._video_stream)
          self._next_idx = keyframe_index
  
          frames_to_yield = index - keyframe_index
  
      for _ in range(frames_to_yield):
          next(self._decoder)
          self._next_idx += 1
  
imports: from fractions import Fraction
  from math import ceil
  from typing import Any, Dict, List, Optional, Tuple, Union, Generator
  import av
  import av.filter
  import numpy
  from numpy.lib.stride_tricks import as_strided
  from ..core import Request
  from ..core.request import URI_BYTES, InitializationError, IOMode
  from ..core.v3_plugin_api import ImageProperties, PluginV3
label_desc: Use image node_id 15 for calling the PyAVPlugin obj's underlying member method code with example usage: obj._seek(index) without return types