code: def gsr_figure() -> FigureResampler:
      def groupby_consecutive(
          df: Union[pd.Series, pd.DataFrame], col_name: str = None
      ) -> pd.DataFrame:
          """Merges consecutive `column_name` values in a single dataframe.
  
          This is especially useful if you want to represent sparse data in a more
          compact format.
  
          Parameters
          ----------
          df : Union[pd.Series, pd.DataFrame]
              Must be time-indexed!
          col_name : str, optional
              If a dataFrame is passed, you will need to specify the `col_name` on which
              the consecutive-grouping will need to take plase.
  
          Returns
          -------
          pd.DataFrame
              A new `DataFrame` view, with columns:
              [`start`, `end`, `n_consecutive`, `col_name`], representing the
              start- and endtime of the consecutive range, the number of consecutive samples,
              and the col_name's consecutive values.
          """
          if type(df) == pd.Series:
              col_name = df.name
              df = df.to_frame()
  
          assert col_name in df.columns
  
          df_cum = (
              (df[col_name].diff(1) != 0)
              .astype("int")
              .cumsum()
              .rename("value_grp")
              .to_frame()
          )
          df_cum["sequence_idx"] = df.index
          df_cum[col_name] = df[col_name]
  
          df_grouped = pd.DataFrame(
              {
                  "start": df_cum.groupby("value_grp")[
                      "sequence_idx"
                  ].first(),
                  "end": df_cum.groupby("value_grp")[
                      "sequence_idx"
                  ].last(),
                  "n_consecutive": df_cum.groupby("value_grp").size(),
                  col_name: df_cum.groupby("value_grp")[
                      col_name
                  ].first(),
              }
          ).reset_index(drop=True)
          df_grouped["next_start"] = df_grouped.start.shift(-1).fillna(
              df_grouped["end"]
          )
          return df_grouped
  
      df_gsr = pd.read_parquet(f"{data_dir}processed_gsr.parquet")
  
      fig = FigureResampler(
          make_subplots(
              rows=2,
              cols=1,
              specs=[[{"secondary_y": True}], [{}]],
              shared_xaxes=True,
          ),
          default_n_shown_samples=1_000,
          resampled_trace_prefix_suffix=(
              '<b style="color:blue">[R]</b> ',
              ' <b style="color:red">[R]</b>',
          ),
          verbose=False,
          show_mean_aggregation_size=True,
      )
      fig.update_layout(height=700)
  
      for c in ["EDA", "EDA_lf_cleaned", "EDA_lf_cleaned_tonic"]:
          fig.add_trace(
              go.Scattergl(name=c),
              hf_x=df_gsr.index,
              hf_y=df_gsr[c],
              row=1,
              col=1,
          )
  
      df_peaks = df_gsr[df_gsr["SCR_Peaks_neurokit_reduced_acc"] == 1]
      fig.add_trace(
          trace=go.Scattergl(
              x=df_peaks.index,
              y=df_peaks["EDA_lf_cleaned"],
              visible="legendonly",
              mode="markers",
              marker_symbol="cross",
              marker_size=15,
              marker_color="red",
              name="SCR peaks",
          ),
          limit_to_view=True,
      )
  
      df_grouped = groupby_consecutive(df_gsr["EDA_SQI"])
      df_grouped["EDA_SQI"] = df_grouped["EDA_SQI"].map(bool)
      df_grouped["good_sqi"] = df_grouped["EDA_SQI"].map(int)
      df_grouped["bad_sqi"] = (~df_grouped["EDA_SQI"]).map(int)
      for sqi_col, col_or in [
          ("good_sqi", "#2ca02c"),
          ("bad_sqi", "#d62728"),
      ]:
          fig.add_trace(
              go.Scattergl(
                  x=df_grouped["start"],
                  y=df_grouped[sqi_col],
                  mode="lines",
                  line_width=0,
                  fill="tozeroy",
                  fillcolor=col_or,
                  opacity=0.1 if "good" in sqi_col else 0.2,
                  line_shape="hv",
                  name=sqi_col,
                  showlegend=False,
              ),
              max_n_samples=len(df_grouped) + 1,
              downsampler=EveryNthPoint(),
              limit_to_view=True,
              secondary_y=True,
          )
  
      fig.add_trace(
          go.Scattergl(name="EDA_Phasic", visible="legendonly"),
          hf_x=df_gsr.index,
          hf_y=df_gsr["EDA_Phasic"],
          row=2,
          col=1,
      )
  
      return fig
  
imports: import os
  from typing import Union
  import numpy
  import pandas
  import plotly.graph_objects
  import pytest
  from plotly.subplots import make_subplots
  from plotly_resampler import LTTB, EveryNthPoint, FigureResampler, unregister_plotly_resampler
label_desc: Use image node_id 10 for calling a global function with example usage: gsr_figure() and returns: fig, df_grouped