code: def read_data(opt, video_name, transform, video_utils):
      decord = try_import_decord()
      decord_vr = decord.VideoReader(
          video_name, width=opt.new_width, height=opt.new_height
      )
      duration = len(decord_vr)
  
      opt.skip_length = opt.new_length * opt.new_step
      segment_indices, skip_offsets = video_utils._sample_test_indices(
          duration
      )
  
      if opt.video_loader:
          if opt.slowfast:
              clip_input = (
                  video_utils._video_TSN_decord_slowfast_loader(
                      video_name,
                      decord_vr,
                      duration,
                      segment_indices,
                      skip_offsets,
                  )
              )
          else:
              clip_input = video_utils._video_TSN_decord_batch_loader(
                  video_name,
                  decord_vr,
                  duration,
                  segment_indices,
                  skip_offsets,
              )
      else:
          raise RuntimeError("We only support video-based inference.")
  
      clip_input = transform(clip_input)
  
      if opt.slowfast:
          sparse_sampels = len(clip_input) // (
              opt.num_segments * opt.num_crop
          )
          clip_input = np.stack(clip_input, axis=0)
          clip_input = clip_input.reshape(
              (-1,)
              + (sparse_sampels, 3, opt.input_size, opt.input_size)
          )
          clip_input = np.transpose(clip_input, (0, 2, 1, 3, 4))
      else:
          clip_input = np.stack(clip_input, axis=0)
          clip_input = clip_input.reshape(
              (-1,)
              + (opt.new_length, 3, opt.input_size, opt.input_size)
          )
          clip_input = np.transpose(clip_input, (0, 2, 1, 3, 4))
  
      if opt.new_length == 1:
          clip_input = np.squeeze(
              clip_input, axis=2
          )  # this is for 2D input case
  
      return nd.array(clip_input)
  
file_path: gluon-cv/scripts/action-recognition/inference.py
imports: import os
  import time
  import argparse
  import logging
  import gc
  from gluoncv.utils.filesystem import try_import_decord
  import numpy
  import mxnet
  from mxnet import nd
  from mxnet.gluon.data.vision import transforms
  from gluoncv.data import Kinetics400Attr, UCF101Attr, SomethingSomethingV2Attr, HMDB51Attr, VideoClsCustom
  from gluoncv.data.transforms import video
  from gluoncv.model_zoo import get_model
  from gluoncv.utils import makedirs
label_desc: Use image node_id 2 for calling a global function with example usage: read_data(opt, video_name, transform, video_utils) and returns: nd