code: def rank_filter(
      f, Bc, rank, mode="reflect", cval=0.0, out=None, output=None
  ):
      """
      ranked = rank_filter(f, Bc, rank, mode='reflect', cval=0.0, out=None)
  
      Rank filter. The value at ``ranked[i,j]`` will be the ``rank``\th largest in
      the neighbourhood defined by ``Bc``.
  
      Parameters
      ----------
      f : ndarray
          input. Any dimension is supported
      Bc : ndarray
          Defines the neighbourhood. Must be explicitly passed, no default.
      rank : integer
      mode : {'reflect' [default], 'nearest', 'wrap', 'mirror', 'constant', 'ignore'}
          How to handle borders
      cval : double, optional
          If `mode` is constant, which constant to use (default: 0.0)
      out : ndarray, optional
          Output array. Must have same shape and dtype as `f` as well as be
          C-contiguous.
  
      Returns
      -------
      ranked : ndarray of same type and shape as ``f``
          ranked[i,j] is the ``rank``\th value of the points in f close to (i,j)
  
      See Also
      --------
      median_filter : A special case of rank_filter
      """
      Bc = morph.get_structuring_elem(f, Bc)
      output = _get_output(f, out, "rank_filter", output=output)
      _check_mode(mode, cval, "rank_filter")
      return _convolve.rank_filter(f, Bc, output, rank, mode2int[mode])
  
imports: import numpy
  from .None import _convolve
  from .None import morph
  from .internal import _get_output, _normalize_sequence, _verify_is_floatingpoint_type, _as_floating_point_array
  from ._filters import mode2int, modes, _check_mode
label_desc: Use image node_id 5 for calling a global function with example usage: rank_filter(f, Bc, rank, mode, cval, out, output) and returns: _convolve