code: def _mask_image_data(data, info):
      """Mask image data if necessary.
  
      Masking is done if alpha channel is present or
      dataset 'nodata_handling' is set to 'nan_mask'.
      In the latter case even integer data is converted
      to float32 and masked with np.nan.
      """
      if data.bands.size in (2, 4):
          if not np.issubdtype(data.dtype, np.integer):
              raise ValueError(
                  "Only integer datatypes can be used as a mask."
              )
          mask = data.data[-1, :, :] == np.iinfo(data.dtype).min
          data = data.astype(np.float64)
          masked_data = da.stack(
              [
                  da.where(mask, np.nan, data.data[i, :, :])
                  for i in range(data.shape[0])
              ]
          )
          data.data = masked_data
          data = data.sel(bands=BANDS[data.bands.size - 1])
      elif hasattr(data, "nodatavals") and data.nodatavals:
          data = _handle_nodatavals(
              data,
              info.get("nodata_handling", NODATA_HANDLING_FILLVALUE),
          )
      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 1 for calling a global function with example usage: _mask_image_data(data, info) and returns: data