code: def plot_pd_variance(
      exp: Explanation,
      features: Union[List[int], Literal["all"]] = "all",
      targets: Union[
          List[Union[str, int]],
          Literal["all"],
      ] = "all",
      summarise: bool = True,
      n_cols: int = 3,
      sort: bool = True,
      top_k: Optional[int] = None,
      plot_limits: Optional[Tuple[float, float]] = None,
      ax: Optional[Union["plt.Axes", np.ndarray]] = None,
      sharey: Optional[Literal["all", "row"]] = "all",
      bar_kw: Optional[dict] = None,
      line_kw: Optional[dict] = None,
      fig_kw: Optional[dict] = None,
  ):
      """
      Plot feature importance and feature interaction based on partial dependence curves on `matplotlib` axes.
  
      Parameters
      ----------
      exp
          An `Explanation` object produced by a call to the
          :py:meth:`alibi.explainers.pd_variance.PartialDependenceVariance.explain` method.
      features
          A list of features entries provided in `feature_names` argument  to the
          :py:meth:`alibi.explainers.pd_variance.PartialDependenceVariance.explain` method, or
          ``'all'`` to  plot all the explained features. For example, if  ``feature_names = ['temp', 'hum', 'windspeed']``
          and we want to plot the values only for the ``'temp'`` and ``'windspeed'``, then we would set
          ``features=[0, 2]``. Defaults to ``'all'``.
      targets
          A target name/index, or a list of target names/indices, for which to plot the feature importance/interaction,
          or ``'all'``. Can be a mix of integers denoting target index or strings denoting entries in
          `exp.meta['params']['target_names']`. By default ``'all'`` to plot the importance for all features
          or to plot all the feature interactions.
      summarise
          Whether to plot only the summary of the feature importance/interaction as a bar plot, or plot comprehensive
          exposition including partial dependence plots and conditional importance plots.
      n_cols
          Number of columns to organize the resulting plot into.
      sort
          Boolean flag whether to sort the values in descending order.
      top_k
          Number of top k values to be displayed if the ``sort=True``. If not provided, then all values will be displayed.
      plot_limits
          Minimum and maximum y-limits for all the line plots. If ``None`` will be automatically inferred.
      ax
          A `matplotlib` axes object or a `numpy` array of `matplotlib` axes to plot on.
      sharey
          A parameter specifying whether the y-axis of the PD and ICE curves should be on the same scale
          for several features. Possible values are: ``'all'`` | ``'row'`` | ``None``.
      bar_kw
          Keyword arguments passed to the `matplotlib.pyplot.barh`_ function.
      line_kw
          Keyword arguments passed to the `matplotlib.pyplot.plot`_ function.
      fig_kw
          Keyword arguments passed to the `matplotlib.figure.set`_ function.
  
          .. _matplotlib.pyplot.barh:
              https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.barh.html
  
          .. _matplotlib.pyplot.plot:
              https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html
  
          .. _matplotlib.figure.set:
              https://matplotlib.org/stable/api/figure_api.html
  
      Returns
      -------
      `plt.Axes` with the summary/detailed exposition plot of the feature importance or feature interaction.
      """
      # sanity check for `top_k`
      if sort and (top_k is not None) and (top_k <= 0):
          raise ValueError("``top_k`` must be greater than 0.")
  
      # initialization for `targets`
      if targets == "all":
          targets = exp.meta["params"]["target_names"]
  
      # sanity check for targets
      if not isinstance(targets, list):
          raise ValueError("`targets` must be a list.")
  
      # warning that plotting partial dependence and conditional importance works for a single target
      if len(targets) > 1 and (not summarise):
          logger.warning(
              "`targets` should be a list containing a single element when ``summarise=False``."
              "By default the first element in the list is considered."
          )
  
      # initialization for `features`
      if features == "all":
          features = list(range(len(exp.data["feature_names"])))
  
      # sanity checks for `features`
      for ifeatures in features:
          if ifeatures > len(exp.data["feature_names"]):
              raise ValueError(
                  f"The `features` indices must be less than the "
                  f"``len(feature_names)={len(exp.data['feature_names'])}``. Received {ifeatures}."
              )
  
      # sanity check for `targets`
      for target in targets:
          if isinstance(target, str) and (
              target not in exp.meta["params"]["target_names"]
          ):
              raise ValueError(
                  f"Unknown `target` name. Received {target}. "
                  f"Available values are: {exp.meta['params']['target_names']}."
              )
  
          if isinstance(target, numbers.Integral) and (
              target > len(exp.meta["params"]["target_names"])
          ):  # type: ignore[operator]
              raise IndexError(
                  f"Target index out of range. Received {target}. "
                  f"The number of targets is {len(exp.meta['params']['target_names'])}."
              )
  
      if exp.meta["params"]["method"] == Method.IMPORTANCE:
          # plot feature importance
          return _plot_feature_importance(
              exp=exp,
              features=features,
              targets=targets,
              summarise=summarise,
              n_cols=n_cols,
              sort=sort,
              top_k=top_k,
              plot_limits=plot_limits,
              ax=ax,
              sharey=sharey,
              bar_kw=bar_kw,
              line_kw=line_kw,
              fig_kw=fig_kw,
          )
  
      # plot feature interaction
      return _plot_feature_interaction(
          exp=exp,
          features=features,
          targets=targets,
          summarise=summarise,
          n_cols=n_cols,
          sort=sort,
          top_k=top_k,
          plot_limits=plot_limits,
          ax=ax,
          sharey=sharey,
          bar_kw=bar_kw,
          line_kw=line_kw,
          fig_kw=fig_kw,
      )
  
imports: import copy
  import itertools
  import logging
  import math
  import numbers
  import sys
  from enum import Enum
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import matplotlib.pyplot
  import numpy
  from sklearn.base import BaseEstimator
  from alibi.api.defaults import DEFAULT_DATA_PD, DEFAULT_DATA_PDVARIANCE, DEFAULT_META_PDVARIANCE
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.explainers import plot_pd
  from alibi.explainers.partial_dependence import Kind, PartialDependence, TreePartialDependence
  from alibi.utils import _get_options_string
label_desc: Use image node_id 4 for calling a global function with example usage: plot_pd_variance(exp, features, targets, summarise, n_cols, sort, top_k, plot_limits, ax, sharey, bar_kw, line_kw, fig_kw) and returns: _plot_feature_interaction, _plot_feature_importance