code: def get_embedding(args, imgrec, a, b, image_size, model):
      ocontents = []
      for idx in range(a, b):
          s = imgrec.read_idx(idx)
          ocontents.append(s)
      embeddings = None
      # print(len(ocontents))
      ba = 0
      rlabel = -1
      imgs = []
      contents = []
      while True:
          bb = min(ba + args.batch_size, len(ocontents))
          if ba >= bb:
              break
          _batch_size = bb - ba
          # _batch_size2 = max(_batch_size, args.ctx_num)
          _batch_size2 = _batch_size
          if _batch_size % args.ctx_num != 0:
              _batch_size2 = (
                  (_batch_size // args.ctx_num) + 1
              ) * args.ctx_num
          data = np.zeros(
              (_batch_size2, 3, image_size[0], image_size[1])
          )
          count = bb - ba
          ii = 0
          for i in range(ba, bb):
              header, img = mx.recordio.unpack(ocontents[i])
              contents.append(img)
              label = header.label
              if not isinstance(label, numbers.Number):
                  label = label[0]
              if rlabel < 0:
                  rlabel = int(label)
  
              img = mx.image.imdecode(img)
              rgb = img.asnumpy()
              bgr = rgb[:, :, ::-1]
              imgs.append(bgr)
              img = rgb.transpose((2, 0, 1))
              data[ii] = img
              ii += 1
          while ii < _batch_size2:
              data[ii] = data[0]
              ii += 1
          nddata = nd.array(data)
          db = mx.io.DataBatch(data=(nddata,))
          model.forward(db, is_train=False)
          net_out = model.get_outputs()
          net_out = net_out[0].asnumpy()
          if embeddings is None:
              embeddings = np.zeros((len(ocontents), net_out.shape[1]))
          embeddings[ba:bb, :] = net_out[0:_batch_size, :]
          ba = bb
      embeddings = sklearn.preprocessing.normalize(embeddings)
      return embeddings, rlabel, contents
  
file_path: insightface/recognition/subcenter_arcface/drop.py
imports: import os
  import shutil
  import datetime
  import sys
  from mxnet import ndarray
  import mxnet
  import random
  import argparse
  import numbers
  import cv2
  import time
  import pickle
  import sklearn
  import sklearn.preprocessing
  from easydict import EasyDict
  import numpy
  from rec_builder import *
label_desc: Use image node_id 1 for calling a global function with example usage: get_embedding(args, imgrec, a, b, image_size, model) and returns: embeddings,  rlabel,  contents