code: def eval_resnet():
      Tensor.no_grad = True
      # Resnet50-v1.5
      from extra.models.resnet import ResNet50
  
      tlog("imports")
      GPUS = [f"{Device.DEFAULT}:{i}" for i in range(getenv("GPUS", 6))]
      for x in GPUS:
          Device[x]
      tlog("got devices")  # NOTE: this is faster with rocm-smi running
  
      class ResnetRunner:
          def __init__(self, device=None):
              self.mdl = ResNet50()
              for x in get_parameters(self.mdl) if device else []:
                  x.to_(device)
              if fn := getenv("RESNET_MODEL", ""):
                  load_state_dict(self.mdl, safe_load(fn))
              else:
                  self.mdl.load_from_pretrained()
              self.input_mean = Tensor(
                  [0.485, 0.456, 0.406], device=device
              ).reshape(1, -1, 1, 1)
              self.input_std = Tensor(
                  [0.229, 0.224, 0.225], device=device
              ).reshape(1, -1, 1, 1)
  
          def __call__(self, x: Tensor) -> Tensor:
              x = x.permute([0, 3, 1, 2]).cast(dtypes.float32) / 255.0
              x -= self.input_mean
              x /= self.input_std
              return self.mdl(x).argmax(axis=1).realize()
  
      mdl = TinyJit(ResnetRunner(GPUS))
      tlog("loaded models")
  
      # evaluation on the mlperf classes of the validation set from imagenet
      from examples.mlperf.dataloader import batch_load_resnet
  
      iterator = batch_load_resnet(
          getenv("BS", 128 * 6), val=getenv("VAL", 1), shuffle=False
      )
  
      def data_get():
          x, y, cookie = next(iterator)
          return x.shard(GPUS, axis=0).realize(), y, cookie
  
      n, d = 0, 0
      proc = data_get()
      tlog("loaded initial data")
      st = time.perf_counter()
      while proc is not None:
          GlobalCounters.reset()
          proc = (
              mdl(proc[0]),
              proc[1],
              proc[2],
          )  # this frees the images
          run = time.perf_counter()
          # load the next data here
          try:
              next_proc = data_get()
          except StopIteration:
              next_proc = None
          nd = time.perf_counter()
          proc = (
              proc[0].numpy() == proc[1]
          )  # this realizes the models and frees the cookies
          n += proc.sum()
          d += proc.size
          et = time.perf_counter()
          tlog(
              f"****** {n:5d}/{d:5d}  {n*100.0/d:.2f}% -- {(run-st)*1000:7.2f} ms to enqueue, {(et-run)*1000:7.2f} ms to realize ({(nd-run)*1000:7.2f} ms fetching). {(len(proc))/(et-st):8.2f} examples/sec. {GlobalCounters.global_ops*1e-12/(et-st):5.2f} TFLOPS"
          )
          st = et
          proc, next_proc = next_proc, None
      tlog("done")
  
file_path: tinygrad/examples/mlperf/model_eval.py
imports: import time
  from pathlib import Path
  import numpy
  from tinygrad import Tensor, Device, dtypes, GlobalCounters
  from tinygrad.jit import TinyJit
  from tinygrad.nn.state import get_parameters, load_state_dict, safe_load
  from tinygrad.helpers import getenv, Timing
  from examples.mlperf import helpers
label_desc: Use image node_id 2 for calling a global function with example usage: eval_resnet() and returns: x,  y,  cookie, self