code: def partial_dependence(
      space,
      model,
      i,
      j=None,
      sample_points=None,
      n_samples=250,
      n_points=40,
      x_eval=None,
  ):
      """Calculate the partial dependence for dimensions `i` and `j` with
      respect to the objective value, as approximated by `model`.
  
      The partial dependence plot shows how the value of the dimensions
      `i` and `j` influence the `model` predictions after "averaging out"
      the influence of all other dimensions.
  
      When `x_eval` is not `None`, the given values are used instead of
      random samples. In this case, `n_samples` will be ignored.
  
      Parameters
      ----------
      space : `Space`
          The parameter space over which the minimization was performed.
  
      model
          Surrogate model for the objective function.
  
      i : int
          The first dimension for which to calculate the partial dependence.
  
      j : int, default=None
          The second dimension for which to calculate the partial dependence.
          To calculate the 1D partial dependence on `i` alone set `j=None`.
  
      sample_points : np.array, shape=(n_points, n_dims), default=None
          Only used when `x_eval=None`, i.e in case partial dependence should
          be calculated.
          Randomly sampled and transformed points to use when averaging
          the model function at each of the `n_points` when using partial
          dependence.
  
      n_samples : int, default=100
          Number of random samples to use for averaging the model function
          at each of the `n_points` when using partial dependence. Only used
          when `sample_points=None` and `x_eval=None`.
  
      n_points : int, default=40
          Number of points at which to evaluate the partial dependence
          along each dimension `i` and `j`.
  
      x_eval : list, default=None
          `x_eval` is a list of parameter values or None. In case `x_eval`
          is not None, the parsed dependence will be calculated using these
          values.
          Otherwise, random selected samples will be used.
  
      Returns
      -------
      For 1D partial dependence:
  
      xi : np.array
          The points at which the partial dependence was evaluated.
  
      yi : np.array
          The value of the model at each point `xi`.
  
      For 2D partial dependence:
  
      xi : np.array, shape=n_points
          The points at which the partial dependence was evaluated.
      yi : np.array, shape=n_points
          The points at which the partial dependence was evaluated.
      zi : np.array, shape=(n_points, n_points)
          The value of the model at each point `(xi, yi)`.
  
      For Categorical variables, the `xi` (and `yi` for 2D) returned are
      the indices of the variable in `Dimension.categories`.
      """
      # If we haven't parsed an x_eval list we use random sampled values instead
      if x_eval is None and sample_points is None:
          sample_points = space.transform(
              space.rvs(n_samples=n_samples)
          )
      elif sample_points is None:
          sample_points = space.transform([x_eval])
  
      if j is None:
          return partial_dependence_1D(
              space, model, i, sample_points, n_points
          )
      else:
          return partial_dependence_2D(
              space, model, i, j, sample_points, n_points
          )
  
imports: import sys
  import numpy
  from itertools import count
  from functools import partial
  from scipy.optimize import OptimizeResult
  from .acquisition import _gaussian_acquisition
  from guild._skopt import expected_minimum, expected_minimum_random_sampling
  from .space import Categorical
  from collections import Counter
  import matplotlib.pyplot
  from matplotlib.pyplot import cm
  from matplotlib.ticker import LogLocator
  from matplotlib.ticker import MaxNLocator, FuncFormatter
label_desc: Use image node_id 5 for calling a global function with example usage: partial_dependence(space, model, i, j, sample_points, n_samples, n_points, x_eval) and returns: partial_dependence_1D, partial_dependence_2D