code: def median_filter(
      f, Bc=None, mode="reflect", cval=0.0, out=None, output=None
  ):
      """
      median = median_filter(f, Bc={square}, mode='reflect', cval=0.0, out={np.empty(f.shape, f.dtype})
  
      Median filter
  
      Parameters
      ----------
      f : ndarray
          input. Any dimension is supported
      Bc : ndarray or int, optional
          Defines the neighbourhood, default is a square of side 3.
      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
      -------
      median : ndarray of same type and shape as ``f``
          median[i,j] is the median value of the points in f close to (i,j)
      """
      if Bc is None:
          Bc = np.ones((3,) * len(f.shape), f.dtype)
      elif f.dtype != Bc.dtype:
          Bc = Bc.astype(f.dtype)
      if f.ndim != Bc.ndim:
          raise ValueError(
              "mahotas.median_filter: `f` and `Bc` must have the same number of dimensions"
          )
      rank = Bc.sum() // 2
      output = _get_output(f, out, "median_filter", output=output)
      _check_mode(mode, cval, "median_filter")
      return _convolve.rank_filter(
          f, Bc, output, int(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 3 for calling a global function with example usage: median_filter(f, Bc, mode, cval, out, output) and returns: _convolve