code: def _create_distribution_bar_graphs(
      train_column: Union[np.ndarray, pd.Series],
      test_column: Union[np.ndarray, pd.Series],
      max_num_categories: int,
      show_categories_by: CategoriesSortingKind,
      dataset_names: Tuple[str] = DEFAULT_DATASET_NAMES,
  ) -> Tuple[Any, Any]:
      """
      Create distribution bar graphs.
  
      Returns
      -------
      Tuple[Any, Any]:
          a tuple instance with figures traces, yaxis layout
      """
      (
          expected,
          actual,
          categories_list,
      ) = preprocess_2_cat_cols_to_same_bins(
          dist1=train_column,
          dist2=test_column,
      )
  
      expected_percents, actual_percents = expected / len(
          train_column
      ), actual / len(test_column)
  
      if show_categories_by == "train_largest":
          sort_func = lambda tup: tup[0]
      elif show_categories_by == "test_largest":
          sort_func = lambda tup: tup[1]
      elif show_categories_by == "largest_difference":
          sort_func = lambda tup: np.abs(tup[0] - tup[1])
      else:
          raise DeepchecksValueError(
              'show_categories_by must be either "train_largest", "test_largest" '
              f'or "largest_difference", instead got: {show_categories_by}'
          )
  
      # Sort the lists together according to the parameter show_categories_by (done by sorting zip and then using it again
      # to return the lists to the original 3 separate ones).
      # Afterwards, leave only the first max_num_categories values in each list.
      distribution = sorted(
          zip(expected_percents, actual_percents, categories_list),
          key=sort_func,
          reverse=True,
      )
      expected_percents, actual_percents, categories_list = zip(
          *distribution[:max_num_categories]
      )
  
      # fixes plotly widget bug with numpy values by converting them to native values
      # https://github.com/plotly/plotly.py/issues/3470
      cat_df = pd.DataFrame(
          {
              "Train dataset": expected_percents,
              "Test dataset": actual_percents,
          },
          index=[un_numpy(cat) for cat in categories_list],
      )
  
      # Creating sorting function which works on both numbers and strings
      def sort_int_and_strings(a, b):
          # If both numbers or both same type using regular operator
          if type(a) is type(b) or (
              isinstance(a, Number) and isinstance(b, Number)
          ):
              return -1 if a < b else 1
          # Sort numbers before strings
          return -1 if isinstance(a, Number) else 1
  
      cat_df = cat_df.reindex(
          sorted(cat_df.index, key=cmp_to_key(sort_int_and_strings))
      )
  
      traces = [
          go.Bar(
              x=cat_df.index,
              y=cat_df["Train dataset"],
              marker=dict(color=colors[DEFAULT_DATASET_NAMES[0]]),
              name=dataset_names[0] + " Dataset",
          ),
          go.Bar(
              x=cat_df.index,
              y=cat_df["Test dataset"],
              marker=dict(color=colors[DEFAULT_DATASET_NAMES[1]]),
              name=dataset_names[1] + " Dataset",
          ),
      ]
  
      yaxis_layout = dict(
          fixedrange=True,
          autorange=True,
          rangemode="normal",
          title="Frequency",
      )
  
      return traces, yaxis_layout
  
file_path: deepchecks/deepchecks/utils/distribution/plot.py
imports: from functools import cmp_to_key
  from numbers import Number
  from typing import Any, Dict, List, Tuple, Union
  import numpy
  import pandas
  import plotly.graph_objs
  from plotly.basedatatypes import BaseTraceType
  from scipy.stats import gaussian_kde
  from typing_extensions import Literal
  from deepchecks.core.errors import DeepchecksValueError
  from deepchecks.utils.dataframes import un_numpy
  from deepchecks.utils.distribution.preprocessing import preprocess_2_cat_cols_to_same_bins
  from deepchecks.utils.plot import DEFAULT_DATASET_NAMES, colors
label_desc: Use image node_id 6 for calling a global function with example usage: _create_distribution_bar_graphs(train_column, test_column, max_num_categories, show_categories_by, dataset_names) and returns: traces,  yaxis_layout, unknown, unknown