class_docstr: SmartPlotter is a Bridge pattern decoupling plotting functions from SmartExplainer.
  The smartplotter class includes all the methods used to display graphics
  Each SmartPlotter method is easy to use from a Smart explainer object,
  just use the following syntax
  Attributes :
  explainer: object
      SmartExplainer instance to point to.
  Example
  --------
  >>> xpl.plot.my_plot_method(param=value)
class_docstr_tok: ["SmartPlotter","is","a","Bridge","pattern","decoupling","plotting","functions","from","SmartExplainer",".","The","smartplotter","class","includes","all","the","methods","used","to","display","graphics","Each","SmartPlotter","method","is","easy","to","use","from","a","Smart","explainer","object",",","just","use","the","following","syntax","Attributes",":","explainer",":","object","SmartExplainer","instance","to","point","to",".","Example","--","--","--","--",">",">",">","xpl.plot.my_plot_method","(","param=value",")"]
docstr: Displays a dynamic plot with the `nb_top_interactions` most important interactions existing
  between two variables.
  The most important interactions are determined computing the sum of all absolute shap interactions
  values between all existing pairs of variables.
  A button allows to select and display the corresponding features values and their shap contribution values.
  Parameters
  ----------
  nb_top_interactions : int
      Number of top interactions to display.
  selection : list (optional)
      Contains list of index, subset of the input DataFrame that we want to plot
  violin_maxf : int (optional, default: 10)
      maximum number modality to plot violin. If the feature specified with col argument
      has more modalities than violin_maxf, a scatter plot will be choose
  max_points : int (optional, default: 500)
      maximum number to plot in contribution plot. if input dataset is bigger than max_points,
      a sample limits the number of points to plot.
      nb: you can also limit the number using 'selection' parameter.
  width : Int (default: 900)
      Plotly figure - layout width
  height : Int (default: 600)
      Plotly figure - layout height
  file_name: string (optional)
      File name to use to save the plotly bar chart. If None the bar chart will not be saved.
  auto_open: Boolean (optional)
      Indicate whether to open the bar plot or not.
  Returns
  -------
  go.Figure
  Example
  --------
  >>> xpl.plot.top_interactions_plot()
