def cursor(pickables=None, **kwargs):
if pickables is None:<EOL><INDENT>plt = sys.modules.get("<STR_LIT>")<EOL>pickables = [<EOL>plt.figure(num) for num in plt.get_fignums()] if plt else []<EOL><DEDENT>elif (isinstance(pickables, Container)<EOL>or not isinstance(pickables, Iterable)):<EOL><INDENT>pickables = [pickables]<EOL><DEDENT>def iter_unpack_figures(pickables):<EOL><INDENT>for entry in pickables:<EOL><INDENT>if isinstance(entry, Figure):<EOL><INDENT>yield from entry.axes<EOL><DEDENT>else:<EOL><INDENT>yield entry<EOL><DEDENT><DEDENT><DEDENT>def iter_unpack_axes(pickables):<EOL><INDENT>for entry in pickables:<EOL><INDENT>if isinstance(entry, Axes):<EOL><INDENT>yield from _iter_axes_subartists(entry)<EOL>containers.extend(entry.containers)<EOL><DEDENT>elif isinstance(entry, Container):<EOL><INDENT>containers.append(entry)<EOL><DEDENT>else:<EOL><INDENT>yield entry<EOL><DEDENT><DEDENT><DEDENT>containers = []<EOL>artists = list(iter_unpack_axes(iter_unpack_figures(pickables)))<EOL>for container in containers:<EOL><INDENT>contained = list(filter(None, container.get_children()))<EOL>for artist in contained:<EOL><INDENT>with suppress(ValueError):<EOL><INDENT>artists.remove(artist)<EOL><DEDENT><DEDENT>if contained:<EOL><INDENT>artists.append(_pick_info.ContainerArtist(container))<EOL><DEDENT><DEDENT>return Cursor(artists, **kwargs)<EOL>
Create a `Cursor` for a list of artists, containers, and axes.

Parameters
----------

pickables : Optional[List[Union[Artist, Container, Axes, Figure]]]
    All artists and containers in the list or on any of the axes or
    figures passed in the list are selectable by the constructed `Cursor`.
    Defaults to all artists and containers on any of the figures that
    :mod:`~matplotlib.pyplot` is tracking.  Note that the latter will only
    work when relying on pyplot, not when figures are directly instantiated
    (e.g., when manually embedding Matplotlib in a GUI toolkit).

**kwargs
    Keyword arguments are passed to the `Cursor` constructor.