code: def extract_train(
      tar_fname, target_dir, with_rec=False, num_thread=1
  ):
      os.makedirs(target_dir)
      with tarfile.open(tar_fname) as tar:
          print("Extracting " + tar_fname + "...")
          # extract each class one-by-one
          pbar = tqdm(total=len(tar.getnames()))
          for class_tar in tar:
              pbar.set_description("Extract " + class_tar.name)
              tar.extract(class_tar, target_dir)
              class_fname = os.path.join(target_dir, class_tar.name)
              class_dir = os.path.splitext(class_fname)[0]
              os.mkdir(class_dir)
              with tarfile.open(class_fname) as f:
                  f.extractall(class_dir)
              os.remove(class_fname)
              pbar.update(1)
          pbar.close()
      if with_rec:
          build_rec_process(target_dir, True, num_thread)
  
file_path: gluon-cv/scripts/datasets/imagenet.py
imports: import os
  import argparse
  import tarfile
  import pickle
  import gzip
  import subprocess
  from tqdm import tqdm
  from mxnet.gluon.utils import check_sha1
  from gluoncv.utils import download, makedirs
label_desc: Use image node_id 4 for calling a global function with example usage: extract_train(tar_fname, target_dir, with_rec, num_thread) without return types