code: def _correlate_or_convolve(
      input, weights, output, mode, cval, origin, convolution
  ):
      input = numpy.asarray(input)
      if numpy.iscomplexobj(input):
          raise TypeError("Complex type not supported")
      origins = _ni_support._normalize_sequence(origin, input.ndim)
      weights = numpy.asarray(weights, dtype=numpy.float64)
      wshape = [ii for ii in weights.shape if ii > 0]
      if len(wshape) != input.ndim:
          raise RuntimeError(
              "filter weights array has incorrect shape."
          )
      if convolution:
          weights = weights[
              tuple([slice(None, None, -1)] * weights.ndim)
          ]
          for ii in range(len(origins)):
              origins[ii] = -origins[ii]
              if not weights.shape[ii] & 1:
                  origins[ii] -= 1
      for origin, lenw in zip(origins, wshape):
          if _invalid_origin(origin, lenw):
              raise ValueError(
                  "Invalid origin; origin must satisfy "
                  "-(weights.shape[k] // 2) <= origin[k] <= "
                  "(weights.shape[k]-1) // 2"
              )
  
      if not weights.flags.contiguous:
          weights = weights.copy()
      output = _ni_support._get_output(output, input)
      mode = _ni_support._extend_mode_to_code(mode)
      _nd_image.correlate(input, weights, output, mode, cval, origins)
      return output
  
imports: from __future__ import division, print_function, absolute_import
  import warnings
  import numbers
  import numpy
  import operator
  from .None import _ni_support
  from .None import _nd_image
  from .None import _ni_docstrings
label_desc: Use image node_id 14 for calling a global function with example usage: _correlate_or_convolve(input, weights, output, mode, cval, origin, convolution) and returns: output