code: def test_accurateseek_middle(self, test_video, backend):
      torchvision.set_video_backend(backend)
      full_path = os.path.join(VIDEO_DIR, test_video)
      stream = "video"
      video_reader = VideoReader(full_path, stream)
      md = video_reader.get_metadata()
      duration = md[stream]["duration"][0]
      if duration is not None:
          num_frames = 0
          for _ in video_reader:
              num_frames += 1
  
          video_reader.seek(duration / 2)
          middle_num_frames = 0
          for _ in video_reader:
              middle_num_frames += 1
  
          assert middle_num_frames < num_frames
          assert middle_num_frames == approx(num_frames // 2, abs=1)
  
          video_reader.seek(duration / 2)
          frame = next(video_reader)
          lb = duration / 2 - 1 / md[stream]["fps"][0]
          ub = duration / 2 + 1 / md[stream]["fps"][0]
          assert (lb <= frame["pts"]) and (ub >= frame["pts"])
  
file_path: vision/test/test_videoapi.py
imports: import collections
  import os
  import urllib
  import pytest
  import torch
  import torchvision
  from pytest import approx
  from torchvision.datasets.utils import download_url
  from torchvision.io import _HAS_VIDEO_OPT, VideoReader
label_desc: Use image node_id 5 for calling the TestVideoApi obj's underlying member method code with example usage: obj.test_accurateseek_middle(test_video, backend) without return types