code: def _draw_legend_pce(
      legend,
      split_legend,
      styles,
      linestyles,
      colors,
      cmap,
      do_topo,
      ax,
  ):
      """Draw legend for plot_compare_evokeds."""
      import matplotlib.lines as mlines
  
      lines = list()
      # triage
      if split_legend is None:
          split_legend = cmap is not None
      n_colors = len(set(colors.values()))
      n_linestyles = len(set(linestyles.values()))
      draw_styles = cmap is None and not split_legend
      draw_colors = cmap is None and split_legend and n_colors > 1
      draw_linestyles = (
          cmap is None or split_legend
      ) and n_linestyles > 1
      # create the fake lines for the legend
      if draw_styles:
          for label, cond_styles in styles.items():
              line = mlines.Line2D([], [], label=label, **cond_styles)
              lines.append(line)
      else:
          if draw_colors:
              for label, color in colors.items():
                  line = mlines.Line2D(
                      [],
                      [],
                      label=label,
                      linestyle="solid",
                      color=color,
                  )
                  lines.append(line)
          if draw_linestyles:
              for label, linestyle in linestyles.items():
                  line = mlines.Line2D(
                      [],
                      [],
                      label=label,
                      linestyle=linestyle,
                      color="black",
                  )
                  lines.append(line)
      # legend params
      ncol = 1 + (len(lines) // 5)
      loc = _check_loc_legal(legend, "legend")
      legend_params = dict(loc=loc, frameon=True, ncol=ncol)
      # special placement (above dedicated legend axes) in topoplot
      if do_topo and isinstance(legend, bool):
          legend_params.update(loc="lower right", bbox_to_anchor=(1, 1))
      # draw the legend
      if any([draw_styles, draw_colors, draw_linestyles]):
          labels = [
              _abbreviate_label(line.get_label()) for line in lines
          ]
          ax.legend(lines, labels, **legend_params)
  
imports: from copy import deepcopy
  from functools import partial
  from itertools import cycle
  from numbers import Integral
  import numpy
  from .._fiff.pick import _DATA_CH_TYPES_SPLIT, _PICK_TYPES_DATA_DICT, _VALID_CHANNEL_TYPES, _picks_to_idx, channel_indices_by_type, channel_type, pick_info
  from ..defaults import _handle_default
  from ..fixes import _is_last_row
  from ..utils import _check_ch_locs, _check_if_nan, _clean_names, _is_numeric, _pl, _to_rgb, _validate_type, fill_doc, logger, verbose, warn
  from .topo import _plot_evoked_topo
  from .topomap import _check_sphere, _draw_outlines, _get_pos_outlines, _make_head_outlines, _prepare_topomap, _prepare_topomap_plot, _set_contour_locator, plot_topomap
  from .utils import DraggableColorbar, _check_cov, _check_delayed_ssp, _check_option, _check_time_unit, _draw_proj_checkbox, _get_cmap, _get_color_list, _make_combine_callable, _plot_masked_image, _prepare_joint_axes, _process_times, _prop_kw, _set_title_multiple_electrodes, _set_window_title, _setup_ax_spines, _setup_cmap, _setup_plot_projector, _setup_vmin_vmax, _triage_rank_sss, _trim_ticks, _validate_if_list_of_axes, plt_show
label_desc: Use image node_id 29 for calling a global function with example usage: _draw_legend_pce(legend, split_legend, styles, linestyles, colors, cmap, do_topo, ax) without return types