code: def correlate1d(
      input,
      weights,
      axis=-1,
      output=None,
      mode="reflect",
      cval=0.0,
      origin=0,
  ):
      """Calculate a 1-D correlation along the given axis.
  
      The lines of the array along the given axis are correlated with the
      given weights.
  
      Parameters
      ----------
      %(input)s
      weights : array
          1-D sequence of numbers.
      %(axis)s
      %(output)s
      %(mode_reflect)s
      %(cval)s
      %(origin)s
  
      Returns
      -------
      result : ndarray
          Correlation result. Has the same shape as `input`.
  
      Examples
      --------
      >>> from scipy.ndimage import correlate1d
      >>> correlate1d([2, 8, 0, 4, 1, 9, 9, 0], weights=[1, 3])
      array([ 8, 26,  8, 12,  7, 28, 36,  9])
      """
      input = numpy.asarray(input)
      weights = numpy.asarray(weights)
      complex_input = input.dtype.kind == "c"
      complex_weights = weights.dtype.kind == "c"
      if complex_input or complex_weights:
          if complex_weights:
              weights = weights.conj()
              weights = weights.astype(numpy.complex128, copy=False)
          kwargs = dict(axis=axis, mode=mode, origin=origin)
          output = _ni_support._get_output(
              output, input, complex_output=True
          )
          return _complex_via_real_components(
              correlate1d, input, weights, output, cval, **kwargs
          )
  
      output = _ni_support._get_output(output, input)
      weights = numpy.asarray(weights, dtype=numpy.float64)
      if weights.ndim != 1 or weights.shape[0] < 1:
          raise RuntimeError("no filter weights given")
      if not weights.flags.contiguous:
          weights = weights.copy()
      axis = normalize_axis_index(axis, input.ndim)
      if _invalid_origin(origin, len(weights)):
          raise ValueError(
              "Invalid origin; origin must satisfy "
              "-(len(weights) // 2) <= origin <= "
              "(len(weights)-1) // 2"
          )
      mode = _ni_support._extend_mode_to_code(mode)
      _nd_image.correlate1d(
          input, weights, axis, output, mode, cval, origin
      )
      return output
  
imports: from collections.abc import Iterable
  import numbers
  import warnings
  import numpy
  import operator
  from scipy._lib._util import normalize_axis_index
  from .None import _ni_support
  from .None import _nd_image
  from .None import _ni_docstrings
label_desc: Use image node_id 3 for calling a global function with example usage: correlate1d(input, weights, axis, output, mode, cval, origin) and returns: output, _complex_via_real_components