code: def main(args):
      # Convert recordio to ofrecord
      imgrec, imgidx_list = load_train_data(data_dir=args.data_dir)
      imgidx_list = list(imgidx_list)
      random.shuffle(imgidx_list)
  
      output_dir = os.path.join(args.output_filepath, "train")
      if not os.path.exists(output_dir):
          os.makedirs(output_dir)
      num_images = len(imgidx_list)
      num_images_per_part = (
          num_images + args.num_part
      ) // args.num_part
      print(
          "num_images",
          num_images,
          "num_images_per_part",
          num_images_per_part,
      )
  
      for part_id in range(args.num_part):
          part_name = "part-" + "{:0>5d}".format(part_id)
          output_file = os.path.join(output_dir, part_name)
          file_idx_start = part_id * num_images_per_part
          file_idx_end = min(
              (part_id + 1) * num_images_per_part, num_images
          )
          print(
              "part-" + str(part_id),
              "start",
              file_idx_start,
              "end",
              file_idx_end,
          )
          with open(output_file, "wb") as f:
              for file_idx in range(file_idx_start, file_idx_end):
                  idx = imgidx_list[file_idx]
                  if idx % 10000 == 0:
                      print(
                          "Converting images: {} of {}".format(
                              idx, len(imgidx_list)
                          )
                      )
  
                  img_data = {}
                  rec = imgrec.read_idx(idx)
                  header, s = recordio.unpack(rec)
                  label = header.label
                  if not isinstance(label, numbers.Number):
                      label = label[0]
                  img_data["label"] = int(label)
                  img_data["pixel_data"] = s
  
                  example = convert_to_ofrecord(img_data)
                  size = example.ByteSize()
                  f.write(struct.pack("q", size))
                  f.write(example.SerializeToString())
  
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 4 for calling a global function with example usage: main(args) without return types