code: def correlation_lags(in1_len, in2_len, mode="full"):
      r"""
      Calculates the lag / displacement indices array for 1D cross-correlation.
  
      Parameters
      ----------
      in1_size : int
          First input size.
      in2_size : int
          Second input size.
      mode : str {'full', 'valid', 'same'}, optional
          A string indicating the size of the output.
          See the documentation `correlate` for more information.
  
      See Also
      --------
      correlate : Compute the N-dimensional cross-correlation.
  
      Returns
      -------
      lags : array
          Returns an array containing cross-correlation lag/displacement indices.
          Indices can be indexed with the np.argmax of the correlation to return
          the lag/displacement.
  
      Notes
      -----
      Cross-correlation for continuous functions :math:`f` and :math:`g` is
      defined as:
  
      .. math ::
  
          \left ( f\star g \right )\left ( \tau \right )
          \triangleq \int_{t_0}^{t_0 +T}
          \overline{f\left ( t \right )}g\left ( t+\tau \right )dt
  
      Where :math:`\tau` is defined as the displacement, also known as the lag.
  
      Cross correlation for discrete functions :math:`f` and :math:`g` is
      defined as:
  
      .. math ::
          \left ( f\star g \right )\left [ n \right ]
          \triangleq \sum_{-\infty}^{\infty}
          \overline{f\left [ m \right ]}g\left [ m+n \right ]
  
      Where :math:`n` is the lag.
  
      Examples
      --------
      Cross-correlation of a signal with its time-delayed self.
  
      >>> from scipy import signal
      >>> from numpy.random import default_rng
      >>> rng = default_rng()
      >>> x = rng.standard_normal(1000)
      >>> y = np.concatenate([rng.standard_normal(100), x])
      >>> correlation = signal.correlate(x, y, mode="full")
      >>> lags = signal.correlation_lags(x.size, y.size, mode="full")
      >>> lag = lags[np.argmax(correlation)]
      """
  
      # calculate lag ranges in different modes of operation
      if mode == "full":
          # the output is the full discrete linear convolution
          # of the inputs. (Default)
          lags = np.arange(-in2_len + 1, in1_len)
      elif mode == "same":
          # the output is the same size as `in1`, centered
          # with respect to the 'full' output.
          # calculate the full output
          lags = np.arange(-in2_len + 1, in1_len)
          # determine the midpoint in the full output
          mid = lags.size // 2
          # determine lag_bound to be used with respect
          # to the midpoint
          lag_bound = in1_len // 2
          # calculate lag ranges for even and odd scenarios
          if in1_len % 2 == 0:
              lags = lags[(mid - lag_bound) : (mid + lag_bound)]
          else:
              lags = lags[(mid - lag_bound) : (mid + lag_bound) + 1]
      elif mode == "valid":
          # the output consists only of those elements that do not
          # rely on the zero-padding. In 'valid' mode, either `in1` or `in2`
          # must be at least as large as the other in every dimension.
  
          # the lag_bound will be either negative or positive
          # this let's us infer how to present the lag range
          lag_bound = in1_len - in2_len
          if lag_bound >= 0:
              lags = np.arange(lag_bound + 1)
          else:
              lags = np.arange(lag_bound, 1)
      return lags
  
imports: import operator
  import math
  import timeit
  from scipy.spatial import cKDTree
  from .None import sigtools, dlti
  from ._upfirdn import upfirdn, _output_len, _upfirdn_modes
  from scipy import linalg, fft
  from scipy.fft._helper import _init_nd_shape_and_axes
  from scipy._lib._util import prod
  import numpy
  from scipy.special import lambertw
  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
  from ._sosfilt import _sosfilt
  import warnings
label_desc: Use image node_id 5 for calling a global function with example usage: correlation_lags(in1_len, in2_len, mode) and returns: lags