code: def _check_warning(
      condition: bool, category: type[Warning], message: str
  ):
      """Conditionally check if a warning is raised"""
      if condition:
          import pytest
  
          with pytest.warns(category, match=message) as ctx:
              yield ctx
      else:
          with contextlib.nullcontext() as ctx:
              yield ctx
  
imports: from __future__ import annotations
  import contextlib
  import importlib
  import time
  from typing import TYPE_CHECKING
label_desc: Use image node_id 8 for calling a global function with example usage: _check_warning(condition, category, message) without return types