code: def __pretty_exc__(self, **kwargs: Any) -> None:  # noqa: C901
      from ruamel.yaml.error import MarkedYAMLError
  
      exc = self.exc.__cause__
  
      if not isinstance(exc, MarkedYAMLError):
          raise ValueError(
              "nothing to pretty-print here."
          )  # noqa: TRY004
  
      source = self.yaml_text.splitlines()
  
      def prepare_linecol(mark: "StreamMark") -> str:
          return f"in line {mark.line + 1}, column {mark.column + 1}"
  
      def prepare_message(
          message: str, mark: Optional["StreamMark"] = None
      ) -> "RichText":
          cause = ", ".join(
              [
                  message.capitalize(),
                  prepare_linecol(mark) if mark else "",
              ]
          )
          return _prepare_cause(cause)
  
      def prepare_code(mark: "StreamMark") -> "Syntax":
          line = mark.line + 1
          code = "" if line > len(source) else source[line - 1]
          return _prepare_code_snippets(code, line)
  
      lines: List[object] = []
      if hasattr(exc, "context"):
          if exc.context_mark is not None:
              lines.append(
                  prepare_message(str(exc.context), exc.context_mark)
              )
          if exc.context_mark is not None and (
              exc.problem is None
              or exc.problem_mark is None
              or exc.context_mark.name != exc.problem_mark.name
              or exc.context_mark.line != exc.problem_mark.line
              or exc.context_mark.column != exc.problem_mark.column
          ):
              lines.extend([prepare_code(exc.context_mark), ""])
          if exc.problem is not None:
              lines.append(
                  prepare_message(str(exc.problem), exc.problem_mark)
              )
          if exc.problem_mark is not None:
              lines.append(prepare_code(exc.problem_mark))
  
      if lines:
          # we should not add a newline after the main message
          # if there are no other outputs
          lines.insert(0, "")
  
      rel = make_relpath(self.path)
      rev_msg = f" in revision '{self.rev[:7]}'" if self.rev else ""
      msg_fmt = f"'{rel}' is invalid{self.hint}{rev_msg}."
      lines.insert(0, _prepare_message(msg_fmt))
      for line in lines:
          ui.error_write(line, styled=True)
  
imports: import re
  import typing
  from contextlib import suppress
  from typing import TYPE_CHECKING, Any, Callable, List, Optional, Tuple, TypeVar
  from dvc.exceptions import PrettyDvcException
  from dvc.ui import ui
  from dvc.utils.serialize import EncodingError, YAMLFileCorruptedError, parse_yaml, parse_yaml_for_update
label_desc: Use image node_id 2 for calling the YAMLSyntaxError obj's underlying member method code with example usage: obj.__pretty_exc__() and returns: str, unknown, str, unknown, _prepare_cause, _prepare_code_snippets