code: def solve_quadratic(coeffs: Tensor) -> Tensor:
      r"""Solve given quadratic equation.
  
      The function takes the coefficients of quadratic equation and returns the real roots.
  
      .. math:: coeffs[0]x^2 + coeffs[1]x + coeffs[2] = 0
  
      Args:
          coeffs : The coefficients of quadratic equation :`(B, 3)`
  
      Returns:
          A tensor of shape `(B, 2)` containing the real roots to the quadratic equation.
  
      Example:
          >>> coeffs = torch.tensor([[1., 4., 4.]])
          >>> roots = solve_quadratic(coeffs)
  
      .. note::
         In cases where a quadratic polynomial has only one real root, the output will be in the format
         [real_root, 0]. And for the complex roots should be represented as 0. This is done to maintain
         a consistent output shape for all cases.
      """
  
      KORNIA_CHECK_SHAPE(coeffs, ["B", "3"])
  
      # Coefficients of quadratic equation
      a = coeffs[:, 0]  # coefficient of x^2
      b = coeffs[:, 1]  # coefficient of x
      c = coeffs[:, 2]  # constant term
  
      # Calculate discriminant
      delta = b * b - 4 * a * c
  
      # Create masks for negative and zero discriminant
      mask_negative = delta < 0
      mask_zero = delta == 0
  
      # Calculate 1/(2*a) for efficient computation
      inv_2a = 0.5 / a
  
      # Initialize solutions tensor
      solutions = zeros(
          (coeffs.shape[0], 2), device=coeffs.device, dtype=coeffs.dtype
      )
  
      # Handle cases with zero discriminant
      if torch.any(mask_zero):
          solutions[mask_zero, 0] = -b[mask_zero] * inv_2a[mask_zero]
          solutions[mask_zero, 1] = solutions[mask_zero, 0]
  
      # Negative discriminant cases are automatically handled since solutions is initialized with zeros.
  
      sqrt_delta = torch.sqrt(delta)
  
      # Handle cases with non-negative discriminant
      mask = torch.bitwise_and(~mask_negative, ~mask_zero)
      if torch.any(mask):
          solutions[mask, 0] = (-b[mask] + sqrt_delta[mask]) * inv_2a[
              mask
          ]
          solutions[mask, 1] = (-b[mask] - sqrt_delta[mask]) * inv_2a[
              mask
          ]
  
      return solutions
  
file_path: kornia/kornia/geometry/solvers/polynomial_solver.py
imports: import math
  import torch
  from kornia.core import Tensor, cos, ones_like, stack, zeros, zeros_like
  from kornia.core.check import KORNIA_CHECK_SHAPE
label_desc: Use image node_id 1 for calling a global function with example usage: solve_quadratic(coeffs) and returns: solutions