code: def draw_core(
      self,
      caption=None,
      limit_length=None,
      color_palette="Blues_d",
      ratio=False,
  ):
      sns.set(font_scale=1)
      data = self.data
      if type(data) == list:
          data = {v: f for v, f in self.data}
      total_amount = sum(self.data.values())
      data = sorted(
          data.items(), key=lambda kv: int(kv[1]), reverse=True
      )
      percentage = [v / total_amount for k, v in data]
  
      if limit_length is not None:
          data = data[:limit_length]
          percentage = percentage[:limit_length]
  
      items = np.array([a for a, _ in data])
      values = np.array([b for _, b in data])
      ax = sns.barplot(
          x=values,
          y=items,
          palette=sns.color_palette(color_palette),
          orient="h",
          order=items,
      )
      if (
          len(data) > 3 and percentage[0] - percentage[1] > 0.3
      ):  # the top item is quite dominant
          xlimit = values[1] * 1.2
          plt.xlim([0, xlimit])
          if ratio:
              ax.text(
                  xlimit,
                  0,
                  "%s%%" % round(percentage[0] * 100, 2),
                  color="black",
                  ha="left",
              )
          else:
              ax.text(
                  xlimit, 0, round(values[0], 4), color="red", ha="left"
              )
          plt.autoscale(enable=True, axis="y", tight=True)
  
      else:
          if ratio:
              ax.text(
                  values[0],
                  0,
                  "%s%%" % round(percentage[0] * 100, 2),
                  color="black",
                  ha="left",
              )
          else:
              ax.text(
                  values[0],
                  0,
                  round(values[0], 4),
                  color="black",
                  ha="left",
              )
          plt.autoscale(enable=True, axis="both", tight=True)
  
      for index in range(1, len(values)):
          if ratio:
              ax.text(
                  values[index],
                  index,
                  "%s%%" % round(percentage[index] * 100, 2),
                  color="black",
                  ha="left",
              )
          else:
              ax.text(
                  values[index],
                  index,
                  round(values[index], 4),
                  color="black",
                  ha="left",
              )
      if caption is not None:
          plt.title(caption)
      self.label_ax = ax
  
imports: import matplotlib.pyplot
  import numpy
  import pandas
  import seaborn
  import xai.constants
  from wordcloud import WordCloud
  import shap
  from xai.graphs.basic_graph import Graph
  from typing import List
  from collections import Counter
  import operator
  from xai.data.exceptions import NoItemsError
label_desc: Use image node_id 2 for calling the BarPlot obj's underlying member method code with example usage: obj.draw_core(caption, limit_length, color_palette, ratio) without return types