code: def plot_objective_2D(
      result,
      dimension_identifier1,
      dimension_identifier2,
      n_points=40,
      n_samples=250,
      levels=10,
      zscale="linear",
      sample_source="random",
      minimum="result",
      n_minimum_search=None,
      ax=None,
  ):
      """
      Create and return a Matplotlib figure and axes with a landscape
      contour-plot of the last fitted model of the search-space,
      overlaid with all the samples from the optimization results,
      for the two given dimensions of the search-space.
  
      This is similar to `plot_objective()` but only for 2 dimensions
      whose doc-string also has a more extensive explanation.
  
      Parameters
      ----------
      result : `OptimizeResult`
          The optimization results e.g. from calling `gp_minimize()`.
  
      dimension_identifier1 : str or int
          Name or index of a dimension in the search-space.
  
      dimension_identifier2 : str or int
          Name or index of a dimension in the search-space.
  
      n_samples : int, default=250
          Number of random samples used for estimating the contour-plot
          of the objective function.
  
      n_points : int, default=40
          Number of points along each dimension where the partial dependence
          is evaluated when generating the contour-plots.
  
      levels : int, default=10
          Number of levels to draw on the contour plot.
  
      zscale : str, default='linear'
          Scale to use for the z axis of the contour plots.
          Either 'log' or linear for all other choices.
  
      ax : `Matplotlib.Axes`, default: None
          When set, everything is plotted inside this axis.
  
      Returns
      -------
      ax : `Matplotlib.Axes`
          The Matplotlib Figure-object.
          For example, you can save the plot by calling
          `fig.savefig('file.png')`
      """
  
      # Get the search-space instance from the optimization results.
      space = result.space
      x_vals = _evaluate_min_params(result, minimum, n_minimum_search)
      if sample_source == "random":
          x_eval = None
          samples = space.transform(space.rvs(n_samples=n_samples))
      else:
          x_eval = _evaluate_min_params(
              result, sample_source, n_minimum_search
          )
          samples = space.transform([x_eval])
      x_samples, x_minimum, _ = _map_categories(
          space, result.x_iters, x_vals
      )
      # Get the dimension-object, its index in the search-space, and its name.
      index1, dimension1 = space[dimension_identifier1]
      index2, dimension2 = space[dimension_identifier2]
  
      # Get the samples from the optimization-log for the relevant dimensions.
      # samples1 = get_samples_dimension(result=result, index=index1)
      samples1 = x_samples[:, index1]
      samples2 = x_samples[:, index2]
      # samples2 = get_samples_dimension(result=result, index=index2)
  
      # Get the best-found samples for the relevant dimensions.
      best_sample1 = x_minimum[index1]
      best_sample2 = x_minimum[index2]
  
      # Get the last fitted model for the search-space.
      last_model = result.models[-1]
  
      # Estimate the objective function for these sampled points
      # using the last fitted model for the search-space.
      xi, yi, zi = partial_dependence_2D(
          space, last_model, index2, index1, samples, n_points=n_points
      )
  
      if ax is None:
          ax = plt.gca()
  
      # Scale for the z-axis of the contour-plot. Either Log or Linear (None).
      locator = LogLocator() if zscale == "log" else None
  
      # Plot the contour-landscape for the objective function.
      ax.contourf(xi, yi, zi, levels, locator=locator, cmap="viridis_r")
  
      # Plot all the parameters that were sampled during optimization.
      # These are plotted as small black dots.
      ax.scatter(samples1, samples2, c="black", s=10, linewidths=1)
  
      # Plot the best parameters that were sampled during optimization.
      # These are plotted as a big red star.
      ax.scatter(
          best_sample1,
          best_sample2,
          c="red",
          s=50,
          linewidths=1,
          marker="*",
      )
  
      # Use the dimension-names as the labels for the plot-axes.
      ax.set_xlabel(dimension1.name)
      ax.set_ylabel(dimension2.name)
      ax.autoscale(enable=True, axis="x", tight=True)
      ax.autoscale(enable=True, axis="y", tight=True)
      # Use log-scale on the x-axis?
      if dimension1.prior == "log-uniform":
          ax.set_xscale("log")
  
      # Use log-scale on the y-axis?
      if dimension2.prior == "log-uniform":
          ax.set_yscale("log")
      return ax
  
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 11 for calling a global function with example usage: plot_objective_2D(result, dimension_identifier1, dimension_identifier2, n_points, n_samples, levels, zscale, sample_source, minimum, n_minimum_search, ax) and returns: ax