code: def _unpivot_sp(df, template=None):
      """Unpivot DataFrame with multivariate-by-seasonal-offset, invert _pivot_sp.
  
      Inverse operation to `_pivot_sp`.
  
      For a `pd.DataFrame` that is like the output of `_pivot_sp`, produces
      a univariate `pd.DataFrame` where:
  
      * row index consists of all combination sums of `df.index` and `df.columns`
      * column index is `template.index` if `template` is given, otherwise `RangeIndex`
      * the entry in row location `i + j`,
        for `i` a row and `j` a column of `df`, is `df.loc[i][j]`
  
      Parameters
      ----------
      `df` : `pd.Series` or `pd.DataFrame` with `pandas` integer index,
          `pd.DatetimeIndex`, or `pd.PeriodIndex`, and with one column/variable
      `template` : None, or `pd.Series` or `pd.DataFrame`
          template data frame for the unpivot, equal to `df` if not provided
      """
      if template is not None:
          if hasattr(template, "index") and hasattr(
              template.index, "freq"
          ):
              freq = template.index.freq
          elif hasattr(template, "freq"):
              freq = template.freq
          else:
              freq = template
  
      df_melt = df.melt(ignore_index=False)
  
      offset = df_melt[df_melt.columns[0]]
      if isinstance(df_melt.index, pd.DatetimeIndex):
          a = df_melt.index.to_period(freq=freq)
          res = a + offset
          df_melt.index = res
          was_datetime = True
      else:
          df_melt.index = df_melt.index + offset
          was_datetime = False
      df_melt = df_melt.drop(columns=df_melt.columns[0])
      df_melt = df_melt.sort_index()
      df_melt = df_melt.dropna()
  
      if was_datetime:
          df_melt.index = df_melt.index.to_timestamp()
  
      if template is not None:
          if hasattr(template, "columns"):
              df_melt.columns = template.columns
          elif hasattr(template, "name"):
              df_melt.columns = [template.name]
  
      return df_melt
  
imports: from warnings import warn
  import numpy
  import pandas
  from sktime.utils.validation._dependencies import _check_soft_dependencies
  from sktime.utils.validation.forecasting import check_sp, check_y
label_desc: Use image node_id 3 for calling a global function with example usage: _unpivot_sp(df, template) and returns: df_melt