code: def shapes(source, mask=None, connectivity=4, transform=IDENTITY):
      """Get shapes and values of connected regions in a dataset or array.
  
      Parameters
      ----------
      source : numpy.ndarray, dataset object, Band, or tuple(dataset, bidx)
          Data type must be one of rasterio.int16, rasterio.int32,
          rasterio.uint8, rasterio.uint16, or rasterio.float32.
      mask : numpy.ndarray or rasterio Band object, optional
          Must evaluate to bool (rasterio.bool_ or rasterio.uint8). Values
          of False or 0 will be excluded from feature generation.  Note
          well that this is the inverse sense from Numpy's, where a mask
          value of True indicates invalid data in an array. If `source` is
          a :class:`numpy.ma.MaskedArray` and `mask` is None, the source's mask will
          be inverted and used in place of `mask`.
      connectivity : int, optional
          Use 4 or 8 pixel connectivity for grouping pixels into features
      transform : Affine transformation, optional
          If not provided, feature coordinates will be generated based on
          pixel coordinates
  
      Yields
      -------
      polygon, value
          A pair of (polygon, value) for each feature found in the image.
          Polygons are GeoJSON-like dicts and the values are the
          associated value from the image, in the data type of the image.
          Note: due to floating point precision issues, values returned
          from a floating point image may not exactly match the original
          values.
  
      Notes
      -----
      The amount of memory used by this algorithm is proportional to the
      number and complexity of polygons produced.  This algorithm is most
      appropriate for simple thematic data.  Data with high pixel-to-pixel
      variability, such as imagery, may produce one polygon per pixel and
      consume large amounts of memory.
  
      Because the low-level implementation uses either an int32 or float32
      buffer, uint32 and float64 data cannot be operated on without
      truncation issues.
  
      """
      if hasattr(source, "mask") and mask is None:
          mask = ~source.mask
          source = source.data
  
      transform = guard_transform(transform)
      for s, v in _shapes(source, mask, connectivity, transform):
          yield s, v
  
imports: import logging
  import math
  import os
  import warnings
  import numpy
  import rasterio
  from rasterio import warp
  from rasterio._base import DatasetBase
  from rasterio._features import _shapes, _sieve, _rasterize, _bounds
  from rasterio.enums import MergeAlg
  from rasterio.env import ensure_env, GDALVersion
  from rasterio.errors import ShapeSkipWarning
  from rasterio.rio.helpers import coords
  from rasterio.transform import Affine
  from rasterio.transform import IDENTITY, guard_transform
  from rasterio.windows import Window
label_desc: Use image node_id 2 for calling a global function with example usage: shapes(source, mask, connectivity, transform) without return types