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 == "reflect":
          return 2
      elif mode == "mirror":
          return 3
      elif mode == "constant":
          return 4
      else:
          raise RuntimeError("boundary mode not supported")
  
imports: from __future__ import division, print_function, absolute_import
  import numpy
  from scipy._lib.six import string_types
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