code: def paint(
      sampler,
      image,
      prompt,
      t_enc,
      seed,
      scale,
      num_samples=1,
      callback=None,
      do_full_sample=False,
  ):
      device = (
          torch.device("cuda")
          if torch.cuda.is_available()
          else torch.device("cpu")
      )
      model = sampler.model
      seed_everything(seed)
  
      print(
          "Creating invisible watermark encoder (see https://github.com/ShieldMnt/invisible-watermark)..."
      )
      wm = "SDV2"
      wm_encoder = WatermarkEncoder()
      wm_encoder.set_watermark("bytes", wm.encode("utf-8"))
  
      with torch.no_grad(), torch.autocast("cuda"):
          batch = make_batch_sd(
              image, txt=prompt, device=device, num_samples=num_samples
          )
          z = model.get_first_stage_encoding(
              model.encode_first_stage(batch[model.first_stage_key])
          )  # move to latent space
          c = model.cond_stage_model.encode(batch["txt"])
          c_cat = list()
          for ck in model.concat_keys:
              cc = batch[ck]
              cc = model.depth_model(cc)
              depth_min, depth_max = torch.amin(
                  cc, dim=[1, 2, 3], keepdim=True
              ), torch.amax(cc, dim=[1, 2, 3], keepdim=True)
              display_depth = (cc - depth_min) / (depth_max - depth_min)
              depth_image = Image.fromarray(
                  (
                      display_depth[0, 0, ...].cpu().numpy() * 255.0
                  ).astype(np.uint8)
              )
              cc = torch.nn.functional.interpolate(
                  cc,
                  size=z.shape[2:],
                  mode="bicubic",
                  align_corners=False,
              )
              depth_min, depth_max = torch.amin(
                  cc, dim=[1, 2, 3], keepdim=True
              ), torch.amax(cc, dim=[1, 2, 3], keepdim=True)
              cc = (
                  2.0 * (cc - depth_min) / (depth_max - depth_min) - 1.0
              )
              c_cat.append(cc)
          c_cat = torch.cat(c_cat, dim=1)
          # cond
          cond = {"c_concat": [c_cat], "c_crossattn": [c]}
  
          # uncond cond
          uc_cross = model.get_unconditional_conditioning(
              num_samples, ""
          )
          uc_full = {"c_concat": [c_cat], "c_crossattn": [uc_cross]}
          if not do_full_sample:
              # encode (scaled latent)
              z_enc = sampler.stochastic_encode(
                  z,
                  torch.tensor([t_enc] * num_samples).to(model.device),
              )
          else:
              z_enc = torch.randn_like(z)
          # decode it
          samples = sampler.decode(
              z_enc,
              cond,
              t_enc,
              unconditional_guidance_scale=scale,
              unconditional_conditioning=uc_full,
              callback=callback,
          )
          x_samples_ddim = model.decode_first_stage(samples)
          result = torch.clamp(
              (x_samples_ddim + 1.0) / 2.0, min=0.0, max=1.0
          )
          result = result.cpu().numpy().transpose(0, 2, 3, 1) * 255
      return [depth_image] + [
          put_watermark(
              Image.fromarray(img.astype(np.uint8)), wm_encoder
          )
          for img in result
      ]
  
file_path: StableDiffusion/scripts/gradio/depth2img.py
imports: import sys
  import torch
  import numpy
  import gradio
  from PIL import Image
  from omegaconf import OmegaConf
  from einops import repeat, rearrange
  from pytorch_lightning import seed_everything
  from imwatermark import WatermarkEncoder
  from scripts.txt2img import put_watermark
  from ldm.util import instantiate_from_config
  from ldm.models.diffusion.ddim import DDIMSampler
  from ldm.data.util import AddMiDaS
label_desc: Use image node_id 3 for calling a global function with example usage: paint(sampler, image, prompt, t_enc, seed, scale, num_samples, callback, do_full_sample) and returns: unknown