code: def GenIdx(train_vis_label, train_nir_label):
      def get_idx_from_label(train_label):
          pos = []
          unique_train_label = np.unique(train_label)
          for ul in unique_train_label:
              tmp = np.argwhere(train_label == ul).squeeze().tolist()
              if isinstance(tmp, int):
                  tmp = [tmp]
              pos.append(tmp)
          return pos
  
      vis_pos = get_idx_from_label(train_vis_label)
      nir_pos = get_idx_from_label(train_nir_label)
  
      return vis_pos, nir_pos
  
imports: from PIL import Image
  import os
  import torch.utils.data
  import torchvision.transforms
  from torch.utils.data.sampler import Sampler
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: GenIdx(train_vis_label, train_nir_label) and returns: vis_pos,  nir_pos, pos