code: def test_masked_vals():
      """Legend for masked array plots properly."""
  
      im_arr = np.random.uniform(-2, 1, (15, 15))
      bins = [-0.8, -0.2, 0.2, 0.8, np.Inf]
      im_arr_bin = np.digitize(im_arr, bins)
      arr_bin_ma = np.ma.masked_equal(im_arr_bin, 0)
      unmasked_vals = [
          val
          for val in np.unique(arr_bin_ma)
          if val is not np.ma.core.masked
      ]
  
      f, ax = plt.subplots()
      im_ax = ax.imshow(arr_bin_ma)
      leg = ep.draw_legend(im_ax)
      legend_cols = [i.get_facecolor() for i in leg.get_patches()]
      assert len(legend_cols) == len(unmasked_vals)
      plt.close(f)
  
imports: import numpy
  import pytest
  import matplotlib
  import matplotlib.pyplot
  from matplotlib.colors import ListedColormap
  import earthpy.plot
label_desc: Use image node_id 20 for calling a global function with example usage: test_masked_vals() without return types