code: def select_triplets(self):
      self.seq = []
      while len(self.seq) < self.seq_min_size:
          self.time_reset()
          embeddings = None
          bag_size = self.triplet_bag_size
          batch_size = self.batch_size
          # data = np.zeros( (bag_size,)+self.data_shape )
          # label = np.zeros( (bag_size,) )
          tag = []
          # idx = np.zeros( (bag_size,) )
          print("eval %d images.." % bag_size, self.triplet_cur)
          print("triplet time stat", self.times)
          if self.triplet_cur + bag_size > len(self.triplet_seq):
              self.triplet_reset()
              # bag_size = min(bag_size, len(self.triplet_seq))
              print("eval %d images.." % bag_size, self.triplet_cur)
          self.times[0] += self.time_elapsed()
          self.time_reset()
          # print(data.shape)
          data = nd.zeros(self.provide_data[0][1])
          label = None
          if self.provide_label is not None:
              label = nd.zeros(self.provide_label[0][1])
          ba = 0
          while True:
              bb = min(ba + batch_size, bag_size)
              if ba >= bb:
                  break
              _count = bb - ba
              # data = nd.zeros( (_count,)+self.data_shape )
              # _batch = self.data_iter.next()
              # _data = _batch.data[0].asnumpy()
              # print(_data.shape)
              # _label = _batch.label[0].asnumpy()
              # data[ba:bb,:,:,:] = _data
              # label[ba:bb] = _label
              for i in range(ba, bb):
                  # print(ba, bb, self.triplet_cur, i, len(self.triplet_seq))
                  _idx = self.triplet_seq[i + self.triplet_cur]
                  s = self.imgrec.read_idx(_idx)
                  header, img = recordio.unpack(s)
                  img = self.imdecode(img)
                  data[i - ba][:] = self.postprocess_data(img)
                  _label = header.label
                  if not isinstance(_label, numbers.Number):
                      _label = _label[0]
                  if label is not None:
                      label[i - ba][:] = _label
                  tag.append((int(_label), _idx))
                  # idx[i] = _idx
  
              db = mx.io.DataBatch(data=(data,))
              self.mx_model.forward(db, is_train=False)
              net_out = self.mx_model.get_outputs()
              # print('eval for selecting triplets',ba,bb)
              # print(net_out)
              # print(len(net_out))
              # print(net_out[0].asnumpy())
              net_out = net_out[0].asnumpy()
              # print(net_out)
              # print('net_out', net_out.shape)
              if embeddings is None:
                  embeddings = np.zeros((bag_size, net_out.shape[1]))
              embeddings[ba:bb, :] = net_out
              ba = bb
          assert len(tag) == bag_size
          self.triplet_cur += bag_size
          embeddings = sklearn.preprocessing.normalize(embeddings)
          self.times[1] += self.time_elapsed()
          self.time_reset()
          nrof_images_per_class = [1]
          for i in range(1, bag_size):
              if tag[i][0] == tag[i - 1][0]:
                  nrof_images_per_class[-1] += 1
              else:
                  nrof_images_per_class.append(1)
  
          triplets = self.pick_triplets(
              embeddings, nrof_images_per_class
          )  # shape=(T,3)
          print("found triplets", len(triplets))
          ba = 0
          while True:
              bb = ba + self.per_batch_size // 3
              if bb > len(triplets):
                  break
              _triplets = triplets[ba:bb]
              for i in range(3):
                  for triplet in _triplets:
                      _pos = triplet[i]
                      _idx = tag[_pos][1]
                      self.seq.append(_idx)
              ba = bb
          self.times[2] += self.time_elapsed()
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import random
  import logging
  import sys
  import numbers
  import math
  import sklearn
  import datetime
  import numpy
  import cv2
  import mxnet
  from mxnet import ndarray
  from mxnet import io
  from mxnet import recordio
  import face_preprocess
label_desc: Use image node_id 7 for calling the FaceImageIter obj's underlying member method code with example usage: obj.select_triplets() without return types