code: def forward(
      self, z, sigma, cond, uncond, text_cfg_scale, image_cfg_scale
  ):
      cfg_z = einops.repeat(z, "b ... -> (n b) ...", n=3)
      cfg_sigma = einops.repeat(sigma, "b ... -> (n b) ...", n=3)
      cfg_cond = {
          "c_crossattn": [
              torch.cat(
                  [
                      cond["c_crossattn"][0],
                      uncond["c_crossattn"][0],
                      uncond["c_crossattn"][0],
                  ]
              )
          ],
          "c_concat": [
              torch.cat(
                  [
                      cond["c_concat"][0],
                      cond["c_concat"][0],
                      uncond["c_concat"][0],
                  ]
              )
          ],
      }
      out_cond, out_img_cond, out_uncond = self.inner_model(
          cfg_z, cfg_sigma, cond=cfg_cond
      ).chunk(3)
      out = (
          out_uncond
          + text_cfg_scale * (out_cond - out_img_cond)
          + image_cfg_scale * (out_img_cond - out_uncond)
      )
      return out
  
imports: from __future__ import annotations
  import math
  import os
  import random
  import einops
  import numpy
  import torch
  import torch.nn
  from einops import rearrange, repeat
  from omegaconf import OmegaConf, open_dict
  from PIL import Image, ImageOps
  from nemo.collections.multimodal.models.text_to_image.instruct_pix2pix.ldm.ddpm_edit import MegatronLatentDiffusionEdit
  from nemo.collections.multimodal.models.text_to_image.stable_diffusion.samplers.k_diffusion import DiscreteEpsDDPMDenoiser, sample_euler_ancestral
  from nemo.collections.multimodal.parts.utils import setup_trainer_and_model_for_inference
  from nemo.core.config import hydra_runner
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling the CFGDenoiser obj's underlying member method code with example usage: obj.forward(z, sigma, cond, uncond, text_cfg_scale, image_cfg_scale) and returns: out