code: def index_labels(labels, case_sensitive=False):
      
  
      label_to_index = {}
      index_to_label = {}
  
      # If we're not case-sensitive,
      if not case_sensitive:
          labels = [str(s).lower() for s in labels]
  
      # First, build the unique label mapping
      for index, s in enumerate(sorted(set(labels))):
          label_to_index[s] = index
          index_to_label[index] = s
  
      # Remap the labels to indices
      indices = [label_to_index[s] for s in labels]
  
      # Return the converted labels, and the inverse mapping
      return indices, index_to_label
docs: Convert a list of string identifiers into numerical indices.
  
      Parameters
      ----------
      labels : list of strings, shape=(n,)
          A list of annotations, e.g., segment or chord labels from an
          annotation file.
  
      case_sensitive : bool
          Set to True to enable case-sensitive label indexing
          (Default value = False)
  
      Returns
      -------
      indices : list, shape=(n,)
          Numerical representation of ``labels``
      index_to_label : dict
          Mapping to convert numerical indices back to labels.
          ``labels[i] == index_to_label[indices[i]]``