code: def run_tests_if_main():
      """Run tests in a given file if it is run as a script"""
      local_vars = inspect.currentframe().f_back.f_locals
      if not local_vars.get("__name__", "") == "__main__":
          return
      # we are in a "__main__"
      fname = local_vars["__file__"]
      # Run ourselves. post-mortem debugging!
      try:
          import faulthandler
  
          faulthandler.enable()
      except Exception:
          pass
      import __main__
  
      try:
          import pytest
  
          pytest.main(["-s", "--tb=short", fname])
      except ImportError:
          print("==== Running tests in script\n==== %s" % fname)
          run_tests_in_object(__main__)
          print("==== Tests pass")
  
imports: from __future__ import print_function
  import numpy
  import sys
  import os
  import inspect
  import gc
  import pytest
  import functools
  from packaging.version import Version
  from ..util.check_environment import has_backend
label_desc: Use image node_id 29 for calling a global function with example usage: run_tests_if_main() without return types