code: def test_write_masked_nomask(tmp_path):
      """Verify that a mask is written when we write an optimized masked array (mask == np.ma.nomask)."""
      data = np.ma.masked_array([[0, 1, 2]], dtype="uint8")
  
      with rasterio.open(
          tmp_path / "test.tif",
          "w",
          driver="GTiff",
          count=1,
          width=3,
          height=1,
          dtype="uint8",
      ) as dst:
          dst.write(data, indexes=1, masked=True)
  
      # Expect no masked values.
      with rasterio.open(tmp_path / "test.tif") as src:
          assert src.mask_flag_enums == ([MaskFlags.per_dataset],)
          arr = src.read(masked=True)
          assert list(arr.flatten()) == [0, 1, 2]
  
imports: import logging
  import re
  from pathlib import Path
  import subprocess
  import affine
  import numpy
  import pytest
  from .conftest import requires_gdal35, gdal_version
  import rasterio
  from rasterio.drivers import blacklist
  from rasterio.enums import MaskFlags, Resampling
  from rasterio.env import Env, GDALVersion
  from rasterio.errors import RasterioIOError
label_desc: Use image node_id 33 for calling a global function with example usage: test_write_masked_nomask(tmp_path) without return types