code: def run(
      model,
      logdir,
      batch_size=50,
      vanilla=False,
      custom_steps=None,
      eta=None,
      n_samples=50000,
      nplog=None,
  ):
      if vanilla:
          print(
              f"Using Vanilla DDPM sampling with {model.num_timesteps} sampling steps."
          )
      else:
          print(
              f"Using DDIM sampling with {custom_steps} sampling steps and eta={eta}"
          )
  
      tstart = time.time()
      n_saved = len(glob.glob(os.path.join(logdir, "*.png"))) - 1
      # path = logdir
      if model.cond_stage_model is None:
          all_images = []
  
          print(
              f"Running unconditional sampling for {n_samples} samples"
          )
          for _ in trange(
              n_samples // batch_size,
              desc="Sampling Batches (unconditional)",
          ):
              logs = make_convolutional_sample(
                  model,
                  batch_size=batch_size,
                  vanilla=vanilla,
                  custom_steps=custom_steps,
                  eta=eta,
              )
              n_saved = save_logs(
                  logs, logdir, n_saved=n_saved, key="sample"
              )
              all_images.extend([custom_to_np(logs["sample"])])
              if n_saved >= n_samples:
                  print(f"Finish after generating {n_saved} samples")
                  break
          all_img = np.concatenate(all_images, axis=0)
          all_img = all_img[:n_samples]
          shape_str = "x".join([str(x) for x in all_img.shape])
          nppath = os.path.join(nplog, f"{shape_str}-samples.npz")
          np.savez(nppath, all_img)
  
      else:
          raise NotImplementedError(
              "Currently only sampling for unconditional models supported."
          )
  
      print(
          f"sampling of {n_saved} images finished in {(time.time() - tstart) / 60.:.2f} minutes."
      )
  
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 7 for calling a global function with example usage: run(model, logdir, batch_size, vanilla, custom_steps, eta, n_samples, nplog) without return types