code: def validate(
      data: _T,
      schema: Callable[[_T], _T],
      text: Optional[str] = None,
      path: Optional[str] = None,
      rev: Optional[str] = None,
  ) -> _T:
      from voluptuous import MultipleInvalid
  
      try:
          return schema(data)
      except MultipleInvalid as exc:
          raise YAMLValidationError(exc, path, text, rev=rev) from exc
  
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 6 for calling a global function with example usage: validate(data, schema, text, path, rev) and returns: schema