code: def time_func(func, x):
      try:
          if torch.cuda.is_available():
              torch.cuda.synchronize()
          elif torch.backends.mps.is_available():
              import torch.mps
  
              torch.mps.synchronize()
          t = time.perf_counter()
  
          if not args.with_backward:
              with torch.no_grad():
                  for _ in range(iters):
                      func(x)
          else:
              x = x.requires_grad_()
              for _ in range(iters):
                  out = func(x)
                  out = out[0] if isinstance(out, tuple) else out
                  torch.autograd.grad(out, x, out, only_inputs=True)
  
          if torch.cuda.is_available():
              torch.cuda.synchronize()
          elif torch.backends.mps.is_available():
              import torch.mps
  
              torch.mps.synchronize()
          return time.perf_counter() - t
      except RuntimeError as e:
          if "out of memory" not in str(e):
              raise RuntimeError(e)
          torch.cuda.empty_cache()
          return float("inf")
  
file_path: pytorch_sparse/benchmark/main.py
imports: import argparse
  import itertools
  import os.path
  import time
  import torch
  import wget
  from scipy.io import loadmat
  from torch_scatter import scatter_add
  from torch_sparse.tensor import SparseTensor
label_desc: Use image node_id 4 for calling a global function with example usage: time_func(func, x) and returns: unknown, float