code: def add_text_and_tooltips_to_dendrogram(
      fig, _dendrogram_aspects_ordered, rounding_function, digits
  ):
      res_fig = go.Figure(fig)
      corner_scatters = []  # scatters with depend=0
      for i, scatter in enumerate(res_fig.data):
          # 0 ---- 1
          #        |
          #        *   scatter indexing convention
          #        |
          # 3 ---- 2
          # add middle point - for text label (*)
          x_cord = scatter.x[1]
          y_cord = np.mean(scatter.y[1:3])
          scatter.x = np.insert(scatter.x, 2, x_cord)
          scatter.y = np.insert(scatter.y, 2, y_cord)
  
          # add text labels and tooltips
          min_depend_val_rounded = str(
              rounding_function(
                  _dendrogram_aspects_ordered.iloc[i].min_depend, digits
              )
          )
          if x_cord != 1:
              scatter.mode = "text+lines"
              scatter["text"] = [
                  None,
                  None,
                  str(rounding_function(1 - x_cord, digits)),
                  None,
                  None,
              ]
              scatter["textposition"] = "middle left"
              scatter.hoverinfo = "text"
              scatter.hoverlabel = {"bgcolor": "rgba(0,0,0,0.8)"}
              scatter.hovertext = (
                  "Min depend value: "
                  + min_depend_val_rounded
                  + "<br>(between variables: "
                  + ", ".join(
                      _dendrogram_aspects_ordered.iloc[
                          i
                      ].vars_min_depend
                  )
                  + ")"
                  + "<br>Variables:<br>"
                  + "<br>".join(
                      _dendrogram_aspects_ordered.iloc[i].variable_names
                  )
              )
          else:
              scatter.hoverlabel = {"bgcolor": "rgba(0,0,0,0.8)"}
              scatter.hovertext = (
                  "Min depend value: "
                  + min_depend_val_rounded
                  + "<br>(between variables: "
                  + ", ".join(
                      _dendrogram_aspects_ordered.iloc[
                          -1
                      ].vars_min_depend
                  )
                  + ")"
                  + "<br>Variables:<br>"
                  + "<br>".join(
                      _dendrogram_aspects_ordered.iloc[
                          -1
                      ].variable_names
                  )
              )
              corner_scatters.append(scatter)
  
      if corner_scatters:
          # (add only one text label for all)
          scatter = corner_scatters[len(corner_scatters) // 2]
          label = str(rounding_function(0, digits))
          scatter.mode = "text+lines"
          scatter["text"] = [None, None, label, None, None]
          scatter["textposition"] = "middle left"
          scatter.hoverinfo = "text"
  
      return res_fig
  
imports: import numpy
  from plotly.figure_factory import create_dendrogram
  import plotly.graph_objects
label_desc: Use image node_id 2 for calling a global function with example usage: add_text_and_tooltips_to_dendrogram(fig, _dendrogram_aspects_ordered, rounding_function, digits) and returns: res_fig