code: def log_api(**kwargs):
      exit_stack = contextlib.ExitStack()
      exit_stack.enter_context(preserve_log_state())
      torch._logging.set_logs(**kwargs)
      return exit_stack
  
file_path: pytorch/torch/testing/_internal/logging_utils.py
imports: import torch._dynamo.test_case
  import unittest.mock
  import os
  import contextlib
  import torch._logging
  import torch._logging._internal
  from torch._dynamo.utils import LazyString
  import logging
label_desc: Use image node_id 3 for calling a global function with example usage: log_api() and returns: exit_stack