code: def progdist_losses(
      self,
      model,
      x_start,
      num_scales,
      model_kwargs=None,
      teacher_model=None,
      teacher_diffusion=None,
      noise=None,
  ):
      if model_kwargs is None:
          model_kwargs = {}
      if noise is None:
          noise = th.randn_like(x_start)
  
      dims = x_start.ndim
  
      def denoise_fn(x, t):
          return self.denoise(model, x, t, **model_kwargs)[1]
  
      @th.no_grad()
      def teacher_denoise_fn(x, t):
          return teacher_diffusion.denoise(
              teacher_model, x, t, **model_kwargs
          )[1]
  
      @th.no_grad()
      def euler_solver(samples, t, next_t):
          x = samples
          denoiser = teacher_denoise_fn(x, t)
          d = (x - denoiser) / append_dims(t, dims)
          samples = x + d * append_dims(next_t - t, dims)
  
          return samples
  
      @th.no_grad()
      def euler_to_denoiser(x_t, t, x_next_t, next_t):
          denoiser = x_t - append_dims(t, dims) * (
              x_next_t - x_t
          ) / append_dims(next_t - t, dims)
          return denoiser
  
      indices = th.randint(
          0, num_scales, (x_start.shape[0],), device=x_start.device
      )
  
      t = self.sigma_max ** (1 / self.rho) + indices / num_scales * (
          self.sigma_min ** (1 / self.rho)
          - self.sigma_max ** (1 / self.rho)
      )
      t = t**self.rho
  
      t2 = self.sigma_max ** (1 / self.rho) + (
          indices + 0.5
      ) / num_scales * (
          self.sigma_min ** (1 / self.rho)
          - self.sigma_max ** (1 / self.rho)
      )
      t2 = t2**self.rho
  
      t3 = self.sigma_max ** (1 / self.rho) + (
          indices + 1
      ) / num_scales * (
          self.sigma_min ** (1 / self.rho)
          - self.sigma_max ** (1 / self.rho)
      )
      t3 = t3**self.rho
  
      x_t = x_start + noise * append_dims(t, dims)
  
      denoised_x = denoise_fn(x_t, t)
  
      x_t2 = euler_solver(x_t, t, t2).detach()
      x_t3 = euler_solver(x_t2, t2, t3).detach()
  
      target_x = euler_to_denoiser(x_t, t, x_t3, t3).detach()
  
      snrs = self.get_snr(t)
      weights = get_weightings(
          self.weight_schedule, snrs, self.sigma_data
      )
      if self.loss_norm == "l1":
          diffs = th.abs(denoised_x - target_x)
          loss = mean_flat(diffs) * weights
      elif self.loss_norm == "l2":
          diffs = (denoised_x - target_x) ** 2
          loss = mean_flat(diffs) * weights
      elif self.loss_norm == "lpips":
          if x_start.shape[-1] < 256:
              denoised_x = F.interpolate(
                  denoised_x, size=224, mode="bilinear"
              )
              target_x = F.interpolate(
                  target_x, size=224, mode="bilinear"
              )
          loss = (
              self.lpips_loss(
                  (denoised_x + 1) / 2.0,
                  (target_x + 1) / 2.0,
              )
              * weights
          )
      else:
          raise ValueError(f"Unknown loss norm {self.loss_norm}")
  
      terms = {}
      terms["loss"] = loss
  
      return terms
  
imports: import random
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from piq import LPIPS
  from torchvision.transforms import RandomCrop
  from .None import dist_util
  from .nn import mean_flat, append_dims, append_zero
  from .random_util import get_generator
label_desc: Use image node_id 8 for calling the KarrasDenoiser obj's underlying member method code with example usage: obj.progdist_losses(model, x_start, num_scales, model_kwargs, teacher_model, teacher_diffusion, noise) and returns: terms, self, teacher_diffusion, samples, denoiser