code: def write_worker(args, q_out):
      pre_time = time.time()
  
      if args.input[-1] == "/":
          args.input = args.input[:-1]
      dirname = os.path.dirname(args.input)
      basename = os.path.basename(args.input)
      output = os.path.join(dirname, f"shuffled_{basename}")
      os.makedirs(output, exist_ok=True)
  
      path_imgidx = os.path.join(output, "train.idx")
      path_imgrec = os.path.join(output, "train.rec")
      save_record = mx.recordio.MXIndexedRecordIO(
          path_imgidx, path_imgrec, "w"
      )
      more = True
      count = 0
      while more:
          deq = q_out.get()
          if deq is None:
              more = False
          else:
              header, jpeg = mx.recordio.unpack(deq)
              # TODO it is currently not fully developed
              if isinstance(header.label, float):
                  label = header.label
              else:
                  label = header.label[0]
  
              header = mx.recordio.IRHeader(
                  flag=header.flag,
                  label=label,
                  id=header.id,
                  id2=header.id2,
              )
              save_record.write_idx(
                  count, mx.recordio.pack(header, jpeg)
              )
              count += 1
              if count % 10000 == 0:
                  cur_time = time.time()
                  print(
                      "save time:",
                      cur_time - pre_time,
                      " count:",
                      count,
                  )
                  pre_time = cur_time
      print(count)
      save_record.close()
  
file_path: insightface/recognition/arcface_torch/scripts/shuffle_rec.py
imports: import argparse
  import multiprocessing
  import os
  import time
  import mxnet
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: write_worker(args, q_out) without return types