code: def draw_distplot_hv(
      dft,
      cats,
      conti,
      chart_format,
      problem_type,
      dep=None,
      classes=None,
      mk_dir="AutoViz_Plots",
      verbose=0,
  ):
      ensure_hvplot_imported()
      dft = copy.deepcopy(dft)
      image_count = 0
      imgdata_list = list()
      #### Since we are making changes to dft and classes, we will be making copies of it here
      conti = list(set(conti))
      nums = copy.deepcopy(conti)
      classes = copy.deepcopy(classes)
      colors = cycle("brycgkbyrcmgkbyrcmgkbyrcmgkbyr")
      imgdata_list = list()
      width_size = 600  #### this is to control the width of chart as well as number of categories to display
      height_size = 400
      gap = 0.4  #### This controls the space between rows  ######
      plot_name = "distplots"
      ###################################################################################
      if dep == None or dep == "" or problem_type == "Regression":
          ######### This is for Regression problems only ########
          transparent = 0.7
          binsize = 30
          ### Be very careful with the next 2 lines: we want to fill NA with 0 in numeric vars
          for each_conti, k in zip(conti, range(len(conti))):
              if dft[each_conti].isnull().sum() > 0:
                  ### Remember that fillna only works at dataframe level! ###
                  dft[[each_conti]] = dft[[each_conti]].fillna(0)
          ## In this case, we perform this only if we have Cat variables
          if not isinstance(dep, list):
              ### it means dep is a string ###
              if dep == "":
                  pass
              elif len(cats) > 0:
                  colors = cycle("brycgkbyrcmgkbyrcmgkbyrcmgkbyr")
  
                  def select_widget(each_cat):
                      """
                      This program must take in a variable passed from the widget and turn it into a chart.
                      The input is known as each_cat and it is the variable you must use to get the data and build a chart.
                      The output must return a HoloViews Chart.
                      """
                      width_size = 15
                      #######  This is where you plot the histogram of categorical variable input as each_cat ####
                      conti_df = (
                          dft[[dep, each_cat]]
                          .groupby(each_cat)
                          .mean()
                          .reset_index()
                      )
                      row_ticks = dft[dep].unique().tolist()
                      color_list = next(colors)
                      pivotdf = pd.DataFrame(
                          conti_df.to_records()
                      ).set_index(each_cat)
                      plot = pivotdf.hvplot(
                          kind="bar",
                          stacked=False,
                          use_index=False,
                          color=color_list,
                          title="Mean Target = %s by each Categorical Variable"
                          % dep,
                      ).opts(xrotation=70)
                      return plot
  
                  #######  This is where you call the widget and pass it the select_variable to draw a Chart #######
                  dmap = hv.DynamicMap(
                      select_widget, kdims=["Select_Cat_Variable"]
                  ).redim.values(Select_Cat_Variable=cats)
                  dmap.opts(
                      framewise=True, axiswise=True
                  )  ## both must be True for your charts to have dynamically varying axes!
                  ###########  This is where you put the Panel Together ############
                  hv_panel = pn.panel(dmap)
                  widgets = hv_panel[0]
                  hv_all = pn.Column(pn.Row(*widgets))
                  if verbose == 2:
                      imgdata_list = append_panels(
                          hv_panel, imgdata_list, chart_format
                      )
                      image_count += 1
                  if chart_format in [
                      "server",
                      "bokeh_server",
                      "bokeh-server",
                  ]:
                      # server = pn.serve(hv_all, start=True, show=True)
                      print("%s can be found in URL below:" % plot_name)
                      hv_all.show()
                  elif chart_format == "html":
                      save_html_data(
                          hv_all,
                          chart_format,
                          plot_name,
                          mk_dir,
                          additional="_cats",
                      )
                  else:
                      display(
                          hv_all
                      )  ### This will display it in a Jupyter Notebook. If you want it on a server, you use drawobj.show()
                      # display_obj(hv_all)  ### This will display it in a Jupyter Notebook. If you want it on a server, you use drawobj.show()
          if len(conti) > 0:
              try:
                  ######   This is a Very Complex Way to build an ND Overlay Chart with One Variable as a Select Variable #######
                  jitter = 0.5
                  colors = cycle("brycgkbyrcmgkbyrcmgkbyrcmgkbyr")
                  transparent = 0.5
  
                  def select_variable_to_plot(num_var):
                      """
                      This program must take in a variable passed from the widget and turn it into a chart.
                      The input is known as num_var and it is the variable you must use to get the data and build a chart.
                      The output must return a HoloViews Chart.
                      """
                      color = next(colors)
                      xlimi = (dft[num_var].min(), dft[num_var].max())
                      hv_look = (
                          hv.Distribution(
                              np.histogram(dft[num_var]), num_var
                          )
                          .opts(
                              color=color,
                              height=height_size,
                              width=width_size,
                              alpha=transparent,
                              title="KDE (Distribution) Plot of Numeric Variables",
                          )
                          .redim.range(num_var=xlimi)
                      )
                      return hv_look
  
                  #######  This is where you call the widget and pass it the select_variable to draw a Chart #######
                  dmap = hv.DynamicMap(
                      select_variable_to_plot, kdims=["Select_Variable"]
                  ).redim.values(Select_Variable=nums)
                  dmap.opts(
                      framewise=True, axiswise=True
                  )  ## both must be True for your charts to have dynamically varying axes!
                  ###########  This is where you put the Panel Together ############
                  hv_panel = pn.panel(dmap)
                  widgets = hv_panel[0]
                  hv_all = pn.Column(pn.Row(*widgets))
              except:
                  print("Error in Distribution Plot")
                  hv_panel = []
          if verbose == 2:
              imgdata_list = append_panels(
                  hv_panel, imgdata_list, chart_format
              )
              image_count += 1
          if chart_format in ["server", "bokeh_server", "bokeh-server"]:
              # server = pn.serve(hv_all, start=True, show=True)
              print("%s can be found in URL below:" % plot_name)
              hv_all.show()
          elif chart_format == "html":
              save_html_data(
                  hv_all,
                  chart_format,
                  plot_name,
                  mk_dir,
                  additional="_nums",
              )
          else:
              display(
                  hv_all
              )  ### This will display it in a Jupyter Notebook. If you want it on a server, you use drawobj.show()
              # display_obj(hv_all)  ### This will display it in a Jupyter Notebook. If you want it on a server, you use drawobj.show()
      else:
          ######### This is for Classification problems only ########
          transparent = 0.7
          binsize = 30
          alpha = 0.5
          height_size = 400
          width_size = 600
          ### Be very careful with the next 2 lines: we want to fill NA with 0 in numeric vars
          target_vars = dft[dep].unique().tolist()
          if type(classes[0]) == int:
              classes = [str(x) for x in classes]
          for each_conti, k in zip(conti, range(len(conti))):
              if dft[each_conti].isnull().sum() > 0:
                  ## fillna only works on a dataframe level - it also doesnt do inplace! ###
                  dft[[each_conti]] = dft[[each_conti]].fillna(0)
          if len(cats) > 0:
  
              def select_widget(Select_categorical_var):
                  """
                  This program must take in a variable passed from the widget and turn it into a chart.
                  The input is known as num_var and it is the variable you must use to get the data and build a chart.
                  The output must return a HoloViews Chart.
                  """
                  colors = cycle("brycgkbyrcmgkbyrcmgkbyrcmgkbyr")
                  #######  This is where you plot the histogram of categorical variable input as each_cat ####
                  conti_df = (
                      dft[[dep, Select_categorical_var]]
                      .groupby([dep, Select_categorical_var])
                      .size()
                      .nlargest(width_size)
                      .reset_index(name="Values")
                  )
                  pivot_df = conti_df.pivot(
                      index=Select_categorical_var,
                      columns=dep,
                      values="Values",
                  ).fillna(0)
                  row_ticks = dft[dep].unique().tolist()
                  color_list = []
                  for i in range(len(row_ticks)):
                      color_list.append(next(colors))
                  pivotdf = pd.DataFrame(
                      pivot_df.to_records()
                  ).set_index(Select_categorical_var)
                  plot = pivotdf.hvplot(
                      kind="bar",
                      stacked=True,
                      use_index=True,
                      title="Target = %s Histogram by each Categorical Variable"
                      % dep,
                  ).opts(
                      height=height_size, width=width_size, xrotation=70
                  )
                  return plot
  
              #######  This is where you call the widget and pass it the select_variable to draw a Chart #######
              dmap = hv.DynamicMap(
                  select_widget, kdims=["Select_categorical_var"]
              ).redim.values(Select_categorical_var=cats)
              ###########  This is where you put the Panel Together ############
              hv_panel = pn.panel(dmap)
              widgets = hv_panel[0]
              hv_all = pn.Column(pn.Row(*widgets))
              if verbose == 2:
                  imgdata_list = append_panels(
                      hv_panel, imgdata_list, chart_format
                  )
                  image_count += 1
              if chart_format in [
                  "server",
                  "bokeh_server",
                  "bokeh-server",
              ]:
                  # server = pn.serve(hv_all, start=True, show=True)
                  print("%s can be found in URL below:" % plot_name)
                  hv_all.show()
              elif chart_format == "html":
                  save_html_data(
                      hv_all,
                      chart_format,
                      plot_name,
                      mk_dir,
                      additional="_cats",
                  )
              else:
                  display(
                      hv_all
                  )  ### This will display it in a Jupyter Notebook. If you want it on a server, you use drawobj.show()
                  # display_obj(hv_all)  ### This will display it in a Jupyter Notebook. If you want it on a server, you use drawobj.show()
          if len(conti) > 0:
              try:
                  ######   This is a Very Complex Way to build an ND Overlay Chart with One Variable as a Select Variable #######
                  colortext = "brycgkbyrcmgkbyrcmgkbyrcmgkbyr"
                  target_vars = dft[dep].unique().tolist()
                  color_list = list(colortext[: len(target_vars)])
                  jitter = 0.5
                  colors = cycle("brycgkbyrcmgkbyrcmgkbyrcmgkbyr")
                  transparent = 0.5
  
                  def select_widget(Select_numeric_variable):
                      """
                      This program must take in a variable passed from the widget and turn it into a chart.
                      The input is known as num_var and it is the variable you must use to get the data and build a chart.
                      The output must return a HoloViews Chart.
                      """
                      color = next(colors)
                      overlay = hv.NdOverlay(
                          {
                              group: hv.Distribution(
                                  np.histogram(
                                      dft[dft[dep] == group][
                                          Select_numeric_variable
                                      ].values
                                  )
                              )
                              for i, group in enumerate(target_vars)
                          }
                      )
                      hv_look = (
                          overlay.opts(
                              opts.Distribution(
                                  alpha=0.5,
                                  height=height_size,
                                  width=width_size,
                              )
                          )
                          .opts(
                              title="KDE (Distribution) Plots of all Numeric Variables by Classes"
                          )
                          .opts(xlabel="%s" % dep)
                          .opts(ylabel="%s" % Select_numeric_variable)
                      )
                      return hv_look
  
                  #######  This is where you call the widget and pass it the select_variable to draw a Chart #######
                  dmap = hv.DynamicMap(
                      select_widget, kdims=["Select_numeric_variable"]
                  ).redim.values(Select_numeric_variable=nums)
                  ###########  This is where you put the Panel Together ############
                  hv_panel = pn.panel(dmap)
                  widgets = hv_panel[0]
                  hv_all = pn.Column(pn.Row(*widgets))
              except:
                  print("Error in Distribution Plot")
              if verbose == 2:
                  imgdata_list = append_panels(
                      hv_panel, imgdata_list, chart_format
                  )
                  image_count += 1
              if chart_format in [
                  "server",
                  "bokeh_server",
                  "bokeh-server",
              ]:
                  # server = pn.serve(hv_all, start=True, show=True)
                  print("%s can be found in URL below:" % plot_name)
                  hv_all.show()
              elif chart_format == "html":
                  save_html_data(
                      hv_all,
                      chart_format,
                      plot_name,
                      mk_dir,
                      additional="_nums",
                  )
              else:
                  display(
                      hv_all
                  )  ### This will display it in a Jupyter Notebook. If you want it on a server, you use drawobj.show()
                  # display_obj(hv_all)  ### This will display it in a Jupyter Notebook. If you want it on a server, you use drawobj.show()
      ####### End of Distplots ###########
      return hv_all
  
imports: import numpy
  import pandas
  from autoviz.AutoViz_Utils import *
  import copy
  import warnings
  import logging
  import warnings
  from sklearn.exceptions import DataConversionWarning
  import matplotlib
  import matplotlib.pyplot
  import io
  import seaborn
  import re
  import pdb
  import pprint
  import matplotlib
  from itertools import cycle, combinations
  from collections import defaultdict
  import copy
  import time
  import sys
  import random
  import xlrd
  import statsmodels
  from io import BytesIO
  import base64
  from functools import reduce
  import traceback
  import xgboost
  from xgboost.sklearn import XGBClassifier
  from xgboost.sklearn import XGBRegressor
  import os
  from .classify_method import classify_columns
label_desc: Use image node_id 14 for calling a global function with example usage: draw_distplot_hv(dft, cats, conti, chart_format, problem_type, dep, classes, mk_dir, verbose) and returns: hv_all, plot, hv_look, hv_look, plot