code: def main(logger):
      opt = parse_args()
      logger.info(opt)
      gc.set_threshold(100, 5, 5)
  
      if not os.path.exists(opt.save_dir):
          os.makedirs(opt.save_dir)
  
      # set env
      if opt.gpu_id == -1:
          context = mx.cpu()
      else:
          gpu_id = opt.gpu_id
          context = mx.gpu(gpu_id)
  
      # get data preprocess
      image_norm_mean = [0.485, 0.456, 0.406]
      image_norm_std = [0.229, 0.224, 0.225]
      if opt.ten_crop:
          transform_test = transforms.Compose(
              [
                  video.VideoTenCrop(opt.input_size),
                  video.VideoToTensor(),
                  video.VideoNormalize(image_norm_mean, image_norm_std),
              ]
          )
          opt.num_crop = 10
      elif opt.three_crop:
          transform_test = transforms.Compose(
              [
                  video.VideoThreeCrop(opt.input_size),
                  video.VideoToTensor(),
                  video.VideoNormalize(image_norm_mean, image_norm_std),
              ]
          )
          opt.num_crop = 3
      else:
          transform_test = video.VideoGroupValTransform(
              size=opt.input_size,
              mean=image_norm_mean,
              std=image_norm_std,
          )
          opt.num_crop = 1
  
      # get model
      if opt.use_pretrained and len(opt.hashtag) > 0:
          opt.use_pretrained = opt.hashtag
      classes = opt.num_classes
      model_name = opt.model
      net = get_model(
          name=model_name,
          nclass=classes,
          pretrained=opt.use_pretrained,
          feat_ext=True,
          num_segments=opt.num_segments,
          num_crop=opt.num_crop,
      )
      net.cast(opt.dtype)
      net.collect_params().reset_ctx(context)
      if opt.mode == "hybrid":
          net.hybridize(static_alloc=True, static_shape=True)
      if opt.resume_params != "" and not opt.use_pretrained:
          net.load_parameters(opt.resume_params, ctx=context)
          logger.info(
              "Pre-trained model %s is successfully loaded."
              % (opt.resume_params)
          )
      else:
          logger.info(
              "Pre-trained model is successfully loaded from the model zoo."
          )
      logger.info("Successfully built model {}".format(model_name))
  
      # get data
      anno_file = opt.data_list
      f = open(anno_file, "r")
      data_list = f.readlines()
      logger.info("Load %d video samples." % len(data_list))
  
      # build a pseudo dataset instance to use its children class methods
      video_utils = VideoClsCustom(
          root=opt.data_dir,
          setting=opt.data_list,
          num_segments=opt.num_segments,
          num_crop=opt.num_crop,
          new_length=opt.new_length,
          new_step=opt.new_step,
          new_width=opt.new_width,
          new_height=opt.new_height,
          video_loader=opt.video_loader,
          use_decord=opt.use_decord,
          slowfast=opt.slowfast,
          slow_temporal_stride=opt.slow_temporal_stride,
          fast_temporal_stride=opt.fast_temporal_stride,
          data_aug=opt.data_aug,
          lazy_init=True,
      )
  
      start_time = time.time()
      for vid, vline in enumerate(data_list):
          video_path = vline.split()[0]
          video_name = video_path.split("/")[-1]
          if opt.need_root:
              video_path = os.path.join(opt.data_dir, video_path)
          video_data = read_data(
              opt, video_path, transform_test, video_utils
          )
          video_input = video_data.as_in_context(context)
          video_feat = net(video_input.astype(opt.dtype, copy=False))
  
          feat_file = "%s_%s_feat.npy" % (model_name, video_name)
          np.save(
              os.path.join(opt.save_dir, feat_file),
              video_feat.asnumpy(),
          )
  
          if vid > 0 and vid % opt.log_interval == 0:
              logger.info("%04d/%04d is done" % (vid, len(data_list)))
  
      end_time = time.time()
      logger.info(
          "Total feature extraction time is %4.2f minutes"
          % ((end_time - start_time) / 60)
      )
  
file_path: gluon-cv/scripts/action-recognition/feat_extract.py
imports: import os
  import sys
  import time
  import argparse
  import logging
  import math
  import gc
  import json
  import numpy
  import mxnet
  from mxnet import nd
  from mxnet.gluon.data.vision import transforms
  from gluoncv.data.transforms import video
  from gluoncv.model_zoo import get_model
  from gluoncv.data import VideoClsCustom
  from gluoncv.utils.filesystem import try_import_decord
label_desc: Use image node_id 3 for calling a global function with example usage: main(logger) without return types