code: def harris_response(
      input: Tensor,
      k: Union[Tensor, float] = 0.04,
      grads_mode: str = "sobel",
      sigmas: Optional[Tensor] = None,
  ) -> Tensor:
      r"""Compute the Harris cornerness function.
  
      .. image:: _static/img/harris_response.png
  
      Function does not do any normalization or nms. The response map is computed according the following formulation:
  
      .. math::
          R = max(0, det(M) - k \cdot trace(M)^2)
  
      where:
  
      .. math::
          M = \sum_{(x,y) \in W}
          \begin{bmatrix}
              I^{2}_x & I_x I_y \\
              I_x I_y & I^{2}_y \\
          \end{bmatrix}
  
      and :math:`k` is an empirically determined constant
      :math:`k ∈ [ 0.04 , 0.06 ]`
  
      Args:
          input: input image with shape :math:`(B, C, H, W)`.
          k: the Harris detector free parameter.
          grads_mode: can be ``'sobel'`` for standalone use or ``'diff'`` for use on Gaussian pyramid.
          sigmas: coefficients to be multiplied by multichannel response. Should be shape of :math:`(B)`
            It is necessary for performing non-maxima-suppression across different scale pyramid levels.
            See `vlfeat <https://github.com/vlfeat/vlfeat/blob/master/vl/covdet.c#L874>`_.
  
      Return:
          the response map per channel with shape :math:`(B, C, H, W)`.
  
      Example:
          >>> input = torch.tensor([[[
          ...    [0., 0., 0., 0., 0., 0., 0.],
          ...    [0., 1., 1., 1., 1., 1., 0.],
          ...    [0., 1., 1., 1., 1., 1., 0.],
          ...    [0., 1., 1., 1., 1., 1., 0.],
          ...    [0., 1., 1., 1., 1., 1., 0.],
          ...    [0., 1., 1., 1., 1., 1., 0.],
          ...    [0., 0., 0., 0., 0., 0., 0.],
          ... ]]])  # 1x1x7x7
          >>> # compute the response map
          harris_response(input, 0.04)
          tensor([[[[0.0012, 0.0039, 0.0020, 0.0000, 0.0020, 0.0039, 0.0012],
                    [0.0039, 0.0065, 0.0040, 0.0000, 0.0040, 0.0065, 0.0039],
                    [0.0020, 0.0040, 0.0029, 0.0000, 0.0029, 0.0040, 0.0020],
                    [0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
                    [0.0020, 0.0040, 0.0029, 0.0000, 0.0029, 0.0040, 0.0020],
                    [0.0039, 0.0065, 0.0040, 0.0000, 0.0040, 0.0065, 0.0039],
                    [0.0012, 0.0039, 0.0020, 0.0000, 0.0020, 0.0039, 0.0012]]]])
      """
      # TODO: Recompute doctest
      KORNIA_CHECK_SHAPE(input, ["B", "C", "H", "W"])
  
      if sigmas is not None:
          if not isinstance(sigmas, Tensor):
              raise TypeError(
                  f"sigmas type is not a Tensor. Got {type(sigmas)}"
              )
          if (not len(sigmas.shape) == 1) or (
              sigmas.size(0) != input.size(0)
          ):
              raise ValueError(
                  f"Invalid sigmas shape, we expect B == input.size(0). Got: {sigmas.shape}"
              )
  
      gradients: Tensor = spatial_gradient(input, grads_mode)
      dx: Tensor = gradients[:, :, 0]
      dy: Tensor = gradients[:, :, 1]
  
      # compute the structure tensor M elements
  
      dx2: Tensor = gaussian_blur2d(dx**2, (7, 7), (1.0, 1.0))
      dy2: Tensor = gaussian_blur2d(dy**2, (7, 7), (1.0, 1.0))
      dxy: Tensor = gaussian_blur2d(dx * dy, (7, 7), (1.0, 1.0))
  
      det_m: Tensor = dx2 * dy2 - dxy * dxy
      trace_m: Tensor = dx2 + dy2
  
      # compute the response map
      scores: Tensor = det_m - k * (trace_m**2)
  
      if sigmas is not None:
          scores = scores * sigmas.pow(4).view(-1, 1, 1, 1)
  
      return scores
  
imports: from typing import Optional, Union
  import torch
  from kornia.core import Module, Tensor, tensor
  from kornia.core.check import KORNIA_CHECK_SHAPE
  from kornia.filters import gaussian_blur2d, spatial_gradient
label_desc: Use image node_id 2 for calling a global function with example usage: harris_response(input, k, grads_mode, sigmas) and returns: scores