code: def convolve1d(f, weights, axis, mode="reflect", cval=0.0, out=None):
      """
      convolved = convolve1d(f, weights, axis, mode='reflect', cval=0.0, out={new array})
  
      Convolution of `f` and `weights` along axis `axis`.
  
      Convolution is performed in `doubles` to avoid over/underflow, but the
      result is then cast to `f.dtype`.
  
      Parameters
      ----------
      f : ndarray
          input. Any dimension is supported
      weights : 1-D ndarray
          weight filter. If not of the same dtype as `f`, it is cast
      axis : int
          Axis along which to convolve
      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`
  
      See Also
      --------
      convolve : function
          generic convolution
      """
      weights = np.asanyarray(weights)
      weights = weights.squeeze()
      if weights.ndim != 1:
          raise ValueError(
              "mahotas.convolve1d: only 1-D sequences allowed"
          )
      _check_mode(mode, cval, "convolve1d")
      if f.flags.contiguous and len(weights) < f.shape[axis]:
          weights = weights.astype(np.double, copy=False)
          indices = [a for a in range(f.ndim) if a != axis] + [axis]
          rindices = [indices.index(a) for a in range(f.ndim)]
          oshape = f.shape
          f = f.transpose(indices)
          tshape = f.shape
          f = f.reshape((-1, f.shape[-1]))
  
          out = _get_output(f, out, "convolve1d")
          _convolve.convolve1d(f, weights, out, mode2int[mode])
          out = out.reshape(tshape)
          out = out.transpose(rindices)
          out = out.reshape(oshape)
          return out
      else:
          index = [None] * f.ndim
          index[axis] = slice(0, None)
          weights = weights[tuple(index)]
          return convolve(f, weights, mode=mode, cval=cval, out=out)
  
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 2 for calling a global function with example usage: convolve1d(f, weights, axis, mode, cval, out) and returns: out, convolve