code: def compute_speedups(
      operator,
      models,
      example_inputs,
      repeats,
      accuracy_checking=False,
      device="cuda",
  ):
      expected = models[0](*example_inputs)
      if accuracy_checking:
          for model in models[1:]:
              actual = model(*example_inputs)
              # change to assert later
              try:
                  same(
                      actual,
                      expected,
                      cos_similarity=True,
                      equal_nan=True,
                  )
              except AssertionError as e:
                  print(e)
                  print(f"Accuracy check failed: {operator}")
                  print((expected[0] - actual[0]).abs().max())
  
      timings = np.zeros((repeats, len(models)), np.float64)
      for rep in range(repeats):
          # interleave the runs to handle frequency scaling and load changes
          for m, model in enumerate(models):
              if device == "cuda":
                  import triton
  
                  model(*example_inputs)
  
                  # do_bench() clears L2 cache to hide the latency of CPU launch time
                  # along with cuda synchronization
                  timings[rep, m] = triton.testing.do_bench(
                      lambda: model(*example_inputs)
                  )
              else:
                  from torch._inductor.utils import timed
  
                  timings[rep, m] = timed(model, example_inputs)
      return np.median(timings, axis=0)
  
file_path: pytorch/benchmarks/dynamo/microbenchmarks/operatorbench.py
imports: import click
  import numpy
  import torch
  from operator_inp_utils import OperatorInputsLoader
  from torch._dynamo.backends.cudagraphs import cudagraphs_inner
  from torch._dynamo.testing import same
  from torch._inductor.compile_fx import compile_fx
  from torch._inductor.decomposition import decompositions
  from torch._inductor.lowering import lowerings
  from torch._inductor.utils import gen_gm_and_inputs
  from torch.utils._pytree import tree_map_only
label_desc: Use image node_id 1 for calling a global function with example usage: compute_speedups(operator, models, example_inputs, repeats, accuracy_checking, device) and returns: np