code: def save_images(
      device, encoder, decoder, train, test, prior, out_dir
  ):
      # Training samples
      train_ind = [1, 3, 5, 10, 2, 0, 13, 15, 17]
      x = device.send(np.asarray(train[train_ind]))
      with chainer.using_config("train", False):
          with chainer.no_backprop_mode():
              z = encoder(x).mean
              y = decoder(z, inference=True).mean
              y = y.array
      save3x3(x, os.path.join(out_dir, "train"))
      save3x3(y, os.path.join(out_dir, "train_reconstructed"))
  
      # Test samples
      test_ind = [3, 2, 1, 18, 4, 8, 11, 17, 61]
      x = device.send(np.asarray(test[test_ind]))
      with chainer.using_config("train", False):
          with chainer.no_backprop_mode():
              z = encoder(x).mean
              y = decoder(z, inference=True).mean
              y = y.array
      save3x3(x, os.path.join(out_dir, "test"))
      save3x3(y, os.path.join(out_dir, "test_reconstructed"))
  
      # Draw images from 9 randomly sampled values of z
      z = prior().sample(9)
      with chainer.using_config("train", False):
          with chainer.no_backprop_mode():
              y = decoder(z, inference=True).mean
              y = y.array
      save3x3(y, os.path.join(out_dir, "sampled"))
  
file_path: chainer/examples/vae/train_vae.py
imports: import argparse
  import os
  import warnings
  import matplotlib.pyplot
  import numpy
  import chainer
  from chainer import training
  from chainer.training import extensions
  import chainerx
  import net
  import matplotlib
label_desc: Use image node_id 3 for calling a global function with example usage: save_images(device, encoder, decoder, train, test, prior, out_dir) without return types