docstr: Modify the density data structure to handle multiple densities.
docstr_tok: ["Modify","the","density","data","structure","to","handle","multiple","densities","."]
code: def _resolve_multiple(self, curves, multiple):
      """Modify the density data structure to handle multiple densities."""
  
      # Default baselines have all densities starting at 0
      baselines = {k: np.zeros_like(v) for k, v in curves.items()}
  
      # TODO we should have some central clearinghouse for checking if any
      # "grouping" (terminnology?) semantics have been assigned
      if "hue" not in self.variables:
          return curves, baselines
  
      if multiple in ("stack", "fill"):
          # Setting stack or fill means that the curves share a
          # support grid / set of bin edges, so we can make a dataframe
          # Reverse the column order to plot from top to bottom
          curves = pd.DataFrame(curves).iloc[:, ::-1]
  
          # Find column groups that are nested within col/row variables
          column_groups = {}
          for i, keyd in enumerate(map(dict, curves.columns)):
              facet_key = keyd.get("col", None), keyd.get("row", None)
              column_groups.setdefault(facet_key, [])
              column_groups[facet_key].append(i)
  
          baselines = curves.copy()
  
          for col_idxs in column_groups.values():
              cols = curves.columns[col_idxs]
  
              norm_constant = curves[cols].sum(axis="columns")
  
              # Take the cumulative sum to stack
              curves[cols] = curves[cols].cumsum(axis="columns")
  
              # Normalize by row sum to fill
              if multiple == "fill":
                  curves[cols] = curves[cols].div(
                      norm_constant, axis="index"
                  )
  
              # Define where each segment starts
              baselines[cols] = curves[cols].shift(1, axis=1).fillna(0)
  
      if multiple == "dodge":
          # Account for the unique semantic (non-faceting) levels
          # This will require rethiniking if we add other semantics!
          hue_levels = self.var_levels["hue"]
          n = len(hue_levels)
          f_fwd, f_inv = self._get_scale_transforms(self.data_variable)
          for key in curves:
              level = dict(key)["hue"]
              hist = curves[key].reset_index(name="heights")
              level_idx = hue_levels.index(level)
  
              a = f_fwd(hist["edges"])
              b = f_fwd(hist["edges"] + hist["widths"])
              w = (b - a) / n
              new_min = f_inv(a + level_idx * w)
              new_max = f_inv(a + (level_idx + 1) * w)
              hist["widths"] = new_max - new_min
              hist["edges"] = new_min
  
              curves[key] = hist.set_index(["edges", "widths"])[
                  "heights"
              ]
  
      return curves, baselines
  
imports: from numbers import Number
  from functools import partial
  import math
  import textwrap
  import warnings
  import numpy
  import pandas
  import matplotlib
  import matplotlib.pyplot
  import matplotlib.transforms
  from matplotlib.cbook import normalize_kwargs
  from matplotlib.colors import to_rgba
  from matplotlib.collections import LineCollection
  from ._base import VectorPlotter
  from ._statistics import ECDF, Histogram, KDE
  from ._stats.counting import Hist
  from .axisgrid import FacetGrid, _facet_docs
  from .utils import remove_na, _get_transform_functions, _kde_support, _check_argument, _assign_default_kwargs, _default_color
  from .palettes import color_palette
  from .external import husl
  from .external.kde import gaussian_kde
  from ._docstrings import DocstringComponents, _core_docs
label_desc: Use image node_id 10 for calling the _DistributionPlotter obj's underlying member method code with example usage: obj._resolve_multiple(curves, multiple) and returns: curves,  baselines, curves,  baselines