code: def logs2pil(logs, keys=["sample"]):
      imgs = dict()
      for k in logs:
          try:
              if len(logs[k].shape) == 4:
                  img = custom_to_pil(logs[k][0, ...])
              elif len(logs[k].shape) == 3:
                  img = custom_to_pil(logs[k])
              else:
                  print(f"Unknown format for key {k}. ")
                  img = None
          except:
              img = None
          imgs[k] = img
      return imgs
  
imports: import argparse
  import datetime
  import glob
  import os
  import sys
  import time
  import numpy
  import torch
  import yaml
  from ldm.models.diffusion.ddim import DDIMSampler
  from ldm.util import instantiate_from_config
  from omegaconf import OmegaConf
  from PIL import Image
  from tqdm import trange
label_desc: Use image node_id 3 for calling a global function with example usage: logs2pil(logs, keys) and returns: imgs