code: def order_filter(a, domain, rank):
      """
      Perform an order filter on an N-dimensional array.
  
      Perform an order filter on the array in.  The domain argument acts as a
      mask centered over each pixel.  The non-zero elements of domain are
      used to select elements surrounding each input pixel which are placed
      in a list.   The list is sorted, and the output for that pixel is the
      element corresponding to rank in the sorted list.
  
      Parameters
      ----------
      a : ndarray
          The N-dimensional input array.
      domain : array_like
          A mask array with the same number of dimensions as `a`.
          Each dimension should have an odd number of elements.
      rank : int
          A non-negative integer which selects the element from the
          sorted list (0 corresponds to the smallest element, 1 is the
          next smallest element, etc.).
  
      Returns
      -------
      out : ndarray
          The results of the order filter in an array with the same
          shape as `a`.
  
      Examples
      --------
      >>> from scipy import signal
      >>> x = np.arange(25).reshape(5, 5)
      >>> domain = np.identity(3)
      >>> x
      array([[ 0,  1,  2,  3,  4],
             [ 5,  6,  7,  8,  9],
             [10, 11, 12, 13, 14],
             [15, 16, 17, 18, 19],
             [20, 21, 22, 23, 24]])
      >>> signal.order_filter(x, domain, 0)
      array([[  0.,   0.,   0.,   0.,   0.],
             [  0.,   0.,   1.,   2.,   0.],
             [  0.,   5.,   6.,   7.,   0.],
             [  0.,  10.,  11.,  12.,   0.],
             [  0.,   0.,   0.,   0.,   0.]])
      >>> signal.order_filter(x, domain, 2)
      array([[  6.,   7.,   8.,   9.,   4.],
             [ 11.,  12.,  13.,  14.,   9.],
             [ 16.,  17.,  18.,  19.,  14.],
             [ 21.,  22.,  23.,  24.,  19.],
             [ 20.,  21.,  22.,  23.,  24.]])
  
      """
      domain = asarray(domain)
      size = domain.shape
      for k in range(len(size)):
          if (size[k] % 2) != 1:
              raise ValueError(
                  "Each dimension of domain argument "
                  " should have an odd number of elements."
              )
      return sigtools._order_filterND(a, domain, rank)
  
imports: from __future__ import division, print_function, absolute_import
  import operator
  import threading
  import sys
  import timeit
  from scipy.spatial import cKDTree
  from .None import sigtools, dlti
  from ._upfirdn import upfirdn, _output_len
  from scipy._lib.six import callable
  from scipy._lib._version import NumpyVersion
  from scipy import fftpack, linalg
  from scipy.fftpack.helper import _init_nd_shape_and_axes_sorted
  from numpy import allclose, angle, arange, argsort, array, asarray, atleast_1d, atleast_2d, cast, dot, exp, expand_dims, iscomplexobj, mean, ndarray, newaxis, ones, pi, poly, polyadd, polyder, polydiv, polymul, polysub, polyval, product, r_, ravel, real_if_close, reshape, roots, sort, take, transpose, unique, where, zeros, zeros_like
  import numpy
  import math
  from scipy.special import factorial
  from .windows import get_window
  from ._arraytools import axis_slice, axis_reverse, odd_ext, even_ext, const_ext
  from .filter_design import cheby1, _validate_sos
  from .fir_filter_design import firwin
label_desc: Use image node_id 15 for calling a global function with example usage: order_filter(a, domain, rank) and returns: sigtools