code: def create_pairs(x, digit_indices):
      pairs = []
      labels = []
      n = min([len(digit_indices[d]) for d in range(num_classes)]) - 1
      for d in range(num_classes):
          for i in range(n):
              z1, z2 = digit_indices[d][i], digit_indices[d][i + 1]
              pairs += [[x[z1], x[z2]]]
              inc = random.randrange(1, num_classes)
              dn = (d + inc) % num_classes
              z1, z2 = digit_indices[d][i], digit_indices[dn][i]
              pairs += [[x[z1], x[z2]]]
              labels += [1, 0]
      return np.array(pairs), np.array(labels).astype(np.float32)
  
file_path: TensorLayer/examples/basic_tutorials/tutorial_mnist_siamese.py
imports: import random
  import time
  import numpy
  import tensorflow
  import tensorlayer
  from tensorlayer.layers import Dense, Dropout, Flatten, Input
  from tensorlayer.models import Model
label_desc: Use image node_id 5 for calling a global function with example usage: create_pairs(x, digit_indices) and returns: np,  np