code: def _extend_mode_to_code(mode):
      """Convert an extension mode to the corresponding integer code."""
      if mode == "nearest":
          return 0
      elif mode == "wrap":
          return 1
      elif mode in ["reflect", "grid-mirror"]:
          return 2
      elif mode == "mirror":
          return 3
      elif mode == "constant":
          return 4
      elif mode == "grid-wrap":
          return 5
      elif mode == "grid-constant":
          return 6
      else:
          raise RuntimeError("boundary mode not supported")
  
imports: from collections.abc import Iterable
  import warnings
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _extend_mode_to_code(mode) and returns: int, int, int, int, int, int, int