code: def _parse_legend_args(axs, *args, **kwargs):
      """
      Get the handles and labels from the calls to either ``figure.legend``
      or ``axes.legend``.
  
      ``axs`` is a list of axes (to get legend artists from)
      """
      log = logging.getLogger(__name__)
  
      handlers = kwargs.get("handler_map", {}) or {}
  
      # Support handles and labels being passed as keywords.
      handles = kwargs.pop("handles", None)
      labels = kwargs.pop("labels", None)
  
      extra_args = ()
  
      if (handles is not None or labels is not None) and len(args):
          warnings.warn(
              "You have mixed positional and keyword "
              "arguments, some input may be "
              "discarded."
          )
  
      # if got both handles and labels as kwargs, make same length
      if handles and labels:
          handles, labels = zip(*zip(handles, labels))
  
      elif handles is not None and labels is None:
          labels = [handle.get_label() for handle in handles]
  
      elif labels is not None and handles is None:
          # Get as many handles as there are labels.
          handles = [
              handle
              for handle, label in zip(
                  _get_legend_handles(axs, handlers), labels
              )
          ]
  
      # No arguments - automatically detect labels and handles.
      elif len(args) == 0:
          handles, labels = _get_legend_handles_labels(axs, handlers)
          if not handles:
              log.warning(
                  "No handles with labels found to put in legend."
              )
  
      # One argument. User defined labels - automatic handle detection.
      elif len(args) == 1:
          (labels,) = args
          # Get as many handles as there are labels.
          handles = [
              handle
              for handle, label in zip(
                  _get_legend_handles(axs, handlers), labels
              )
          ]
  
      # Two arguments:
      #   * user defined handles and labels
      elif len(args) >= 2:
          handles, labels = args[:2]
          extra_args = args[2:]
  
      else:
          raise TypeError("Invalid arguments to legend.")
  
      return handles, labels, extra_args, kwargs
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  import logging
  import warnings
  import numpy
  from matplotlib import rcParams
  from matplotlib import docstring
  from matplotlib.artist import Artist, allow_rasterization
  from matplotlib.cbook import silent_list, is_hashable
  import matplotlib.colors
  from matplotlib.font_manager import FontProperties
  from matplotlib.lines import Line2D
  from matplotlib.patches import Patch, Rectangle, Shadow, FancyBboxPatch
  from matplotlib.collections import LineCollection, RegularPolyCollection, CircleCollection, PathCollection, PolyCollection
  from matplotlib.transforms import Bbox, BboxBase, TransformedBbox
  from matplotlib.transforms import BboxTransformTo, BboxTransformFrom
  from matplotlib.offsetbox import HPacker, VPacker, TextArea, DrawingArea
  from matplotlib.offsetbox import DraggableOffsetBox
  from matplotlib.container import ErrorbarContainer, BarContainer, StemContainer
  from .None import legend_handler
label_desc: Use image node_id 3 for calling a global function with example usage: _parse_legend_args(axs) and returns: handles,  labels,  extra_args,  kwargs