code: def objective(trial):
      # Model and optimizer
      model = L.Classifier(create_model(trial))
      optimizer = create_optimizer(trial, model)
  
      # Dataset
      rng = np.random.RandomState(0)
      train, valid = chainer.datasets.get_mnist()
      train = chainer.datasets.SubDataset(
          train, 0, N_TRAIN_EXAMPLES, order=rng.permutation(len(train))
      )
      valid = chainer.datasets.SubDataset(
          valid, 0, N_VALID_EXAMPLES, order=rng.permutation(len(valid))
      )
      train_iter = chainer.iterators.SerialIterator(train, BATCHSIZE)
      valid_iter = chainer.iterators.SerialIterator(
          valid, BATCHSIZE, repeat=False, shuffle=False
      )
  
      # Trainer
      updater = chainer.training.StandardUpdater(train_iter, optimizer)
      trainer = chainer.training.Trainer(updater, (EPOCH, "epoch"))
      trainer.extend(
          chainer.training.extensions.Evaluator(valid_iter, model)
      )
      log_report_extension = chainer.training.extensions.LogReport(
          log_name=None
      )
      trainer.extend(
          chainer.training.extensions.PrintReport(
              [
                  "epoch",
                  "main/loss",
                  "validation/main/loss",
                  "main/accuracy",
                  "validation/main/accuracy",
              ]
          )
      )
      trainer.extend(log_report_extension)
  
      trainer.extend(
          ChainerPruningExtension(
              trial, "validation/main/accuracy", (1, "epoch")
          )
      )
  
      # Run!
      trainer.run(show_loop_exception_msg=False)
  
      # Set the user attributes such as loss and accuracy for train and
      # validation sets
      log_last = log_report_extension.log[-1]
      for key, value in log_last.items():
          trial.set_user_attr(key, value)
  
      # Return the validation accuracy
      return log_report_extension.log[-1]["validation/main/accuracy"]
  
file_path: chainer/examples/optuna/chainer_simple.py
imports: import chainer
  import chainer.functions
  import chainer.links
  import numpy
  from packaging import version
  import optuna
  from optuna.integration import ChainerPruningExtension
label_desc: Use image node_id 3 for calling a global function with example usage: objective(trial) and returns: log_report_extension