code: def save_frames_grid(img_array, out_path):
      import torch
      from PIL import Image
      from torchvision.utils import make_grid
  
      if len(img_array.shape) == 3:
          img_array = img_array.unsqueeze(0)
      elif len(img_array.shape) == 5:
          b, t, c, h, w = img_array.shape
          img_array = img_array.view(-1, c, h, w)
      elif len(img_array.shape) == 4:
          pass
      else:
          raise NotImplementedError(
              "Supports only (b,t,c,h,w)-shaped inputs. First two dimensions can be ignored."
          )
  
      assert (
          img_array.shape[1] == 3
      ), "Exepcting input shape of (H, W, 3), i.e. RGB-only."
  
      grid = make_grid(img_array)
      ndarr = grid.permute(1, 2, 0).to("cpu", torch.uint8).numpy()
  
      img = Image.fromarray(ndarr)
  
      img.save(out_path)
  
imports: import gzip
  import logging
  import os
  import random
  import tarfile
  import zipfile
  import cv2
  import decord
  import webdataset
  import numpy
  import torch
  from torch.utils.data.dataset import IterableDataset, ChainDataset
  from decord import VideoReader
  from lavis.common.registry import registry
  from lavis.datasets.datasets.base_dataset import ConcatDataset
  from tqdm import tqdm
label_desc: Use image node_id 8 for calling a global function with example usage: save_frames_grid(img_array, out_path) without return types