code: def main():
      parser = argparse.ArgumentParser(
          description="Learning convnet from ILSVRC2012 dataset"
      )
      parser.add_argument(
          "train", help="Path to training image-label list file"
      )
      parser.add_argument(
          "val", help="Path to validation image-label list file"
      )
      parser.add_argument(
          "--batchsize",
          "-B",
          type=int,
          default=32,
          help="Learning minibatch size",
      )
      parser.add_argument(
          "--epoch",
          "-E",
          type=int,
          default=10,
          help="Number of epochs to train",
      )
      parser.add_argument(
          "--iteration",
          "-I",
          type=int,
          default=None,
          help="Number of iterations to train. Epoch is ignored if specified.",
      )
      parser.add_argument(
          "--loaderjob",
          "-j",
          type=int,
          help="Number of parallel data loading processes",
      )
      parser.add_argument(
          "--mean",
          "-m",
          default="mean.npy",
          help="Mean file (computed by compute_mean.py)",
      )
      parser.add_argument(
          "--root",
          "-R",
          default=".",
          help="Root directory path of image files",
      )
      parser.add_argument(
          "--val_batchsize",
          "-b",
          type=int,
          default=250,
          help="Validation minibatch size",
      )
      parser.set_defaults(test=False)
      parser.add_argument(
          "--device", "-d", default="native", help="Device to use"
      )
  
      args = parser.parse_args()
  
      chx.set_default_device(args.device)
      batch_size = args.batchsize
      eval_size = args.val_batchsize
  
      # Prepare model
      model = resnet50.ResNet50()
  
      # Prepare datasets and mean file
      mean = np.load(args.mean)
      train = PreprocessedDataset(
          args.train, args.root, mean, model.insize
      )
      test = PreprocessedDataset(
          args.val, args.root, mean, model.insize, False
      )
      train_iter = chainer.iterators.MultiprocessIterator(
          train, batch_size, n_processes=args.loaderjob
      )
      test_iter = chainer.iterators.MultiprocessIterator(
          test, eval_size, n_processes=args.loaderjob
      )
  
      N = len(train)
  
      # Train
      model.require_grad()
  
      it = 0
      epoch = 0
      is_finished = False
      start = time.time()
  
      while not is_finished:
          for i in range(0, N // batch_size):
              x, t = get_imagenet(train_iter)
              y = model(x)
              loss = chx.softmax_cross_entropy(y, t).mean()
  
              loss.backward()
              model.update(lr=0.01)
  
              it += 1
              if args.iteration is not None:
                  x_test, t_test = get_imagenet(test_iter)
                  mean_loss, accuracy = evaluate(
                      model, x_test, t_test, eval_size, batch_size
                  )
                  elapsed_time = time.time() - start
                  print(
                      "iteration {}... loss={},\taccuracy={},\telapsed_time={}".format(
                          it, mean_loss, accuracy, elapsed_time
                      )
                  )
                  if it >= args.iteration:
                      is_finished = True
                      break
  
          epoch += 1
          if args.iteration is None:
              x_test, t_test = get_imagenet(test_iter)
              mean_loss, accuracy = evaluate(
                  model, x_test, t_test, eval_size, batch_size
              )
              elapsed_time = time.time() - start
              print(
                  "epoch {}... loss={},\taccuracy={},\telapsed_time={}".format(
                      epoch, mean_loss, accuracy, elapsed_time
                  )
              )
              if epoch >= args.epoch:
                  is_finished = True
  
file_path: chainer/chainerx_cc/examples/imagenet_py/train_imagenet.py
imports: import argparse
  import time
  import chainer.iterators
  import numpy
  import chainerx
  from image_dataset import PreprocessedDataset
  import resnet50
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types