code: def assure_all_labels_occur_numpy(y, num_classes, multi_label=False):
      """Enforces that all labels occur in the data."""
  
      if multi_label:
          y = csr_to_list(y)
  
      label_list = [
          labels
          for labels in y
          if isinstance(labels, int)
          or (isinstance(labels, list) and len(labels) > 0)
      ]
      if len(label_list) == 0:
          return y
  
      if not np.all(
          [isinstance(element, int) for element in label_list]
      ):
          all_labels = np.concatenate(label_list, dtype=int)
          all_labels = all_labels.flatten()
      else:
          all_labels = np.array(label_list)
  
      hist = _get_class_histogram(all_labels, num_classes)
      missing_labels = np.arange(hist.shape[0])[hist == 0]
  
      for i, label_idx in enumerate(missing_labels):
          if multi_label:
              y[i] = y[i][:-1] + (
                  np.sort(np.append(y[i][-1], [label_idx])),
              )
          else:
              y[i] = y[i][:-1] + (label_idx,)
  
      if multi_label:
          y = list_to_csr(y, (len(y), num_classes))
  
      return y
  
imports: import string
  import numpy
  from collections import Counter
  from scipy import sparse
  from sklearn.datasets import fetch_20newsgroups
  from small_text.data.datasets import SklearnDataset, TextDataset
  from small_text.data.sampling import _get_class_histogram
  from small_text.utils.labels import csr_to_list, list_to_csr
label_desc: Use image node_id 10 for calling a global function with example usage: assure_all_labels_occur_numpy(y, num_classes, multi_label) and returns: y, y