code: def save_as_pdf_pages(
      plots: Iterable[ggplot],
      filename: Optional[str | Path] = None,
      path: str | None = None,
      verbose: bool = True,
      **kwargs: Any,
  ):
      """
      Save multiple [](`~plotnine.ggplot`) objects to a PDF file, one per page.
  
      Parameters
      ----------
      plots :
          Plot objects to write to file. `plots` may be either a
          collection such as a :py:class:`list` or :py:class:`set`:
  
          ```python
          base_plot = ggplot(…)
          plots = [base_plot + ggtitle('%d of 3' % i) for i in range(1, 3)]
          save_as_pdf_pages(plots)
          ```
  
          or, a generator that yields [](`~plotnine.ggplot`) objects:
  
          ```python
          def myplots():
              for i in range(1, 3):
                  yield ggplot(…) + ggtitle('%d of 3' % i)
          save_as_pdf_pages(myplots())
          ```
      filename :
          File name to write the plot to. If not specified, a name
          like “plotnine-save-<hash>.pdf” is used.
      path :
          Path to save plot to (if you just want to set path and
          not filename).
      verbose :
          If `True`, print the saving information.
      kwargs :
          Additional arguments to pass to
          :py:meth:`matplotlib.figure.Figure.savefig`.
  
      Notes
      -----
      Using pandas :meth:`~pandas.DataFrame.groupby` methods, tidy data
      can be “faceted” across pages:
  
      ```python
      from plotnine.data import mtcars
  
      def facet_pages(column)
          base_plot = [
              aes(x='wt', y='mpg', label='name'),
              geom_text(),
              ]
          for label, group_data in mtcars.groupby(column):
              yield ggplot(group_data) + base_plot + ggtitle(label)
  
      save_as_pdf_pages(facet_pages('cyl'))
      ```
  
      Unlike :meth:`ggplot.save`, :meth:`save_as_pdf_pages` does not
      process arguments for `height` or `width`. To set the figure size,
      add [](`~plotnine.themes.themeable.figure_size`) to the theme
      for some or all of the objects in `plots`:
  
      ```python
      plot = ggplot(…)
      # The following are equivalent
      plot.save('filename.pdf', height=6, width=8)
      save_as_pdf_pages([plot + theme(figure_size=(8, 6))])
      ```
      """
      from matplotlib.backends.backend_pdf import PdfPages
  
      # as in ggplot.save()
      fig_kwargs = {"bbox_inches": "tight"}
      fig_kwargs.update(kwargs)
  
      # If plots is already an iterator, this is a no-op; otherwise
      # convert a list, etc. to an iterator
      plots = iter(plots)
  
      # filename, depends on the object
      if filename is None:
          # Take the first element from the iterator, store it, and
          # use it to generate a file name
          peek = [next(plots)]
          plots = chain(peek, plots)
          filename = peek[0]._save_filename("pdf")
  
      if path:
          filename = Path(path) / filename
  
      if verbose:
          warn(f"Filename: {filename}", PlotnineWarning)
  
      with PdfPages(filename, keep_empty=False) as pdf:
          # Re-add the first element to the iterator, if it was removed
          for plot in plots:
              fig = plot.draw()
              # Save as a page in the PDF file
              pdf.savefig(fig, **fig_kwargs)
  
imports: from __future__ import annotations
  import typing
  from collections.abc import Sequence
  from copy import copy, deepcopy
  from io import BytesIO
  from itertools import chain
  from pathlib import Path
  from types import SimpleNamespace
  from typing import Any, Dict, Iterable, Optional
  from warnings import warn
  from ._utils import from_inches, is_data_like, order_as_data_mapping, to_inches, ungroup
  from ._utils.context import plot_context
  from ._utils.ipython import get_display_function, get_ipython, is_inline_backend
  from .coords import coord_cartesian
  from .exceptions import PlotnineError, PlotnineWarning
  from .facets import facet_null
  from .facets.layout import Layout
  from .geoms.geom_blank import geom_blank
  from .guides.guides import guides
  from .iapi import mpl_save_view
  from .layer import Layers
  from .mapping.aes import aes, make_labels
  from .options import get_option
  from .scales.scales import Scales
  from .themes.theme import theme, theme_get
label_desc: Use image node_id 1 for calling a global function with example usage: save_as_pdf_pages(plots, filename, path, verbose) without return types