class_docstr: ## Configurations
class_docstr_tok: ["#","#","Configurations"]
docstr: Generate samples from test set and save them
code: def sample_images(self, n: int):
      """Generate samples from test set and save them"""
      batch = next(iter(self.valid_dataloader))
      self.generator_xy.eval()
      self.generator_yx.eval()
      with torch.no_grad():
          data_x, data_y = batch["x"].to(
              self.generator_xy.device
          ), batch["y"].to(self.generator_yx.device)
          gen_y = self.generator_xy(data_x)
          gen_x = self.generator_yx(data_y)
  
          # Arrange images along x-axis
          data_x = make_grid(data_x, nrow=5, normalize=True)
          data_y = make_grid(data_y, nrow=5, normalize=True)
          gen_x = make_grid(gen_x, nrow=5, normalize=True)
          gen_y = make_grid(gen_y, nrow=5, normalize=True)
  
          # Arrange images along y-axis
          image_grid = torch.cat((data_x, gen_y, data_y, gen_x), 1)
  
      # Show samples
      plot_image(image_grid)
  
imports: import itertools
  import random
  import zipfile
  from typing import Tuple
  import torch
  import torch.nn
  import torchvision.transforms
  from PIL import Image
  from torch.utils.data import DataLoader, Dataset
  from torchvision.transforms import InterpolationMode
  from torchvision.utils import make_grid
  from labml import lab, tracker, experiment, monit
  from labml.configs import BaseConfigs
  from labml.utils.download import download_file
  from labml.utils.pytorch import get_modules
  from labml_helpers.device import DeviceConfigs
  from labml_helpers.module import Module
label_desc: Use image node_id 1 for calling the Configs obj's underlying member method code with example usage: obj.sample_images(n) without return types