code: def _handle_nodatavals(data, nodata_handling):
      """Mask data with np.nan or only set 'attr_FillValue'."""
      if nodata_handling == NODATA_HANDLING_NANMASK:
          # data converted to float and masked with np.nan
          data = data.astype(np.float32)
          masked_data = da.stack(
              [
                  da.where(
                      data.data[i, :, :] == nodataval,
                      np.nan,
                      data.data[i, :, :],
                  )
                  for i, nodataval in enumerate(data.nodatavals)
              ]
          )
          data.data = masked_data
          data.attrs["_FillValue"] = np.nan
      elif nodata_handling == NODATA_HANDLING_FILLVALUE:
          # keep data as it is but set _FillValue attribute to provided
          # nodatavalue (first one as it has to be the same for all bands at least
          # in GeoTiff, see GDAL gtiff driver documentation)
          fill_value = data.nodatavals[0]
          if np.issubdtype(data.dtype, np.integer):
              fill_value = int(fill_value)
          data.attrs["_FillValue"] = fill_value
      return data
  
file_path: satpy/satpy/readers/generic_image.py
imports: import logging
  import dask.array
  import numpy
  import rasterio
  import xarray
  from pyresample import utils
  from satpy.readers.file_handlers import BaseFileHandler
  from satpy.utils import get_legacy_chunk_size
label_desc: Use image node_id 2 for calling a global function with example usage: _handle_nodatavals(data, nodata_handling) and returns: data