code: def test_create_sidecar_mask(data):
      """Write a .msk sidecar mask."""
      with rasterio.open(str(data.join("RGB.byte.tif")), "r+") as dst:
          blue = dst.read(1, masked=False)
          mask = 255 * (blue == 0).astype("uint8")
          dst.write_mask(mask)
  
      # There should be a .msk file in this case.
      assert data.join("RGB.byte.tif").exists()
      assert data.join("RGB.byte.tif.msk").exists()
  
      # Check that the mask was saved correctly.
      with rasterio.open(str(data.join("RGB.byte.tif"))) as src:
          assert (mask == src.read_masks()).all()
          for flags in src.mask_flag_enums:
              assert MaskFlags.per_dataset in flags
              assert MaskFlags.alpha not in flags
              assert MaskFlags.nodata not in flags
  
      # Check the .msk file, too.
      with rasterio.open(str(data.join("RGB.byte.tif.msk"))) as msk:
          assert (mask == msk.read(1, masked=False)).all()
  
file_path: rasterio/tests/test_mask_creation.py
imports: import numpy
  import pytest
  import rasterio
  from rasterio.enums import MaskFlags
  from rasterio.errors import RasterioIOError
  from rasterio.windows import Window
label_desc: Use image node_id 2 for calling a global function with example usage: test_create_sidecar_mask(data) without return types