class_docstr: Legend guide
  
  Parameters
  ----------
  nrow : int, default=None
      Number of rows of legends.
  ncol : int, default=None
      Number of columns of legends.
  byrow : bool, default=False
      Whether to fill the legend row-wise or column-wise.
  keywidth : float, default=None
      Width of the legend key.
  keyheight : float, default=None
      Height of the legend key.
  kwargs : dict
      Parameters passed on to [](`~plotnine.guides.guide`).
code: def _set_defaults(self, theme):
      guide._set_defaults(self, theme)
      _property = theme.themeables.property
      self.nrow, self.ncol = self._calculate_rows_and_cols()
      nbreak = len(self.key)
  
      # key width and key height for each legend entry
      #
      # Take a peak into data['size'] to make sure the
      # legend dimensions are big enough
      """
         (ggplot(diamonds, aes(x="cut", y="clarity"))
          + stat_sum(aes(group="cut"))
          + scale_size(range=(3, 25)
         )
  
          Note the different height sizes for the entries
          """
  
      # FIXME: This should be in the geom instead of having
      # special case conditional branches
      def determine_side_length(initial_size):
          default_pad = initial_size * 0.5
          # default_pad = 0
          size = np.ones(nbreak) * initial_size
          for i in range(nbreak):
              for gl in self.glayers:
                  _size = 0
                  pad = default_pad
                  # Full size of object to appear in the
                  # legend key
                  with suppress(IndexError):
                      if "size" in gl.data:
                          _size = gl.data["size"].iloc[i] * SIZE_FACTOR
                          if "stroke" in gl.data:
                              _size += (
                                  2
                                  * gl.data["stroke"].iloc[i]
                                  * SIZE_FACTOR
                              )
  
                      # special case, color does not apply to
                      # border/linewidth
                      if isinstance(gl.geom, geom_text):
                          pad = 0
                          if _size < initial_size:
                              continue
  
                      try:
                          # color(edgecolor) affects size(linewidth)
                          # When the edge is not visible, we should
                          # not expand the size of the keys
                          if gl.data["color"].iloc[i] is not None:
                              size[i] = np.max([_size + pad, size[i]])
                      except KeyError:
                          break
  
          return size
  
      # keysize
      if self.keywidth is None:
          width = determine_side_length(_property("legend_key_width"))
          if self.direction == "vertical":
              width[:] = width.max()
          self._keywidth = width
      else:
          self._keywidth = [self.keywidth] * nbreak
  
      if self.keyheight is None:
          height = determine_side_length(_property("legend_key_height"))
          if self.direction == "horizontal":
              height[:] = height.max()
          self._keyheight = height
      else:
          self._keyheight = [self.keyheight] * nbreak
  
imports: from __future__ import annotations
  import hashlib
  import types
  import typing
  from contextlib import suppress
  from itertools import islice
  from warnings import warn
  import numpy
  import pandas
  from .._utils import SIZE_FACTOR, remove_missing
  from ..exceptions import PlotnineError, PlotnineWarning
  from ..geoms import geom_text
  from ..mapping.aes import rename_aesthetics
  from .guide import guide
label_desc: Use image node_id 5 for calling the guide_legend obj's underlying member method code with example usage: obj._set_defaults(theme) and returns: size