docstr: DPM-Solver-1 (equivalent to DDIM) from time `s` to time `t`.
  
  Args:
      x: A pytorch tensor. The initial value at time `s`.
      s: A pytorch tensor. The starting time, with the shape (x.shape[0],).
      t: A pytorch tensor. The ending time, with the shape (x.shape[0],).
      model_s: A pytorch tensor. The model function evaluated at time `s`.
          If `model_s` is None, we evaluate the model by `x` and `s`; otherwise we directly use it.
      return_intermediate: A `bool`. If true, also return the model value at time `s`.
  Returns:
      x_t: A pytorch tensor. The approximated solution at time `t`.
docstr_tok: ["DPM-Solver-1","(","equivalent","to","DDIM",")","from","time","`","s","`","to","time","`","t","`",".","Args",":","x",":","A","pytorch","tensor",".","The","initial","value","at","time","`","s","`",".","s",":","A","pytorch","tensor",".","The","starting","time",",","with","the","shape","(","x.shape","[","0","]",",",")",".","t",":","A","pytorch","tensor",".","The","ending","time",",","with","the","shape","(","x.shape","[","0","]",",",")",".","model_s",":","A","pytorch","tensor",".","The","model","function","evaluated","at","time","`","s","`",".","If","`","model_s","`","is","None",",","we","evaluate","the","model","by","`","x","`","and","`","s","`",";","otherwise","we","directly","use","it",".","return_intermediate",":","A","`","bool","`",".","If","true",",","also","return","the","model","value","at","time","`","s","`",".","Returns",":","x_t",":","A","pytorch","tensor",".","The","approximated","solution","at","time","`","t","`","."]
code: def dpm_solver_first_update(
      self, x, s, t, model_s=None, return_intermediate=False
  ):
      """
      DPM-Solver-1 (equivalent to DDIM) from time `s` to time `t`.
  
      Args:
          x: A pytorch tensor. The initial value at time `s`.
          s: A pytorch tensor. The starting time, with the shape (x.shape[0],).
          t: A pytorch tensor. The ending time, with the shape (x.shape[0],).
          model_s: A pytorch tensor. The model function evaluated at time `s`.
              If `model_s` is None, we evaluate the model by `x` and `s`; otherwise we directly use it.
          return_intermediate: A `bool`. If true, also return the model value at time `s`.
      Returns:
          x_t: A pytorch tensor. The approximated solution at time `t`.
      """
      ns = self.noise_schedule
      dims = x.dim()
      lambda_s, lambda_t = ns.marginal_lambda(s), ns.marginal_lambda(t)
      h = lambda_t - lambda_s
      log_alpha_s, log_alpha_t = ns.marginal_log_mean_coeff(
          s
      ), ns.marginal_log_mean_coeff(t)
      sigma_s, sigma_t = ns.marginal_std(s), ns.marginal_std(t)
      alpha_t = torch.exp(log_alpha_t)
  
      if self.predict_x0:
          phi_1 = torch.expm1(-h)
          if model_s is None:
              model_s = self.model_fn(x, s)
          x_t = (
              expand_dims(sigma_t / sigma_s, dims) * x
              - expand_dims(alpha_t * phi_1, dims) * model_s
          )
          if return_intermediate:
              return x_t, {"model_s": model_s}
          else:
              return x_t
      else:
          phi_1 = torch.expm1(h)
          if model_s is None:
              model_s = self.model_fn(x, s)
          x_t = (
              expand_dims(torch.exp(log_alpha_t - log_alpha_s), dims)
              * x
              - expand_dims(sigma_t * phi_1, dims) * model_s
          )
          if return_intermediate:
              return x_t, {"model_s": model_s}
          else:
              return x_t
  
imports: import torch
  import torch.nn.functional
  import math
label_desc: Use image node_id 8 for calling the DPM_Solver obj's underlying member method code with example usage: obj.dpm_solver_first_update(x, s, t, model_s, return_intermediate) and returns: x_t,  dict, x_t, x_t,  dict, x_t