code: def pytest_pyfunc_call(pyfuncitem: pytest.Function) -> None:
      if pyfuncitem.stash.get(is_horovod_stash_key, False):
  
          def testfunc_wrapper(test_func, **kwargs):
              def hvd_worker():
                  import horovod.torch as hvd
  
                  hvd.init()
                  lrank = hvd.local_rank()
                  if torch.cuda.is_available():
                      torch.cuda.set_device(lrank)
  
                  test_func(**kwargs)
  
                  hvd.shutdown()
  
              try:
                  # old API
                  from horovod.run.runner import run
              except ImportError:
                  # new API: https://github.com/horovod/horovod/pull/2099
                  from horovod import run
  
              nproc = (
                  4
                  if not torch.cuda.is_available()
                  else torch.cuda.device_count()
              )
              hvd_kwargs = dict(use_gloo=True, num_proc=nproc)
              run(hvd_worker, **hvd_kwargs)
  
          pyfuncitem.obj = functools.partial(
              testfunc_wrapper, pyfuncitem.obj
          )
  
      elif (
          pyfuncitem.stash.get(is_xla_stash_key, False)
          and not pyfuncitem.stash[is_xla_single_device_stash_key]
      ):
  
          def testfunc_wrapper(testfunc, **kwargs):
              def xla_worker(index, fn):
                  import torch_xla.core.xla_model as xm
  
                  kwargs["distributed"]["xla_index"] = index
                  xm.rendezvous("init")
                  fn(**kwargs)
  
              import torch_xla.distributed.xla_multiprocessing as xmp
  
              spawn_kwargs = {
                  "nprocs": int(os.environ["NUM_TPU_WORKERS"])
              }
              if "COLAB_TPU_ADDR" in os.environ:
                  spawn_kwargs["start_method"] = "fork"
              try:
                  xmp.spawn(
                      xla_worker, args=(testfunc,), **spawn_kwargs
                  )
              except SystemExit as ex_:
                  assert (
                      ex_.code == 0
                  ), "Didn't successfully exit in XLA test"
  
          pyfuncitem.obj = functools.partial(
              testfunc_wrapper, pyfuncitem.obj
          )
  
imports: import functools
  import os
  import shutil
  import sys
  import tempfile
  import time
  from pathlib import Path
  import pytest
  import torch
  import torch.distributed
  import ignite.distributed
label_desc: Use image node_id 27 for calling a global function with example usage: pytest_pyfunc_call(pyfuncitem) without return types