code: def mix_colormaps(fg, bg):
      """Mixes foreground and background arrays of RGBA colors.
  
      Parameters
      ----------
      fg : numpy.ndarray
          Array of shape (n, 4), foreground RGBA colors
          represented as floats in [0, 1]
      bg : numpy.ndarray
          Array of shape (n, 4), background RGBA colors
          represented as floats in [0, 1]
  
      Returns
      -------
      mix : numpy.ndarray
          Array of shape (n, 4), mixed colors
          represented as floats in [0, 1]
      """
      # Adapted from https://stackoverflow.com/questions/726549/algorithm-for-additive-color-mixing-for-rgb-values/727339#727339 # noqa: E501
      if fg.shape != bg.shape:
          raise ValueError(
              "Trying to mix colormaps with different shapes: "
              f"{fg.shape}, {bg.shape}"
          )
  
      mix = _np.empty_like(fg)
  
      mix[:, 3] = 1 - (1 - fg[:, 3]) * (1 - bg[:, 3])
  
      for color_index in range(0, 3):
          mix[:, color_index] = (
              fg[:, color_index] * fg[:, 3]
              + bg[:, color_index] * bg[:, 3] * (1 - fg[:, 3])
          ) / mix[:, 3]
  
      return mix
  
file_path: nilearn/nilearn/plotting/cm.py
imports: import numpy
  from matplotlib import cm, colors, rcParams
label_desc: Use image node_id 1 for calling a global function with example usage: mix_colormaps(fg, bg) and returns: mix