code: def main(num_samples=10, max_num_epochs=10, gpus_per_trial=2):
      data_dir = os.path.abspath("./data")
      load_data(data_dir)
      config = {
          "l1": tune.choice([2**i for i in range(9)]),
          "l2": tune.choice([2**i for i in range(9)]),
          "lr": tune.loguniform(1e-4, 1e-1),
          "batch_size": tune.choice([2, 4, 8, 16]),
      }
      scheduler = ASHAScheduler(
          metric="loss",
          mode="min",
          max_t=max_num_epochs,
          grace_period=1,
          reduction_factor=2,
      )
      result = tune.run(
          partial(train_cifar, data_dir=data_dir),
          resources_per_trial={"cpu": 2, "gpu": gpus_per_trial},
          config=config,
          num_samples=num_samples,
          scheduler=scheduler,
      )
  
      best_trial = result.get_best_trial("loss", "min", "last")
      print(f"Best trial config: {best_trial.config}")
      print(
          f"Best trial final validation loss: {best_trial.last_result['loss']}"
      )
      print(
          f"Best trial final validation accuracy: {best_trial.last_result['accuracy']}"
      )
  
      best_trained_model = Net(
          best_trial.config["l1"], best_trial.config["l2"]
      )
      device = "cpu"
      if torch.cuda.is_available():
          device = "cuda:0"
          if gpus_per_trial > 1:
              best_trained_model = nn.DataParallel(best_trained_model)
      best_trained_model.to(device)
  
      best_checkpoint = best_trial.checkpoint
      best_checkpoint_dir = best_checkpoint.to_directory()
      best_checkpoint_path = os.path.join(
          best_checkpoint_dir, "checkpoint.pt"
      )
      best_checkpoint_data = torch.load(best_checkpoint_path)
  
      best_trained_model.load_state_dict(
          best_checkpoint_data["net_state_dict"]
      )
  
      test_acc = test_accuracy(best_trained_model, device)
      print("Best trial test set accuracy: {}".format(test_acc))
  
imports: from functools import partial
  import os
  from tempfile import TemporaryDirectory
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torch.utils.data import random_split
  import torchvision
  import torchvision.transforms
  from ray import train, tune
  from ray.train import Checkpoint
  from ray.tune.schedulers import ASHAScheduler
label_desc: Use image node_id 4 for calling a global function with example usage: main(num_samples, max_num_epochs, gpus_per_trial) without return types