code: def assure_all_labels_occur(data, num_classes, multi_label=False):
      """Enforces that all labels occur in the data."""
      label_list = [
          labels
          for *_, labels in data
          if isinstance(labels, int) or len(labels) > 0
      ]
      if len(label_list) == 0:
          return data
  
      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:
              data[i] = data[i][:-1] + (
                  np.sort(np.append(data[i][-1], [label_idx])),
              )
          else:
              data[i] = data[i][:-1] + (label_idx,)
  
      return data
  
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 9 for calling a global function with example usage: assure_all_labels_occur(data, num_classes, multi_label) and returns: data, data