code: def _get_class_histogram(y, num_classes, normalize=False):
      if isinstance(y, csr_matrix):
          ind, counts = np.unique(y.indices, return_counts=True)
      else:
          ind, counts = np.unique(y, return_counts=True)
      ind = set(ind)
  
      histogram = np.zeros(num_classes)
      for i, c in zip(ind, counts):
          if i in ind:
              histogram[i] = c
  
      if normalize:
          histogram = histogram / histogram.sum()
          return histogram
  
      return histogram.astype(int)
  
file_path: small-text/small_text/data/sampling.py
imports: import numpy
  from scipy.sparse import csr_matrix
  from sklearn.preprocessing import LabelEncoder
label_desc: Use image node_id 6 for calling a global function with example usage: _get_class_histogram(y, num_classes, normalize) and returns: histogram, histogram