code: def top_interactions_plot(
      self,
      nb_top_interactions=5,
      selection=None,
      violin_maxf=10,
      max_points=500,
      width=900,
      height=600,
      file_name=None,
      auto_open=False,
  ):
      """
      Displays a dynamic plot with the `nb_top_interactions` most important interactions existing
      between two variables.
      The most important interactions are determined computing the sum of all absolute shap interactions
      values between all existing pairs of variables.
      A button allows to select and display the corresponding features values and their shap contribution values.
      Parameters
      ----------
      nb_top_interactions : int
          Number of top interactions to display.
      selection : list (optional)
          Contains list of index, subset of the input DataFrame that we want to plot
      violin_maxf : int (optional, default: 10)
          maximum number modality to plot violin. If the feature specified with col argument
          has more modalities than violin_maxf, a scatter plot will be choose
      max_points : int (optional, default: 500)
          maximum number to plot in contribution plot. if input dataset is bigger than max_points,
          a sample limits the number of points to plot.
          nb: you can also limit the number using 'selection' parameter.
      width : Int (default: 900)
          Plotly figure - layout width
      height : Int (default: 600)
          Plotly figure - layout height
      file_name: string (optional)
          File name to use to save the plotly bar chart. If None the bar chart will not be saved.
      auto_open: Boolean (optional)
          Indicate whether to open the bar plot or not.
      Returns
      -------
      go.Figure
      Example
      --------
      >>> xpl.plot.top_interactions_plot()
      """
  
      list_ind, addnote = self._select_indices_interactions_plot(
          selection=selection, max_points=max_points
      )
  
      interaction_values = self.explainer.get_interaction_values(
          selection=list_ind
      )
  
      sorted_top_features_indices = (
          compute_sorted_variables_interactions_list_indices(
              interaction_values
          )
      )
  
      indices_to_plot = sorted_top_features_indices[
          :nb_top_interactions
      ]
      interactions_indices_traces_mapping = []
      fig = go.Figure()
      for i, ids in enumerate(indices_to_plot):
          id0, id1 = ids
  
          fig_one_interaction = self.interactions_plot(
              col1=self.explainer.columns_dict[id0],
              col2=self.explainer.columns_dict[id1],
              selection=selection,
              violin_maxf=violin_maxf,
              max_points=max_points,
              width=width,
              height=height,
              file_name=None,
              auto_open=False,
          )
  
          # The number of traces of each figure is stored
          interactions_indices_traces_mapping.append(
              len(fig_one_interaction.data)
          )
  
          for trace in fig_one_interaction.data:
              trace.visible = True if i == 0 else False
              fig.add_trace(trace=trace)
  
      def generate_title_dict(col_name1, col_name2, addnote):
          title = f"<b>{truncate_str(col_name1)} and {truncate_str(col_name2)}</b> shap interaction values"
          if addnote:
              title += f"<span style='font-size: 12px;'><br />{add_text([addnote], sep=' - ')}</span>"
          dict_t = copy.deepcopy(self._style_dict["dict_title"])
          dict_t.update(
              {
                  "text": title,
                  "y": 0.88,
                  "x": 0.5,
                  "xanchor": "center",
                  "yanchor": "top",
              }
          )
          return dict_t
  
      fig.layout.coloraxis.colorscale = self._style_dict[
          "interactions_col_scale"
      ]
      fig.update_layout(
          xaxis_title=self.explainer.columns_dict[
              sorted_top_features_indices[0][0]
          ],
          yaxis_title="Shap interaction value",
          updatemenus=[
              dict(
                  active=0,
                  buttons=list(
                      [
                          dict(
                              label=f"{self.explainer.columns_dict[i]} - {self.explainer.columns_dict[j]}",
                              method="update",
                              args=[
                                  {
                                      "visible": [
                                          True
                                          if i == id_trace
                                          else False
                                          for i, x in enumerate(
                                              interactions_indices_traces_mapping
                                          )
                                          for _ in range(x)
                                      ]
                                  },
                                  {
                                      "xaxis": {
                                          "title": {
                                              **{
                                                  "text": self.explainer.columns_dict[
                                                      i
                                                  ]
                                              },
                                              **self._style_dict[
                                                  "dict_xaxis"
                                              ],
                                          }
                                      },
                                      "legend": {
                                          "title": {
                                              "text": self.explainer.columns_dict[
                                                  j
                                              ]
                                          }
                                      },
                                      "coloraxis": {
                                          "colorbar": {
                                              "title": {
                                                  "text": self.explainer.columns_dict[
                                                      j
                                                  ]
                                              }
                                          },
                                          "colorscale": fig.layout.coloraxis.colorscale,
                                      },
                                      "title": generate_title_dict(
                                          self.explainer.columns_dict[
                                              i
                                          ],
                                          self.explainer.columns_dict[
                                              j
                                          ],
                                          addnote,
                                      ),
                                  },
                              ],
                          )
                          for id_trace, (i, j) in enumerate(
                              indices_to_plot
                          )
                      ]
                  ),
                  direction="down",
                  pad={"r": 10, "t": 10},
                  showactive=True,
                  x=0.37,
                  xanchor="left",
                  y=1.25,
                  yanchor="top",
              )
          ],
          annotations=[
              dict(
                  text=f"Sorted top {len(indices_to_plot)} SHAP interaction Variables :",
                  x=0,
                  xref="paper",
                  y=1.2,
                  yref="paper",
                  align="left",
                  showarrow=False,
              )
          ],
      )
  
      self._update_interactions_fig(
          fig=fig,
          col_name1=self.explainer.columns_dict[
              sorted_top_features_indices[0][0]
          ],
          col_name2=self.explainer.columns_dict[
              sorted_top_features_indices[0][1]
          ],
          addnote=addnote,
          width=width,
          height=height,
          file_name=None,
          auto_open=False,
      )
  
      fig.update_layout(
          title={
              "y": 0.88,
              "x": 0.5,
              "xanchor": "center",
              "yanchor": "top",
          }
      )
  
      if file_name:
          plot(fig, filename=file_name, auto_open=auto_open)
  
      return fig
  
imports: import warnings
  from numbers import Number
  import random
  import copy
  import math
  import numpy
  from scipy.optimize import fsolve
  import scipy.cluster.hierarchy
  import pandas
  from plotly import graph_objs
  import plotly.express
  from plotly.subplots import make_subplots
  from plotly.offline import plot
  from shapash.manipulation.select_lines import select_lines
  from shapash.manipulation.summarize import compute_features_import, project_feature_values_1d, compute_corr
  from shapash.utils.utils import add_line_break, truncate_str, compute_digit_number, add_text, maximum_difference_sort_value, compute_sorted_variables_interactions_list_indices, compute_top_correlations_features
  from shapash.webapp.utils.utils import round_to_k
  from shapash.style.style_utils import colors_loading, select_palette, define_style
label_desc: Use image node_id 24 for calling the SmartPlotter obj's underlying member method code with example usage: obj.top_interactions_plot(nb_top_interactions, selection, violin_maxf, max_points, width, height, file_name, auto_open) and returns: fig, dict_t