code: def plot_residuals_analysis(
      residuals: TimeSeries,
      num_bins: int = 20,
      fill_nan: bool = True,
      default_formatting: bool = True,
      acf_max_lag: int = 24,
  ) -> None:
      """Plots data relevant to residuals.
  
      This function takes a univariate TimeSeries instance of residuals and plots their values,
      their distribution and their ACF.
      Please note that if the residual TimeSeries instance contains NaN values, the plots
      might be displayed incorrectly. If `fill_nan` is set to True, the missing values will
      be interpolated.
  
      Parameters
      ----------
      residuals
          Univariate TimeSeries instance representing residuals.
      num_bins
          Optionally, an integer value determining the number of bins in the histogram.
      fill_nan
          A boolean value indicating whether NaN values should be filled in the residuals.
      default_formatting
          Whether to use the darts default scheme.
      acf_max_lag
          The maximum lag to be displayed in the ACF plot. Must be less than residuals length.
      """
  
      residuals._assert_univariate()
  
      fig = plt.figure(constrained_layout=True, figsize=(8, 6))
      gs = fig.add_gridspec(2, 2)
  
      if fill_nan:
          residuals = fill_missing_values(residuals)
  
      # plot values
      ax1 = fig.add_subplot(gs[:1, :])
      residuals.plot(ax=ax1)
      ax1.set_ylabel("value")
      ax1.set_title("Residual values")
  
      # plot histogram and distribution
      res_mean, res_std = np.mean(
          residuals.univariate_values()
      ), np.std(residuals.univariate_values())
      res_min, res_max = min(residuals.univariate_values()), max(
          residuals.univariate_values()
      )
      x = np.linspace(res_min, res_max, 100)
      ax2 = fig.add_subplot(gs[1:, 1:])
      plot_hist(residuals, bins=num_bins, ax=ax2)
      ax2.plot(
          x,
          norm(res_mean, res_std).pdf(x)
          * len(residuals)
          * (res_max - res_min)
          / num_bins,
      )
      ax2.yaxis.set_major_locator(plt.MaxNLocator(integer=True))
      ax2.set_title("Distribution")
      ax2.set_ylabel("count")
      ax2.set_xlabel("value")
  
      # plot ACF
      acf_max_lag = min(acf_max_lag, len(residuals) - 1)
      ax3 = fig.add_subplot(gs[1:, :1])
      plot_acf(
          residuals,
          axis=ax3,
          default_formatting=default_formatting,
          max_lag=acf_max_lag,
      )
      ax3.set_ylabel("ACF value")
      ax3.set_xlabel("lag")
      ax3.set_title("ACF")
  
imports: import math
  from typing import List, Optional, Sequence, Tuple, Union
  import matplotlib.pyplot
  import numpy
  from scipy.signal import argrelmax
  from scipy.stats import norm
  from statsmodels.tsa.seasonal import MSTL, STL, seasonal_decompose
  from statsmodels.tsa.stattools import acf, adfuller, grangercausalitytests, kpss, pacf
  from darts import TimeSeries
  from darts.logging import get_logger, raise_if, raise_if_not, raise_log
  from .missing_values import fill_missing_values
  from .utils import ModelMode, SeasonalityMode
label_desc: Use image node_id 14 for calling a global function with example usage: plot_residuals_analysis(residuals, num_bins, fill_nan, default_formatting, acf_max_lag) without return types