code: def sample_by_class(data, n_samples, class_col=1, shuffle=True):
      if shuffle:
          random.shuffle(data)
      samples = {}
      for i, t in enumerate(data):
          cls = t[class_col]
          if cls not in samples:
              samples[cls] = []
          if len(samples[cls]) < n_samples:
              samples[cls].append(data[i])
      samples = sum(samples.values(), [])
      return samples
  
file_path: tensorwatch/tensorwatch/data_utils.py
imports: import random
  import scipy.spatial.distance
  import heapq
  import numpy
  import torch
label_desc: Use image node_id 4 for calling a global function with example usage: sample_by_class(data, n_samples, class_col, shuffle) and returns: samples