code: def test_compute_clips_for_video(self):
      video_pts = torch.arange(30)
      # case 1: single clip
      num_frames = 13
      orig_fps = 30
      duration = float(len(video_pts)) / orig_fps
      new_fps = 13
      clips, idxs = VideoClips.compute_clips_for_video(
          video_pts, num_frames, num_frames, orig_fps, new_fps
      )
      resampled_idxs = VideoClips._resample_video_idx(
          int(duration * new_fps), orig_fps, new_fps
      )
      assert len(clips) == 1
      assert_equal(clips, idxs)
      assert_equal(idxs[0], resampled_idxs)
  
      # case 2: all frames appear only once
      num_frames = 4
      orig_fps = 30
      duration = float(len(video_pts)) / orig_fps
      new_fps = 12
      clips, idxs = VideoClips.compute_clips_for_video(
          video_pts, num_frames, num_frames, orig_fps, new_fps
      )
      resampled_idxs = VideoClips._resample_video_idx(
          int(duration * new_fps), orig_fps, new_fps
      )
      assert len(clips) == 3
      assert_equal(clips, idxs)
      assert_equal(idxs.flatten(), resampled_idxs)
  
      # case 3: frames aren't enough for a clip
      num_frames = 32
      orig_fps = 30
      new_fps = 13
      with pytest.warns(UserWarning):
          clips, idxs = VideoClips.compute_clips_for_video(
              video_pts, num_frames, num_frames, orig_fps, new_fps
          )
      assert len(clips) == 0
      assert len(idxs) == 0
  
file_path: vision/test/test_datasets_video_utils.py
imports: import pytest
  import torch
  from common_utils import assert_equal, get_list_of_videos
  from torchvision import io
  from torchvision.datasets.video_utils import unfold, VideoClips
label_desc: Use image node_id 4 for calling the TestVideo obj's underlying member method code with example usage: obj.test_compute_clips_for_video() without return types