code: def unit_impulse(shape, idx=None, dtype=float):
      """
      Unit impulse signal (discrete delta function) or unit basis vector.
  
      Parameters
      ----------
      shape : int or tuple of int
          Number of samples in the output (1-D), or a tuple that represents the
          shape of the output (N-D).
      idx : None or int or tuple of int or 'mid', optional
          Index at which the value is 1.  If None, defaults to the 0th element.
          If ``idx='mid'``, the impulse will be centered at ``shape // 2`` in
          all dimensions.  If an int, the impulse will be at `idx` in all
          dimensions.
      dtype : data-type, optional
          The desired data-type for the array, e.g., ``numpy.int8``.  Default is
          ``numpy.float64``.
  
      Returns
      -------
      y : ndarray
          Output array containing an impulse signal.
  
      Notes
      -----
      The 1D case is also known as the Kronecker delta.
  
      Examples
      --------
      An impulse at the 0th element (:math:`\\delta[n]`):
  
      >>> import cupyx.scipy.signal
      >>> import cupy as cp
      >>> cupyx.scipy.signal.unit_impulse(8)
      array([ 1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])
  
      Impulse offset by 2 samples (:math:`\\delta[n-2]`):
  
      >>> cupyx.scipy.signal.unit_impulse(7, 2)
      array([ 0.,  0.,  1.,  0.,  0.,  0.,  0.])
  
      2-dimensional impulse, centered:
  
      >>> cupyx.scipy.signal.unit_impulse((3, 3), 'mid')
      array([[ 0.,  0.,  0.],
             [ 0.,  1.,  0.],
             [ 0.,  0.,  0.]])
  
      Impulse at (2, 2), using broadcasting:
  
      >>> cupyx.scipy.signal.unit_impulse((4, 4), 2)
      array([[ 0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.],
             [ 0.,  0.,  1.,  0.],
             [ 0.,  0.,  0.,  0.]])
      """
      out = cupy.empty(shape, dtype)
      shape = np.atleast_1d(shape)
  
      if idx is None:
          idx = (0,) * len(shape)
      elif idx == "mid":
          idx = tuple(shape // 2)
      elif not hasattr(idx, "__iter__"):
          idx = (idx,) * len(shape)
  
      pos = np.ravel_multi_index(idx, out.shape)
  
      n = out.size
      block_sz = 128
      n_blocks = (n + block_sz - 1) // block_sz
  
      unit_impulse_kernel = _get_module_func(
          UNIT_MODULE, "unit_impulse", out
      )
      unit_impulse_kernel((n_blocks,), (block_sz,), (n, pos, out))
      return out
  
file_path: cupy/cupyx/scipy/signal/_waveforms.py
imports: import cupy
  from cupy._core._scalar import get_typename
  from cupy_backends.cuda.api import runtime
  import numpy
label_desc: Use image node_id 9 for calling a global function with example usage: unit_impulse(shape, idx, dtype) and returns: out