code: def compute_indices(
      num_frames_orig: int, num_frames_target: int, is_train: bool
  ):
      """compute indices"""
  
      def round_half_down(array: np.ndarray) -> np.ndarray:
          return np.ceil(array - 0.5)
  
      if is_train:
          # random sampling during training
          start_points = np.linspace(
              0, num_frames_orig, num_frames_target, endpoint=False
          )
          start_points = round_half_down(start_points).astype(int)
          offsets = start_points[1:] - start_points[:-1]
          np.random.shuffle(offsets)
          last_offset = num_frames_orig - np.sum(offsets)
          offsets = np.concatenate([offsets, np.array([last_offset])])
          new_start_points = np.cumsum(offsets) - offsets[0]
          offsets = np.roll(offsets, -1)
          random_offsets = offsets * np.random.rand(num_frames_target)
          indices = new_start_points + random_offsets
          indices = np.floor(indices).astype(int)
          return indices
      # center sampling during validation
      start_points = np.linspace(
          0, num_frames_orig, num_frames_target, endpoint=False
      )
      offset = num_frames_orig / num_frames_target / 2
      indices = start_points + offset
      indices = np.floor(indices).astype(int)
      return indices
  
imports: import ctypes
  import datetime
  import logging
  import multiprocessing
  import os
  from pathlib import Path
  import random
  import sys
  from typing import Tuple, Dict
  import numpy
  import torch
  import torch.backends.cudnn
  from torch import cuda
  import torch.nn.functional
label_desc: Use image node_id 6 for calling a global function with example usage: compute_indices(num_frames_orig, num_frames_target, is_train) and returns: indices, np, indices