class_docstr: Load your own video classification dataset.
code: def __getitem__(self, index):
      if self.mode == "train":
          if self.use_multigrid is True:
              index, alpha, beta = index
              info = self.mg_helper.get_resize(alpha, beta)
              scale_t = info[0]
              data_transform_func = self.data_transform[alpha][beta]
          else:
              scale_t = 1
              data_transform_func = self.data_transform
  
          sample = self.dataset_samples[index]
          buffer = self.loadvideo_decord(
              sample, sample_rate_scale=scale_t
          )
          if len(buffer) == 0:
              while len(buffer) == 0:
                  warnings.warn(
                      "video {} not correctly loaded during training".format(
                          sample
                      )
                  )
                  index = np.random.randint(self.__len__())
                  sample = self.dataset_samples[index]
                  buffer = self.loadvideo_decord(
                      sample, sample_rate_scale=scale_t
                  )
  
          buffer = data_transform_func(buffer)
          buffer = self.data_transform_after(buffer)
          return (
              buffer,
              self.label_array[index],
              sample.split("/")[-1].split(".")[0],
          )
  
      elif self.mode == "validation":
          sample = self.dataset_samples[index]
          buffer = self.loadvideo_decord(sample)
          if len(buffer) == 0:
              while len(buffer) == 0:
                  warnings.warn(
                      "video {} not correctly loaded during validation".format(
                          sample
                      )
                  )
                  index = np.random.randint(self.__len__())
                  sample = self.dataset_samples[index]
                  buffer = self.loadvideo_decord(sample)
          buffer = self.data_transform(buffer)
          return (
              buffer,
              self.label_array[index],
              sample.split("/")[-1].split(".")[0],
          )
  
      elif self.mode == "test":
          sample = self.test_dataset[index]
          chunk_nb, split_nb = self.test_seg[index]
          buffer = self.loadvideo_decord(sample)
  
          while len(buffer) == 0:
              warnings.warn(
                  "video {}, temporal {}, spatial {} not found during testing".format(
                      str(self.test_dataset[index]), chunk_nb, split_nb
                  )
              )
              index = np.random.randint(self.__len__())
              sample = self.test_dataset[index]
              chunk_nb, split_nb = self.test_seg[index]
              buffer = self.loadvideo_decord(sample)
  
          buffer = self.data_resize(buffer)
          if isinstance(buffer, list):
              buffer = np.stack(buffer, 0)
  
          spatial_step = (
              1.0
              * (
                  max(buffer.shape[1], buffer.shape[2])
                  - self.short_side_size
              )
              / (self.test_num_crop - 1)
          )
          temporal_step = max(
              1.0
              * (buffer.shape[0] - self.clip_len)
              / (self.test_num_segment - 1),
              0,
          )
          temporal_start = int(chunk_nb * temporal_step)
          spatial_start = int(split_nb * spatial_step)
          if buffer.shape[1] >= buffer.shape[2]:
              buffer = buffer[
                  temporal_start : temporal_start + self.clip_len,
                  spatial_start : spatial_start + self.short_side_size,
                  :,
                  :,
              ]
          else:
              buffer = buffer[
                  temporal_start : temporal_start + self.clip_len,
                  :,
                  spatial_start : spatial_start + self.short_side_size,
                  :,
              ]
  
          buffer = self.data_transform(buffer)
          return (
              buffer,
              self.test_label_array[index],
              sample.split("/")[-1].split(".")[0],
              chunk_nb,
              split_nb,
          )
      else:
          raise NameError("mode {} unkown".format(self.mode))
  
file_path: gluon-cv/gluoncv/torch/data/video_cls/dataset_classification.py
imports: import os
  import warnings
  import numpy
  import torch
  from torch.utils.data import Dataset
  from ..transforms.videotransforms import video_transforms, volume_transforms
  from .multigrid_helper import multiGridHelper, MultiGridBatchSampler
label_desc: Use image node_id 2 for calling the VideoClsDataset obj's underlying member method code with example usage: obj.__getitem__(index) and returns: buffer,  self,  sample, buffer,  self,  sample, buffer,  self,  sample,  chunk_nb,  split_nb