code: def _grid_search_single(grid_scores, change, subset, kind, ax, sort):
      # the logic of this function is to group the grid scores acording
      # to certain rules and subsequently remove the elements that we are
      # not interested in, until we have only the elements that the user
      # wants to plot
  
      # get a set with all the parameters
      params = set(grid_scores[0].parameters.keys())
  
      # remove parameter to vary from the list
      # since we are not filtering on that parameter
      try:
          params.remove(change)
      except KeyError:
          raise ValueError("{} is not a valid parameter".format(change))
  
      # now need need to filter out the grid_scores that the user
      # didn't select, for that we have to cases, the first one is when
      # the user explicitely selected some values
      if subset:
          # group the grid_scores based on the values the user selected
          # in subset
          groups = _group_by(
              grid_scores, _get_params_value(subset.keys())
          )
          keys = _mapping_to_tuple_pairs(subset)
          groups = {
              k: v
              for k, v in _sorted_map_iter(groups, sort)
              if k in keys
          }
          grid_scores = _flatten_list(groups.values())
          groups = _group_by(grid_scores, _get_params_value(params))
          if not groups:
              raise ValueError(
                  (
                      "Your subset didn't match any data"
                      " verify that the values are correct."
                  )
              )
      # if the user didn't select any values don't filter anything
      # just group the grid_scores depending on the values they
      # have for the parameters
      else:
          groups = _group_by(grid_scores, _get_params_value(params))
  
      if kind == "bar":
          change_unique = len(
              set([g.parameters[change] for g in grid_scores])
          )
          # bar shifter is just a wrapper around matplotlib's bar plot
          # to automatically calculate the left position on each bar
          bar_shifter = BarShifter(
              g_number=change_unique, g_size=len(groups), ax=ax
          )
  
      for params_kv, group in _sorted_map_iter(groups, sort):
          # get the x and y values for each grid_score on this group
          # also calculate the std
          x = [element.parameters[change] for element in group]
          y = [element.mean_validation_score for element in group]
          stds = [element.std_test_score for element in group]
  
          # take (param, value) and convert them to 'param: value'
          label = ["{}: {}".format(*t) for t in params_kv]
          # now convert it to one string
          label = ", ".join(label)
  
          if kind == "bar":
              bar_shifter(y, yerr=stds, label=label)
          elif kind == "line":
              is_categorical = isinstance(x[0], string_types)
              if is_categorical:
                  ints = range(len(x))
                  ax.errorbar(ints, y, yerr=stds, label=label)
                  ax.set_xticks(ints)
              else:
                  ax.errorbar(x, y, yerr=stds, label=label)
                  ax.set_xticks(x)
  
      ax.set_xticklabels(x)
      ax.set_title("Grid search results")
      ax.set_ylabel("Mean score")
      ax.set_xlabel(change)
      ax.legend(loc="best")
      ax.margins(0.05)
      return ax
  
file_path: sklearn-evaluation/src/sklearn_evaluation/plot/grid_search.py
imports: import collections
  import matplotlib.pyplot
  import numpy
  from six import string_types
  from ..telemetry import SKLearnEvaluationLogger
  from sklearn_evaluation.plot.matplotlib.bar import BarShifter
  from ploomber_core.exceptions import modify_exceptions
  from ..util import _group_by, _get_params_value, _mapping_to_tuple_pairs, default_heatmap, _sorted_map_iter, _flatten_list
label_desc: Use image node_id 2 for calling a global function with example usage: _grid_search_single(grid_scores, change, subset, kind, ax, sort) and returns: ax