code: def generate_places_low_shot_samples(
      targets, k_values, sample_inds, output_path, images_data_file
  ):
      logging.info("Generating low-shot samples for places data...")
      k_values = [int(val) for val in k_values]
  
      logging.info(f"Loading images data file: {images_data_file}")
      images = load_file(images_data_file)
      # get the maximum and minumum number of positives per class
      num_pos = find_num_positives(targets)
      logging.info(
          f"min #num_pos: {min(num_pos)}, max #num_pos: {max(num_pos)}"
      )
  
      # start sampling now. the way sampling works is:
      # for each independent sample, and a given k value,
      # we create an output targets vector of shape same as the input targets.
      # We initialize this matrix with -1 (ignore values). We sample k positive
      # for each given class and set the value in the matrix to the class number.
      # Thus the resulting matrix has (k * num_classes) samples sampled and
      # remaining are ignored.
      for idx in sample_inds:
          for k in k_values:
              if k > min(num_pos):
                  logging.info(f"Skip k: {k} min #pos: {min(num_pos)}")
                  continue
              logging.info(f"Sampling: {idx} time for k-value: {k}")
              out_lbls = np.ones(targets.shape, dtype=np.int32) * -1
              out_imgs, out_lbls = sample_places_data(
                  images, targets, k
              )
              out_img_file = (
                  f"{output_path}/train_images_sample{idx}_k{k}.npy"
              )
              out_lbls_file = (
                  f"{output_path}/train_labels_sample{idx}_k{k}.npy"
              )
              logging.info(
                  f"Saving imgs file: {out_img_file} {len(out_imgs)}"
              )
              logging.info(
                  f"Saving lbls file: {out_lbls_file} {len(out_lbls)}"
              )
              save_file(out_lbls, out_lbls_file)
              save_file(out_imgs, out_img_file)
      logging.info("Done!!")
  
file_path: vissl/extra_scripts/create_low_shot_samples.py
imports: import argparse
  import logging
  import random
  import numpy
  from iopath.common.file_io import g_pathmgr
  from vissl.utils.io import load_file, save_file
label_desc: Use image node_id 5 for calling a global function with example usage: generate_places_low_shot_samples(targets, k_values, sample_inds, output_path, images_data_file) without return types