code: def plot_series(
      y: pd.DataFrame,
      y_label: str,
      fig_defaults: Dict[str, Any],
      X: Optional[List[pd.DataFrame]] = None,
      X_labels: Optional[List[str]] = None,
      hoverinfo: Optional[str] = "text",
      fig_kwargs: Optional[Dict] = None,
  ) -> PlotReturnType:
      """Plots the target time series (full or specific splits). Can optionally
      plot exogenous variables if available.
  
      Parameters
      ----------
      y : pd.DataFrame
          A dataframe containing the various plot data types for the target series
          (original, imputed, transformed), the various splits (full, train, test)
          or a combination of these two. Each column in the dataframe is plotted as
          a separate overlaid series in the plot. The names of the columns are used
          in the plot legend.
      y_label : str
          The name of the target time series.
      fig_defaults : Dict[str, Any]
          The default settings for the plotly plot. Must contain keys for "width",
          "height", and "template".
      X : Optional[List[pd.DataFrame]], optional
          The exogenous variables in the data, by default None
          X contains 1 dataframe per exogenous variable. Similar to the target
          series, each dataframe can contain multiple columns corresponding to the
          various plot data types (original, imputed, transformed). Each exogenous
          variable is plotted in a separate subplot and each data type is overlaid
          within that subplot. The names of the columns are used in the plot legend.
      X_labels : Optional[List[str]], optional
          The names of the exogenous variables, by default None
      hoverinfo : Optional[str], optional
          Action when hovering over the plotly plot, by default "text"
      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
          When exogenous variables are passed, but their corresponding names are
          not passed.
      """
      fig_kwargs = fig_kwargs or {}
  
      title = f"Time Series | Target = {y_label}"
  
      plot_data = [y]
      subplot_titles = [y_label]
      if X is not None:
          # Exogenous Variables present.
          plot_data.extend(X)
          if X_labels is None:
              raise ValueError(
                  "X is not None, but X_labels is None. This should not have occurred."
                  "\nPlease file a report here with a reproducible example:"
                  "\nhttps://github.com/pycaret/pycaret/issues"
              )
          subplot_titles.extend(X_labels)
  
      rows = len(plot_data)
      fig = make_subplots(
          rows=rows,
          cols=1,
          subplot_titles=subplot_titles,
          vertical_spacing=0.02,
          shared_xaxes=True,
      )
  
      for i, plot_data_single in enumerate(plot_data):
          fig = time_series_subplot(
              fig=fig,
              data=plot_data_single,
              row=i + 1,
              col=1,
              hoverinfo=hoverinfo,
          )
  
      fig = _plot_fig_update(
          fig, title, fig_defaults, fig_kwargs, show_legend=True
      )
  
      return_data_dict = {
          "data": 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 2 for calling a global function with example usage: plot_series(y, y_label, fig_defaults, X, X_labels, hoverinfo, fig_kwargs) and returns: fig,  return_data_dict