code: def _group_return(
      pred_label: pd.DataFrame = None,
      reverse: bool = False,
      N: int = 5,
      **kwargs,
  ) -> tuple:
      """
  
      :param pred_label:
      :param reverse:
      :param N:
      :return:
      """
      if reverse:
          pred_label["score"] *= -1
  
      pred_label = pred_label.sort_values("score", ascending=False)
  
      # Group1 ~ Group5 only consider the dropna values
      pred_label_drop = pred_label.dropna(subset=["score"])
  
      # Group
      t_df = pd.DataFrame(
          {
              "Group%d"
              % (i + 1): pred_label_drop.groupby(level="datetime")[
                  "label"
              ].apply(
                  lambda x: x[
                      len(x) // N * i : len(x) // N * (i + 1)
                  ].mean()  # pylint: disable=W0640
              )
              for i in range(N)
          }
      )
      t_df.index = pd.to_datetime(t_df.index)
  
      # Long-Short
      t_df["long-short"] = t_df["Group1"] - t_df["Group%d" % N]
  
      # Long-Average
      t_df["long-average"] = (
          t_df["Group1"]
          - pred_label.groupby(level="datetime")["label"].mean()
      )
  
      t_df = t_df.dropna(
          how="all"
      )  # for days which does not contain label
      # Cumulative Return By Group
      group_scatter_figure = ScatterGraph(
          t_df.cumsum(),
          layout=dict(
              title="Cumulative Return",
              xaxis=dict(
                  tickangle=45,
                  rangebreaks=kwargs.get(
                      "rangebreaks",
                      guess_plotly_rangebreaks(t_df.index),
                  ),
              ),
          ),
      ).figure
  
      t_df = t_df.loc[:, ["long-short", "long-average"]]
      _bin_size = float(((t_df.max() - t_df.min()) / 20).min())
      group_hist_figure = SubplotsGraph(
          t_df,
          kind_map=dict(
              kind="DistplotGraph", kwargs=dict(bin_size=_bin_size)
          ),
          subplots_kwargs=dict(
              rows=1,
              cols=2,
              print_grid=False,
              subplot_titles=["long-short", "long-average"],
          ),
      ).figure
  
      return group_scatter_figure, group_hist_figure
  
file_path: qlib/qlib/contrib/report/analysis_model/analysis_model_performance.py
imports: from functools import partial
  import pandas
  import plotly.graph_objs
  import statsmodels.api
  import matplotlib.pyplot
  from scipy import stats
  from typing import Sequence
  from qlib.typehint import Literal
  from ..graph import ScatterGraph, SubplotsGraph, BarGraph, HeatmapGraph
  from ..utils import guess_plotly_rangebreaks
label_desc: Use image node_id 1 for calling a global function with example usage: _group_return(pred_label, reverse, N) and returns: group_scatter_figure,  group_hist_figure