code: def _cap_alpha(alpha_arr, alpha_limit):
      # type: (np.ndarray, Union[None, float, int]) -> np.ndarray
      """
      Limit the alpha values in ``alpha_arr``
      by setting the maximum alpha value to ``alpha_limit``.
      Returns a a new array with the values capped.
      """
      if alpha_limit is None:
          return alpha_arr
      elif isinstance(alpha_limit, (float, int)):
          if 0 <= alpha_limit <= 1:
              new_alpha = np.minimum(alpha_arr, alpha_limit)
              return new_alpha
          else:
              raise ValueError(
                  "alpha_limit must be"
                  "between 0 and 1 inclusive, got: %f" % alpha_limit
              )
      else:
          raise TypeError(
              "alpha_limit must be int or float,"
              "got: {}".format(alpha_limit)
          )
  
file_path: eli5/eli5/formatters/image.py
imports: from __future__ import absolute_import
  from typing import Union, Optional, Callable
  import numpy
  from PIL import Image
  import matplotlib.cm
  from eli5.base import Explanation
label_desc: Use image node_id 6 for calling a global function with example usage: _cap_alpha(alpha_arr, alpha_limit) and returns: alpha_arr, new_alpha