code: def make_pair_grid(*inputs, orientation="horizontal"):
      # make a grid of images with the outputs and references side by side
      if orientation == "horizontal":
          # interleave the outputs and references
          canvas = torch.zeros_like(inputs[0])
          canvas = torch.cat([canvas] * len(inputs), dim=0)
          size = len(inputs)
          for idx, inp in enumerate(inputs):
              canvas[idx::size, ...] = inp
          grid = make_grid(
              canvas,
              nrow=len(inputs),
              padding=16,
              normalize=True,
              scale_each=True,
          )
      elif orientation == "vertical":
          # interleave the outputs and references
          canvas = torch.cat(inputs, dim=0)
          size = len(inputs)
          for idx, inp in enumerate(inputs):
              canvas[idx::size, ...] = inp
          grid = make_grid(
              canvas,
              nrow=len(inputs[0]),
              padding=16,
              normalize=True,
              scale_each=True,
          )
      else:
          raise ValueError(
              "Unknown orientation: {}".format(orientation)
          )
      return grid
  
file_path: vision/references/depth/stereo/visualization.py
imports: import os
  from typing import List
  import numpy
  import torch
  from torch import Tensor
  from torchvision.utils import make_grid
label_desc: Use image node_id 4 for calling a global function with example usage: make_pair_grid() and returns: grid