code: def _plot_fig_update(
      fig: go.Figure,
      title: str,
      fig_defaults: Dict[str, Any],
      fig_kwargs: Optional[Dict] = None,
      show_legend: bool = False,
  ) -> go.Figure:
      """Customises the template layout and dimension of plots
  
      Parameters
      ----------
      fig: go.Figure
          Plotly figure which needs to be customised
      title: str
          Title of the plot
      fig_defaults : Dict[str, Any]
          The default settings for the plotly plot. Must contain keys for "width",
          "height", and "template".
      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".
      show_legend: bool, default=False
          If True, displays the legend in the plot when layout is updated.
  
      Returns
      -------
      go.Figure
          The Plotly figure with updated dimnensions and template layout.
      """
      with fig.batch_update():
          template = _resolve_dict_keys(
              dict_=fig_kwargs, key="template", defaults=fig_defaults
          )
          fig.update_layout(
              title=title, showlegend=show_legend, template=template
          )
          fig = _update_fig_dimensions(
              fig=fig, fig_kwargs=fig_kwargs, fig_defaults=fig_defaults
          )
      return fig
  
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 20 for calling a global function with example usage: _plot_fig_update(fig, title, fig_defaults, fig_kwargs, show_legend) and returns: fig