class_docstr: Defines the top-level RAITextInsights API.
  
  Use RAITextInsights to assess text machine learning models in a
  single API.
class_docstr_tok: ["Defines","the","top-level","RAITextInsights","API",".","Use","RAITextInsights","to","assess","text","machine","learning","models","in","a","single","API","."]
docstr: Convert labels to indexes if possible.
  
  :param labels: Labels to convert.
  :type labels: list or numpy.ndarray
  :param class_names: List of class names.
  :type class_names: list
  :param unique_labels: List of unique labels.
  :type unique_labels: list
  :return: Converted labels.
  :rtype: list
docstr_tok: ["Convert","labels","to","indexes","if","possible",".",":","param","labels",":","Labels","to","convert",".",":","type","labels",":","list","or","numpy.ndarray",":","param","class_names",":","List","of","class","names",".",":","type","class_names",":","list",":","param","unique_labels",":","List","of","unique","labels",".",":","type","unique_labels",":","list",":","return",":","Converted","labels",".",":","rtype",":","list"]
code: def _convert_labels(self, labels, class_names, unique_labels=None):
      """Convert labels to indexes if possible.
  
      :param labels: Labels to convert.
      :type labels: list or numpy.ndarray
      :param class_names: List of class names.
      :type class_names: list
      :param unique_labels: List of unique labels.
      :type unique_labels: list
      :return: Converted labels.
      :rtype: list
      """
      unique_labels = unique_labels or np.unique(labels).tolist()
      if isinstance(labels[0], list):
          return [
              self._convert_labels(li, class_names, unique_labels)
              for li in labels
          ]
      is_boolean = all(isinstance(y, (bool)) for y in unique_labels)
      if is_boolean:
          labels_arr = np.array(labels)
          labels = labels_arr.astype(float).tolist()
      if class_names is not None:
          num_types = (int, float)
          is_numeric = all(
              isinstance(y, num_types) for y in unique_labels
          )
          if not is_numeric:
              labels = [class_names.index(y) for y in labels]
      return labels
  
imports: import json
  import logging
  import pickle
  import warnings
  from enum import Enum
  from pathlib import Path
  from typing import Any, List, Optional, Union
  import numpy
  import pandas
  from ml_wrappers import wrap_model
  from erroranalysis._internal.cohort_filter import FilterDataWithCohortFilters
  from raiutils.data_processing import convert_to_list, serialize_json_safe
  from raiutils.models import SKLearn, is_classifier
  from responsibleai._interfaces import Dataset, RAIInsightsData
  from responsibleai._internal.constants import ManagerNames, Metadata, SerializationAttributes
  from responsibleai.exceptions import UserConfigValidationException
  from responsibleai.feature_metadata import FeatureMetadata
  from responsibleai.rai_insights.rai_base_insights import RAIBaseInsights
  from responsibleai_text.common.constants import ModelTask
  from responsibleai_text.managers.error_analysis_manager import ErrorAnalysisManager
  from responsibleai_text.managers.explainer_manager import ExplainerManager
  from responsibleai_text.utils.feature_extractors import extract_features, get_text_columns
label_desc: Use image node_id 17 for calling the RAITextInsights obj's underlying member method code with example usage: obj._convert_labels(labels, class_names, unique_labels) and returns: labels, unknown