code: def make_batch_sd(image, mask, txt, device, num_samples=1):
      image = np.array(image.convert("RGB"))
      image = image[None].transpose(0, 3, 1, 2)
      image = (
          torch.from_numpy(image).to(dtype=torch.float32) / 127.5 - 1.0
      )
  
      mask = np.array(mask.convert("L"))
      mask = mask.astype(np.float32) / 255.0
      mask = mask[None, None]
      mask[mask < 0.5] = 0
      mask[mask >= 0.5] = 1
      mask = torch.from_numpy(mask)
  
      masked_image = image * (mask < 0.5)
  
      batch = {
          "image": repeat(
              image.to(device=device), "1 ... -> n ...", n=num_samples
          ),
          "txt": num_samples * [txt],
          "mask": repeat(
              mask.to(device=device), "1 ... -> n ...", n=num_samples
          ),
          "masked_image": repeat(
              masked_image.to(device=device),
              "1 ... -> n ...",
              n=num_samples,
          ),
      }
      return batch
  
file_path: StableDiffusion/scripts/streamlit/inpainting.py
imports: import sys
  import cv2
  import torch
  import numpy
  import streamlit
  from PIL import Image
  from omegaconf import OmegaConf
  from einops import repeat
  from streamlit_drawable_canvas import st_canvas
  from imwatermark import WatermarkEncoder
  from ldm.models.diffusion.ddim import DDIMSampler
  from ldm.util import instantiate_from_config
label_desc: Use image node_id 3 for calling a global function with example usage: make_batch_sd(image, mask, txt, device, num_samples) and returns: batch