code: def grid_stack(
      images: List[np.ndarray], rows: int = None, cols: int = None
  ) -> np.ndarray:
      if rows is None and cols is None:
          rows = int(math.ceil(math.sqrt(len(images))))
          cols = int(math.ceil(len(images) / rows))
      elif rows is None:
          rows = math.ceil(len(images) / cols)
      elif cols is None:
          cols = math.ceil(len(images) / rows)
      else:
          if len(images) > rows * cols:
              raise ValueError(
                  "Number of rows * cols must be greater than number of images"
              )
  
      image_rows = []
      for r in range(rows):
          image_rows.append(
              hstack_autopad(images[r * cols : (r + 1) * cols])
          )
  
      return vstack_autopad(image_rows)
  
file_path: pytorch-toolbelt/pytorch_toolbelt/utils/visualization.py
imports: from __future__ import absolute_import
  import itertools
  import math
  import warnings
  from typing import List, Iterable, Tuple, Optional
  import cv2
  import numpy
  from .torch_utils import image_to_tensor
label_desc: Use image node_id 7 for calling a global function with example usage: grid_stack(images, rows, cols) and returns: vstack_autopad