code: def convolve(
      f, weights, mode="reflect", cval=0.0, out=None, output=None
  ):
      """
      convolved = convolve(f, weights, mode='reflect', cval=0.0, out={new array})
  
      Convolution of `f` and `weights`
  
      Convolution is performed in `doubles` to avoid over/underflow, but the
      result is then cast to `f.dtype`. **This conversion may result in
      over/underflow when using small integer types or unsigned types (if the
      output is negative).** Converting to a floating point representation avoids
      this issue::
  
          c = convolve(f.astype(float), kernel)
  
      Parameters
      ----------
      f : ndarray
          input. Any dimension is supported
      weights : ndarray
          weight filter. If not of the same dtype as `f`, it is cast
      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
      -------
      convolved : ndarray of same dtype as `f`
      """
      weights = weights.astype(f.dtype, copy=False)
      if f.ndim != weights.ndim:
          raise ValueError(
              "mahotas.convolve: `f` and `weights` must have the same dimensions"
          )
      output = _get_output(f, out, "convolve", output=output)
      _check_mode(mode, cval, "convolve")
      return _convolve.convolve(f, weights, output, 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 1 for calling a global function with example usage: convolve(f, weights, mode, cval, out, output) and returns: _convolve