code: def corr_subplot(
      fig: go.Figure,
      data: Union[pd.Series, List[pd.Series]],
      row: int,
      col: int,
      name: Optional[str] = None,
      plot: str = "acf",
      nlags: Optional[int] = None,
  ) -> Tuple[
      go.Figure, Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
  ]:
      """Function to add correlation plots to a Plotly subplot
  
      Parameters
      ----------
      fig : go.Figure
          Plotly figure to which the ACF needs to be added
      data : Union[pd.Series, List[pd.Series]]
          Data whose correlation plot needs to be plotted.
            - For ACF and PACF, this should be a Pandas Series.
            - For CCF, this should be a list of two pandas Series with the first one
              being the target, and the second one being the exogenous data against
              which the CCF has to be computed. Note that if the second series is
              the same as the first one, then this is equivalent to the ACF plot.
      row : int
          Row of the figure where the plot needs to be inserted. Starts from 1.
      col : int
          Column of the figure where the plot needs to be inserted. Starts from 1.
      name : Optional[str], optional
          Name to show when hovering over plot, by default None
      plot : str, optional
          Options are
            - "acf": to plot ACF,
            - "pacf": to plot PACF
            - "ccf": to plot CCF
          by default "acf"
      nlags : Optional[int], optional
          Number of lags to plot, by default None which plots 40 lags (same as statsmodels)
  
  
      Returns
      -------
      Tuple[go.Figure, Tuple[np.ndarray, np.ndarray]]
          Returns back the plotly figure with Correlation plot inserted along with
          the correlation data.
  
      Raises
      ------
      ValueError
          If `plot` is not one of the allowed types
      """
  
      lower, upper = None, None
  
      # Compute n_lags
      if nlags is None:
          if plot in ["acf", "ccf"]:
              nlags = 40
          elif plot in ["pacf"]:
              nobs = len(data)
              nlags = min(int(10 * np.log10(nobs)), nobs // 2 - 1)
  
      if plot in ["acf", "pacf"]:
          if plot == "acf":
              default_name = "ACF"
              corr_array = acf(data, nlags=nlags, alpha=0.05)
          elif plot == "pacf":
              default_name = "PACF"
              corr_array = pacf(data, nlags=nlags, alpha=0.05)
          corr_values = corr_array[0]
          lower = corr_array[1][:, 0] - corr_array[0]
          upper = corr_array[1][:, 1] - corr_array[0]
      elif plot == "ccf":
          default_name = "CCF"
          target, exog = data
          corr_values = ccf(target, exog, unbiased=False)
          # Default, returns lags = len of data, hence limit it.
          corr_values = corr_values[: nlags + 1]
          # No upper and lower bounds available for CCF
      else:
          raise ValueError(
              f"plot must be one of 'acf', 'pacf' or 'ccf'. You passed '{plot}'"
          )
  
      lags = np.arange(len(corr_values))
      name = name or default_name
  
      # Add the correlation plot ----
      fig = _add_corr_stems_subplot(
          fig=fig,
          corr_values=corr_values,
          lags=lags,
          name=name,
          row=row,
          col=col,
      )
      if upper is not None and lower is not None:
          # Not available for CCF ----
          fig = _add_corr_bounds_subplot(
              fig=fig, lower=lower, upper=upper, row=row, col=col
          )
  
      with fig.batch_update():
          fig.update_traces(showlegend=False)
          fig.update_xaxes(
              range=[-1, len(corr_values) + 1], row=row, col=col
          )
          fig.update_yaxes(
              range=[-1.1, 1.1],
              zerolinecolor="#000000",
              row=row,
              col=col,
          )
          # For compactness, the following have been removed for now
          # fig.update_xaxes(title_text="Lags", row=row, col=col)
          # fig.update_yaxes(title_text=default_name, row=row, col=col)
      return fig, (corr_values, lags, upper, lower)
  
imports: from math import ceil
  from typing import Any, Dict, List, Optional, Tuple, Union
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import pandas
  import plotly.express
  import plotly.graph_objects
  import plotly.io
  from plotly.colors import DEFAULT_PLOTLY_COLORS
  from plotly.subplots import make_subplots
  from scipy.fft import fft, fftfreq
  from scipy.signal import periodogram
  from statsmodels.graphics.gofplots import qqplot
  from statsmodels.tsa.seasonal import STL, seasonal_decompose
  from statsmodels.tsa.stattools import acf, ccf, pacf
  from pycaret.internal.logging import get_logger
  from pycaret.utils.generic import _resolve_dict_keys
  from pycaret.utils.time_series import TSAllowedPlotDataTypes
label_desc: Use image node_id 2 for calling a global function with example usage: corr_subplot(fig, data, row, col, name, plot, nlags) and returns: fig,  corr_values,  lags,  upper,  lower