code: def _sum_masks(
      masks: list[Optional[jnp.ndarray]],
  ) -> Optional[jnp.ndarray]:
      def add_two_masks(mask1, mask2):
          if mask1 is None:
              return mask2
  
          if mask2 is None:
              return mask1
  
          return mask1 & mask2
  
      mask = functools.reduce(add_two_masks, masks, None)
      return mask
  
imports: import functools
  from typing import Callable, Iterable, Optional, Sequence
  import warnings
  from jax import numpy
  import jax.example_libraries.stax
  from ..utils.kernel import Kernel
  from ..utils.typing import InternalLayer
  from ..utils.typing import InternalLayerMasked
  from ..utils.typing import Kernels
  from .requirements import layer
  from .requirements import supports_masking
label_desc: Use image node_id 6 for calling a global function with example usage: _sum_masks(masks) and returns: mask, unknown, mask2, mask1