code: def frequency_components_subplot(
      fig: go.Figure,
      data: pd.Series,
      row: int,
      col: int,
      hoverinfo: Optional[str],
      plot: str = "periodogram",
      name: Optional[str] = None,
  ) -> PlotReturnType:
      """Function to add a time series to a Plotly subplot
  
      Parameters
      ----------
      fig : go.Figure
          Plotly figure to which the time series needs to be added
      freq : pd.Series
          Time Series whose frequency components have to be plotted
      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.
      hoverinfo : Optional[str]
          Whether hoverinfo should be disabled or not. Options are same as plotly.
          e.g. "text" to display, "skip" or "none" to disable.
      plot : str, optional
          Type of method to use to get the frequency components, by default "periodogram"
          Allowed methods are: "periodogram", "fft"
      name : Optional[str], optional
          Name to show when hovering over plot, by default None
  
      Returns
      -------
      PlotReturnType
          Returns back the plotly figure along with the data used to create the plot.
      """
      x, y = return_frequency_components(data=data, type=plot)
      time_period = [round(1 / freq, 4) for freq in x]
      freq_data = pd.DataFrame(
          {"Freq": x, "Amplitude": y, "Time Period": time_period}
      )
  
      name = name or data.name
  
      # If you add hoverinfo = "text", you must also add the hovertemplate, else no hoverinfo
      # gets displayed. OR alternately, leave it out and it gets plotted by default.
      if hoverinfo == "text":
          # We convert this to hovertext so plotly-resampler can effectively deal with
          # this data modality
          freq_data_str = freq_data.round(4).astype("str")
          hf_hovertext = (
              "Freq: "
              + freq_data_str["Freq"]
              + "<br>Ampl: "
              + freq_data_str["Amplitude"]
              + "<br>Time period: "
              + freq_data_str["Time Period"]
          )
  
          fig.add_trace(
              go.Scattergl(
                  name=name,
                  x=freq_data["Freq"],
                  y=freq_data["Amplitude"],
                  hovertext=hf_hovertext,
                  mode="lines+markers",
                  line=dict(color="#1f77b4", width=2),
                  marker=dict(size=5),
                  showlegend=True,
                  hoverinfo=hoverinfo,
              ),
              row=row,
              col=col,
          )
      else:
          # Disable hoverinfo
          fig.add_trace(
              go.Scattergl(
                  name=name,
                  x=freq_data["Freq"],
                  y=freq_data["Amplitude"],
                  mode="lines+markers",
                  line=dict(color="#1f77b4", width=2),
                  marker=dict(size=5),
                  showlegend=True,
                  hoverinfo=hoverinfo,
              ),
              row=row,
              col=col,
          )
  
      with fig.batch_update():
          # For compactness, the following have been removed for now
          # fig.update_xaxes(title_text="Frequency", row=row, col=col)
  
          # X-axis is getting messed up when acf or pacf is being plotted along with this
          # Hence setting explicitly per https://plotly.com/python/subplots/
          fig.update_xaxes(range=[0, 0.5], row=row, col=col)
      return fig, freq_data
  
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 11 for calling a global function with example usage: frequency_components_subplot(fig, data, row, col, hoverinfo, plot, name) and returns: fig,  freq_data