code: def choose_conv_method(in1, in2, mode="full", measure=False):
      """
      Find the fastest convolution/correlation method.
  
      This primarily exists to be called during the ``method='auto'`` option in
      `convolve` and `correlate`, but can also be used when performing many
      convolutions of the same input shapes and dtypes, determining
      which method to use for all of them, either to avoid the overhead of the
      'auto' option or to use accurate real-world measurements.
  
      Parameters
      ----------
      in1 : array_like
          The first argument passed into the convolution function.
      in2 : array_like
          The second argument passed into the convolution function.
      mode : str {'full', 'valid', 'same'}, optional
          A string indicating the size of the output:
  
          ``full``
             The output is the full discrete linear convolution
             of the inputs. (Default)
          ``valid``
             The output consists only of those elements that do not
             rely on the zero-padding.
          ``same``
             The output is the same size as `in1`, centered
             with respect to the 'full' output.
      measure : bool, optional
          If True, run and time the convolution of `in1` and `in2` with both
          methods and return the fastest. If False (default), predict the fastest
          method using precomputed values.
  
      Returns
      -------
      method : str
          A string indicating which convolution method is fastest, either
          'direct' or 'fft'
      times : dict, optional
          A dictionary containing the times (in seconds) needed for each method.
          This value is only returned if ``measure=True``.
  
      See Also
      --------
      convolve
      correlate
  
      Notes
      -----
      For large n, ``measure=False`` is accurate and can quickly determine the
      fastest method to perform the convolution.  However, this is not as
      accurate for small n (when any dimension in the input or output is small).
  
      In practice, we found that this function estimates the faster method up to
      a multiplicative factor of 5 (i.e., the estimated method is *at most* 5
      times slower than the fastest method). The estimation values were tuned on
      an early 2015 MacBook Pro with 8GB RAM but we found that the prediction
      held *fairly* accurately across different machines.
  
      If ``measure=True``, time the convolutions. Because this function uses
      `fftconvolve`, an error will be thrown if it does not support the inputs.
      There are cases when `fftconvolve` supports the inputs but this function
      returns `direct` (e.g., to protect against floating point integer
      precision).
  
      .. versionadded:: 0.19
  
      Examples
      --------
      Estimate the fastest method for a given input:
  
      >>> from scipy import signal
      >>> a = np.random.randn(1000)
      >>> b = np.random.randn(1000000)
      >>> method = signal.choose_conv_method(a, b, mode='same')
      >>> method
      'fft'
  
      This can then be applied to other arrays of the same dtype and shape:
  
      >>> c = np.random.randn(1000)
      >>> d = np.random.randn(1000000)
      >>> # `method` works with correlate and convolve
      >>> corr1 = signal.correlate(a, b, mode='same', method=method)
      >>> corr2 = signal.correlate(c, d, mode='same', method=method)
      >>> conv1 = signal.convolve(a, b, mode='same', method=method)
      >>> conv2 = signal.convolve(c, d, mode='same', method=method)
  
      """
      volume = asarray(in1)
      kernel = asarray(in2)
  
      if measure:
          times = {}
          for method in ["fft", "direct"]:
              times[method] = _timeit_fast(
                  lambda: convolve(
                      volume, kernel, mode=mode, method=method
                  )
              )
  
          chosen_method = (
              "fft" if times["fft"] < times["direct"] else "direct"
          )
          return chosen_method, times
  
      # fftconvolve doesn't support complex256
      fftconv_unsup = (
          "complex256" if sys.maxsize > 2**32 else "complex192"
      )
      if hasattr(np, fftconv_unsup):
          if (
              volume.dtype == fftconv_unsup
              or kernel.dtype == fftconv_unsup
          ):
              return "direct"
  
      # for integer input,
      # catch when more precision required than float provides (representing an
      # integer as float can lose precision in fftconvolve if larger than 2**52)
      if any(
          [_numeric_arrays([x], kinds="ui") for x in [volume, kernel]]
      ):
          max_value = int(np.abs(volume).max()) * int(
              np.abs(kernel).max()
          )
          max_value *= int(min(volume.size, kernel.size))
          if max_value > 2 ** np.finfo("float").nmant - 1:
              return "direct"
  
      if _numeric_arrays([volume, kernel], kinds="b"):
          return "direct"
  
      if _numeric_arrays([volume, kernel]):
          if _fftconv_faster(volume, kernel, mode):
              return "fft"
  
      return "direct"
  
imports: from __future__ import division, print_function, absolute_import
  import operator
  import threading
  import sys
  import timeit
  from scipy.spatial import cKDTree
  from .None import sigtools, dlti
  from ._upfirdn import upfirdn, _output_len
  from scipy._lib.six import callable
  from scipy._lib._version import NumpyVersion
  from scipy import fftpack, linalg
  from scipy.fftpack.helper import _init_nd_shape_and_axes_sorted
  from numpy import allclose, angle, arange, argsort, array, asarray, atleast_1d, atleast_2d, cast, dot, exp, expand_dims, iscomplexobj, mean, ndarray, newaxis, ones, pi, poly, polyadd, polyder, polydiv, polymul, polysub, polyval, product, r_, ravel, real_if_close, reshape, roots, sort, take, transpose, unique, where, zeros, zeros_like
  import numpy
  import math
  from scipy.special import factorial
  from .windows import get_window
  from ._arraytools import axis_slice, axis_reverse, odd_ext, even_ext, const_ext
  from .filter_design import cheby1, _validate_sos
  from .fir_filter_design import firwin
label_desc: Use image node_id 13 for calling a global function with example usage: choose_conv_method(in1, in2, mode, measure) and returns: str, chosen_method,  times, str, str, str, str