code: def wrap_modelkit_exceptions_gen(func: T) -> T:
      @functools.wraps(func)
      def wrapper(*args, **kwargs):
          if kwargs.pop("__internal", False):
              yield from func(*args, **kwargs)
          else:
              try:
                  yield from func(*args, **kwargs)
              except PredictionError as exc:
                  if (
                      os.environ.get(
                          "MODELKIT_ENABLE_SIMPLE_TRACEBACK", "True"
                      )
                      == "True"
                  ):
                      raise strip_modelkit_traceback_frames(
                          exc.exc
                      ) from exc
                  raise exc.exc from exc
              except BaseException:
                  raise
  
      return cast(T, wrapper)
  
imports: import functools
  import inspect
  import os
  import traceback
  import types
  from typing import Any, Callable, Optional, TypeVar, cast
  import pydantic
label_desc: Use image node_id 4 for calling a global function with example usage: wrap_modelkit_exceptions_gen(func) and returns: cast