code: def wrap_dims(
      n: int, nrow: Optional[int] = None, ncol: Optional[int] = None
  ) -> tuple[int, int]:
      """
      Wrap dimensions
      """
      if nrow is None:
          if ncol is None:
              return n_to_nrow_ncol(n)
          else:
              nrow = int(np.ceil(n / ncol))
  
      if ncol is None:
          ncol = int(np.ceil(n / nrow))
  
      if not nrow * ncol >= n:
          raise PlotnineError(
              "Allocated fewer panels than are required. "
              "Make sure the number of rows and columns can "
              "hold all the plot panels."
          )
      return (nrow, ncol)
  
file_path: plotnine/plotnine/facets/facet_wrap.py
imports: from __future__ import annotations
  import re
  import typing
  from warnings import warn
  import numpy
  import pandas
  from .._utils import join_keys, match
  from ..exceptions import PlotnineError, PlotnineWarning
  from .facet import add_missing_facets, combine_vars, eval_facet_vars, facet, layout_null
  from .strips import Strips, strip
label_desc: Use image node_id 3 for calling a global function with example usage: wrap_dims(n, nrow, ncol) and returns: nrow,  ncol, n_to_nrow_ncol