code: def imbalance_plot(
      df: pd.DataFrame,
      *cross_cols: str,
      categorical_cols: List[str] = [],
      bins: int = 6,
      threshold: float = 0.5,
  ):
      """
      Shows the number of examples provided for each of the values across the
          product tuples in the columns provided. If you would like to do processing
          with the sub-groups created by this class please see the
          group_by_columns function.
  
      :Example:
  
      import xai
      class_counts = xai.imbalance_plot(
          df,
          "gender", "loan",
          bins=10,
          threshold=0.8)
  
      :param df: Pandas Dataframe containing data (inputs and target)
      :type df: pandas.DataFrame
      :param *cross_cols: One or more positional arguments (passed as *args) that
          are used to split the data into the cross product of their values
      :type cross_cross: List[str]
      :param categorical_cols: [Default: []] Columns within dataframe that are
          categorical. Columns that are not np.objects and are not part explicitly
          provided here will be treated as numeric, and bins will be used.
      :type categorical_cols: List[str]
      :param bins: [Default: 6] Number of bins to be used for numerical cols
      :type bins: int
      :param threshold: [Default: 0.5] Threshold to display in the chart.
      :type threshold: float
      :returns: Null
      :rtype: None
  
      """
  
      if not cross_cols:
          raise TypeError(
              "imbalance_plot requires at least 1 string column name"
          )
  
      grouped = group_by_columns(
          df,
          list(cross_cols),
          bins=bins,
          categorical_cols=categorical_cols,
      )
  
      grouped_col = grouped[cross_cols[0]]
      count_grp = grouped_col.count()
      count_max = count_grp.values.max()
      ratios = round(count_grp / count_max, 4)
      # TODO: Make threshold a minimum number of examples per class
      imbalances = ratios < threshold
  
      cm = plt.cm.get_cmap("RdYlBu_r")
      colors = [
          cm(1 - r / threshold / 2) if t else cm(0)
          for r, t in zip(ratios, imbalances)
      ]
      ax = count_grp.plot.bar(color=colors)
      lp = plt.axhline(threshold * count_max, color="r")
      lp.set_label(
          f"Threshold: {threshold*count_max:.2f} ({threshold*100:.2f}%)"
      )
      plt.legend()
      plt.show()
  
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 4 for calling a global function with example usage: imbalance_plot(df) without return types