code: def __init__(self, root_dir, local_rank):
      super(MXFaceDataset, self).__init__()
      self.transform = transforms.Compose(
          [
              transforms.ToPILImage(),
              transforms.RandomHorizontalFlip(),
              transforms.ToTensor(),
              transforms.Normalize(
                  mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]
              ),
          ]
      )
      self.root_dir = root_dir
      self.local_rank = local_rank
      path_imgrec = os.path.join(root_dir, "train.rec")
      path_imgidx = os.path.join(root_dir, "train.idx")
      self.imgrec = mx.recordio.MXIndexedRecordIO(
          path_imgidx, path_imgrec, "r"
      )
      s = self.imgrec.read_idx(0)
      header, _ = mx.recordio.unpack(s)
      # print('ddd1')
      if header.flag > 0:
          if len(header.label) == 2:
              self.header0 = (
                  int(header.label[0]),
                  int(header.label[1]),
              )
              self.imgidx = np.array(range(1, int(header.label[0])))
          else:
              self.imgidx = np.array(list(self.imgrec.keys))
      else:
          self.imgidx = np.array(list(self.imgrec.keys))
  
imports: import numbers
  import os
  import queue
  import threading
  import mxnet
  import numpy
  import torch
  from torch.utils.data import DataLoader, Dataset
  from torchvision import transforms
label_desc: Use image node_id 1 to create a new MXFaceDataset object from inherited base classes: Dataset with example: obj = MXFaceDataset(root_dir, local_rank)