code: def load_train_data(data_dir):
      path_imgrec = os.path.join(data_dir, "train.rec")
      path_imgidx = path_imgrec[0:-4] + ".idx"
  
      print(
          "Loading recordio {}\n\
          Corresponding record idx is {}".format(
              path_imgrec, path_imgidx
          )
      )
  
      imgrec = recordio.MXIndexedRecordIO(
          path_imgidx, path_imgrec, "r", key_type=int
      )
  
      # Read header0 to get some info.
      identity_key_start = 0
      identity_key_end = 0
      imgidx_list = []
      id2range = {}
  
      rec0 = imgrec.read_idx(0)
      header0, img_str = recordio.unpack(rec0)
      if header0.flag > 0:
          identity_key_start = int(header0.label[0])
          identity_key_end = int(header0.label[1])
          imgidx_list = range(1, identity_key_start)
  
          # Read identity id range
          for identity in range(identity_key_start, identity_key_end):
              rec = imgrec.read_idx(identity)
              header, s = recordio.unpack(rec)
              a, b = int(header.label[0]), int(header.label[1])
              id2range[identity] = (a, b)
  
      else:
          imgidx_list = imgrec.keys
  
      return imgrec, imgidx_list
  
file_path: insightface/recognition/arcface_oneflow/tools/mx_recordio_2_ofrecord_shuffled_npart.py
imports: import os
  import sys
  import struct
  import argparse
  import numbers
  import random
  from mxnet import recordio
  import oneflow.core.record.record_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: load_train_data(data_dir) and returns: imgrec,  imgidx_list