code: def mask_pixels(arr, mask_arr, vals=None):
      """Apply a mask to an input array.
  
      Masks values in an n-dimensional input array (arr) based on input
      1-dimensional array (mask_arr). If mask_arr is provided in a boolean
      format, it is used as a mask. If mask_arr is provided as a non-boolean
      format and values to mask (vals) are provided, a Boolean masked array is
      created from the mask_arr and the indicated vals to mask, and
      then this new 1-dimensional masked array is used to mask the input arr.
  
      This function is useful when masking cloud and other unwanted pixels.
  
      Parameters
      -----------
      arr : numpy array
          The array to mask in rasterio (band, row, col) order.
      mask_arr : numpy array
          An array of either the pixel_qa or mask of interest.
      vals : list of numbers either int or float (optional)
          A list of values from the pixel qa layer that will be used to create
          the mask for the final return array. If vals are not passed in,
          it is assumed the mask_arr given is the mask of interest.
  
      Returns
      -------
      arr : numpy array
          A numpy array populated with 1's where the mask is applied (a
          Boolean True) and the original numpy array's value where no masking
          was done.
  
      Example
      -------
      >>> import numpy as np
      >>> from earthpy.mask import mask_pixels
      >>> im = np.arange(9).reshape((3, 3))
      >>> im
      array([[0, 1, 2],
             [3, 4, 5],
             [6, 7, 8]])
      >>> im_mask = np.array([1, 1, 1, 0, 0, 0, 1, 1, 1]).reshape(3, 3)
      >>> im_mask
      array([[1, 1, 1],
             [0, 0, 0],
             [1, 1, 1]])
      >>> mask_pixels(im, mask_arr=im_mask, vals=[1])
      masked_array(
        data=[[--, --, --],
              [3, 4, 5],
              [--, --, --]],
        mask=[[ True,  True,  True],
              [False, False, False],
              [ True,  True,  True]],
        fill_value=999999)
      """
  
      try:
          arr.ndim
      except AttributeError:
          raise AttributeError("Input arr should be a numpy array.")
  
      try:
          mask_arr.ndim
      except AttributeError:
          raise AttributeError("Input arr should be a numpy array.")
  
      if vals:
          cover_mask = _create_mask(mask_arr, vals)
      else:
          # Check to make sure the mask_arr is a boolean
          if np.array_equal(mask_arr, mask_arr.astype(bool)):
              cover_mask = mask_arr.astype(bool)
          else:
              raise ValueError(
                  "You have provided a mask_array with no values to mask. "
                  "Please either provide a mask_array of type bool, or provide "
                  "values to be used to create a mask."
              )
      return _apply_mask(arr, cover_mask)
  
imports: import numpy
  import numpy.ma
label_desc: Use image node_id 3 for calling a global function with example usage: mask_pixels(arr, mask_arr, vals) and returns: _apply_mask