code: def KORNIA_CHECK(
      condition: bool, msg: Optional[str] = None, raises: bool = True
  ) -> bool:
      """Check any arbitrary boolean condition.
  
      Args:
          condition: the condition to evaluate.
          msg: message to show in the exception.
          raises: bool indicating whether an exception should be raised upon failure.
  
      Raises:
          Exception: if the condition is met and raises is True.
  
      Example:
          >>> x = torch.rand(2, 3, 3)
          >>> KORNIA_CHECK(x.shape[-2:] == (3, 3), "Invalid homography")
          True
      """
      if not condition:
          if raises:
              raise Exception(f"{condition} not true.\n{msg}")
          return False
      return True
  
imports: from __future__ import annotations
  from typing import Any, Optional, Sequence, TypeVar, cast
  from torch import float16, float32, float64
  from typing_extensions import TypeGuard
  from kornia.core import Tensor
label_desc: Use image node_id 2 for calling a global function with example usage: KORNIA_CHECK(condition, msg, raises) and returns: True, False