docstr: Compute the sample at time `t_end` by DPM-Solver, given the initial `x` at time `t_start`.
docstr_tok: ["Compute","the","sample","at","time","`","t_end","`","by","DPM-Solver",",","given","the","initial","`","x","`","at","time","`","t_start","`","."]
code: def sample(
      self,
      x,
      steps=20,
      t_start=None,
      t_end=None,
      order=3,
      skip_type="time_uniform",
      method="singlestep",
      lower_order_final=True,
      denoise_to_zero=False,
      solver_type="dpm_solver",
      atol=0.0078,
      rtol=0.05,
  ):
      """
      Compute the sample at time `t_end` by DPM-Solver, given the initial `x` at time `t_start`.
      """
      t_0 = (
          1.0 / self.noise_schedule.total_N if t_end is None else t_end
      )
      t_T = self.noise_schedule.T if t_start is None else t_start
      device = x.device
  
      if method == "multistep":
          assert steps >= order
          timesteps = self.get_time_steps(
              skip_type=skip_type,
              t_T=t_T,
              t_0=t_0,
              N=steps,
              device=device,
          )
          assert timesteps.shape[0] - 1 == steps
          with torch.no_grad():
              vec_t = timesteps[0].expand((x.shape[0]))
              model_prev_list = [self.model_fn(x, vec_t)]
              t_prev_list = [vec_t]
              # Init the first `order` values by lower order multistep DPM-Solver.
              for init_order in range(1, order):
                  vec_t = timesteps[init_order].expand(x.shape[0])
                  x = self.multistep_dpm_solver_update(
                      x,
                      model_prev_list,
                      t_prev_list,
                      vec_t,
                      init_order,
                      solver_type=solver_type,
                  )
                  model_prev_list.append(self.model_fn(x, vec_t))
                  t_prev_list.append(vec_t)
              # Compute the remaining values by `order`-th order multistep DPM-Solver.
              for step in range(order, steps + 1):
                  vec_t = timesteps[step].expand(x.shape[0])
                  if lower_order_final and steps < 15:
                      step_order = min(order, steps + 1 - step)
                  else:
                      step_order = order
                  x = self.multistep_dpm_solver_update(
                      x,
                      model_prev_list,
                      t_prev_list,
                      vec_t,
                      step_order,
                      solver_type=solver_type,
                  )
                  for i in range(order - 1):
                      t_prev_list[i] = t_prev_list[i + 1]
                      model_prev_list[i] = model_prev_list[i + 1]
                  t_prev_list[-1] = vec_t
                  # We do not need to evaluate the final model value.
                  if step < steps:
                      model_prev_list[-1] = self.model_fn(x, vec_t)
      if denoise_to_zero:
          x = self.denoise_to_zero_fn(
              x, torch.ones((x.shape[0],)).to(device) * t_0
          )
      return x
  
imports: import math
  import torch
  from nemo.collections.multimodal.modules.stable_diffusion.diffusionmodules.util import expand_dims, interpolate_fn
label_desc: Use image node_id 11 for calling the DPMSolver obj's underlying member method code with example usage: obj.sample(x, steps, t_start, t_end, order, skip_type, method, lower_order_final, denoise_to_zero, solver_type, atol, rtol) and returns: x