code: def convert_categories(df, categorical_cols: List[str] = []):
      """
      Converts columns to numeric categories. If the categorical_cols
          parameter is passed as a list then those columns are converted.
          Otherwise, all np.object columns are converted.
  
      :Example:
  
      import xai
      cat_df = xai.convert_categories(df)
  
      :param df: Pandas Dataframe containing data (inputs and target)
      :type df: pandas.DataFrame
      :param categorical_cols: List of strings containing categorical cols
      :type categorical_cols: str
      :returns: Dataframe with categorical numerical values.
      :rtype: pandas.DataFrame
  
      """
      tmp_df = df.copy()
  
      if not len(categorical_cols):
          categorical_cols = df.select_dtypes(
              include=[np.object, np.bool]
          ).columns
  
      tmp_df[categorical_cols] = tmp_df[categorical_cols].astype(
          "category"
      )
      tmp_df[categorical_cols] = tmp_df[categorical_cols].apply(
          lambda x: x.cat.codes
      )
      tmp_df[categorical_cols] = tmp_df[categorical_cols].astype("int8")
  
      return tmp_df
  
imports: import pandas
  import matplotlib.pyplot
  import numpy
  from scipy.stats import spearmanr
  from scipy.cluster import hierarchy
  from typing import List, Any, Union, Tuple, Optional, Dict
  import random, math
  from sklearn.metrics import roc_curve, precision_recall_curve, roc_auc_score, confusion_matrix
  import itertools
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: convert_categories(df, categorical_cols) and returns: tmp_df