code: def plot_time_series_decomposition(
      data: pd.DataFrame,
      plot: str,
      fig_defaults: Dict[str, Any],
      data_kwargs: Dict[str, Any],
      data_label: Optional[str] = None,
      model_labels: Optional[List[str]] = None,
      fig_kwargs: Optional[Dict] = None,
  ) -> PlotReturnType:
      """Plots the Decomposition for the target time series (could be any data
      type of the data - original, imputed, transformed) or model residuals.
  
      Parameters
      ----------
      data : pd.DataFrame
          Data whose decomposition plot needs to be plotted. If based on the original
          data, it can contain multiple columns corresponding to the various data
          types of the targets (original, imputed, transformed). If it is based on
          a estimator(s), it can contain residuals from multiple models (one column
          per model). The column names must correspond to the model labels in this
          case.
      plot : str, optional
          Type of plot, allowed values are ["decomp", "decomp_stl"]
      fig_defaults : Dict[str, Any]
          The default settings for the plotly plot. Must contain keys for "width",
          "height", and "template".
      data_kwargs : Dict[str, Any]
          A dictionary containing mandatory keys for "seasonal_period"
      data_label : Optional[str], optional
          If data is from the original target series, then the name of the target
          series, by default None.
      model_labels : Optional[List[str]], optional
          If data is from model residuals, then the name(s) of the model(s),
          by default None. At least one of data_label or model_labels must be provided.
      fig_kwargs : Optional[Dict], optional
          Specific overrides by the user for the plotly figure settings,
          by default None. Can contain keys for "width", "height" and/or "template".
  
      Returns
      -------
      PlotReturnType
          The plotly figure object along with a dictionary with the plot data.
          The data can be returned to the user (if requested) so that the plot can
          be and customized by them if not supported by pycaret by default.
  
      Raises
      ------
      ValueError
          (1) If seasonal_period is not passed through data_kwargs
          (2) When both data_label and model_labels are None
      """
      fig, return_data_dict = None, None
  
      if not isinstance(data.index, (pd.PeriodIndex, pd.DatetimeIndex)):
          print(
              "Decomposition is currently not supported for pandas dataframes "
              "without a PeriodIndex or DatetimeIndex. Please specify a PeriodIndex "
              "or DatetimeIndex in setup() before plotting decomposition plots."
          )
          return fig, return_data_dict
  
      data_kwargs = data_kwargs or {}
      period = data_kwargs.get("seasonal_period", None)
  
      # Check period ----
      if period is None:
          raise ValueError(
              "Decomposition plot needed seasonal period to be passed through "
              "`data_kwargs`. None was passed."
          )
      if plot == "decomp_stl" and period < 2:
          print(
              "STL Decomposition is not supported for time series that have a "
              f"seasonal period < 2. The seasonal period computed/provided was {period}."
          )
          return fig, return_data_dict
  
      ncols = len(data.columns)
      fig = make_subplots(
          rows=4,
          cols=ncols,
          column_titles=data.columns.tolist(),
          row_titles=["Actual", "Seasonal", "Trend", "Residual"],
          shared_xaxes=True,
          shared_yaxes=True,
      )
  
      classical_decomp_type = data_kwargs.get("type", "additive")
      fig_kwargs = fig_kwargs or {}
  
      if plot == "decomp":
          title = f"Classical Decomposition ({classical_decomp_type})"
      elif plot == "decomp_stl":
          title = "STL Decomposition"
  
      if model_labels is not None:
          title = f"{title} | Model Residuals"
      elif data_label is not None:
          title = f"{title} | {data_label}"
      else:
          # Both model_labels and data_label are None
          raise ValueError(msg1)
  
      title = title + f"<br>Seasonal Period = {period}"
  
      all_plot_data = {}
      for i, col_name in enumerate(data.columns):
          fig, plot_data = decomp_subplot(
              fig=fig,
              data=data[col_name],
              col=i + 1,
              plot=plot,
              classical_decomp_type=classical_decomp_type,
              period=period,
          )
          all_plot_data.update({col_name: plot_data})
  
      fig = _plot_fig_update(fig, title, fig_defaults, fig_kwargs)
  
      return_data_dict = {"data": data, plot: all_plot_data}
  
      return fig, return_data_dict
  
file_path: pycaret/pycaret/internal/plots/time_series.py
imports: from typing import Any, Dict, List, Optional, Union
  import numpy
  import pandas
  import plotly.graph_objects
  from plotly.subplots import make_subplots
  from sktime.forecasting.model_selection import ExpandingWindowSplitter, SlidingWindowSplitter
  from pycaret.internal.plots.utils.time_series import PlotReturnType, _clean_model_results_labels, _get_subplot_rows_cols, _plot_fig_update, _resolve_hoverinfo, _update_fig_dimensions, corr_subplot, decomp_subplot, dist_subplot, frequency_components_subplot, plot_original_with_overlays, qq_subplot, time_series_subplot
  from pycaret.utils.generic import _resolve_dict_keys
  from pycaret.utils.time_series import get_diffs
label_desc: Use image node_id 8 for calling a global function with example usage: plot_time_series_decomposition(data, plot, fig_defaults, data_kwargs, data_label, model_labels, fig_kwargs) and returns: fig,  return_data_dict, fig,  return_data_dict, fig,  return_data_dict