docstr: The adaptive step size solver based on singlestep DPM-Solver.
  
  Args:
      x: A pytorch tensor. The initial value at time `t_T`.
      order: A `int`. The (higher) order of the solver. We only support order == 2 or 3.
      t_T: A `float`. The starting time of the sampling (default is T).
      t_0: A `float`. The ending time of the sampling (default is epsilon).
      h_init: A `float`. The initial step size (for logSNR).
      atol: A `float`. The absolute tolerance of the solver. For image data, the default setting is 0.0078, followed [1].
      rtol: A `float`. The relative tolerance of the solver. The default setting is 0.05.
      theta: A `float`. The safety hyperparameter for adapting the step size. The default setting is 0.9, followed [1].
      t_err: A `float`. The tolerance for the time. We solve the diffusion ODE until the absolute error between the 
          current time and `t_0` is less than `t_err`. The default setting is 1e-5.
      solver_type: either 'dpm_solver' or 'taylor'. The type for the high-order solvers.
          The type slightly impacts the performance. We recommend to use 'dpm_solver' type.
  Returns:
      x_0: A pytorch tensor. The approximated solution at time `t_0`.
  
  [1] A. Jolicoeur-Martineau, K. Li, R. Piché-Taillefer, T. Kachman, and I. Mitliagkas, "Gotta go fast when generating data with score-based models," arXiv preprint arXiv:2105.14080, 2021.
docstr_tok: ["The","adaptive","step","size","solver","based","on","singlestep","DPM-Solver",".","Args",":","x",":","A","pytorch","tensor",".","The","initial","value","at","time","`","t_T","`",".","order",":","A","`","int","`",".","The","(","higher",")","order","of","the","solver",".","We","only","support","order","==","2","or","3.","t_T",":","A","`","float","`",".","The","starting","time","of","the","sampling","(","default","is","T",")",".","t_0",":","A","`","float","`",".","The","ending","time","of","the","sampling","(","default","is","epsilon",")",".","h_init",":","A","`","float","`",".","The","initial","step","size","(","for","logSNR",")",".","atol",":","A","`","float","`",".","The","absolute","tolerance","of","the","solver",".","For","image","data",",","the","default","setting","is","0.0078",",","followed","[","1","]",".","rtol",":","A","`","float","`",".","The","relative","tolerance","of","the","solver",".","The","default","setting","is","0.05.","theta",":","A","`","float","`",".","The","safety","hyperparameter","for","adapting","the","step","size",".","The","default","setting","is","0.9",",","followed","[","1","]",".","t_err",":","A","`","float","`",".","The","tolerance","for","the","time",".","We","solve","the","diffusion","ODE","until","the","absolute","error","between","the","current","time","and","`","t_0","`","is","less","than","`","t_err","`",".","The","default","setting","is","1e-5",".","solver_type",":","either","'dpm_solver","'","or","'taylor","'",".","The","type","for","the","high-order","solvers",".","The","type","slightly","impacts","the","performance",".","We","recommend","to","use","'dpm_solver","'","type",".","Returns",":","x_0",":","A","pytorch","tensor",".","The","approximated","solution","at","time","`","t_0","`",".","[","1","]","A.","Jolicoeur-Martineau",",","K.","Li",",","R.","Pich\u00e9-Taillefer",",","T.","Kachman",",","and","I.","Mitliagkas",",","``","Got","ta","go","fast","when","generating","data","with","score-based","models",",","''","arXiv","preprint","arXiv:2105.14080",",","2021","."]
code: def dpm_solver_adaptive(
      self,
      x,
      order,
      t_T,
      t_0,
      h_init=0.05,
      atol=0.0078,
      rtol=0.05,
      theta=0.9,
      t_err=1e-5,
      solver_type="dpm_solver",
  ):
      """
      The adaptive step size solver based on singlestep DPM-Solver.
  
      Args:
          x: A pytorch tensor. The initial value at time `t_T`.
          order: A `int`. The (higher) order of the solver. We only support order == 2 or 3.
          t_T: A `float`. The starting time of the sampling (default is T).
          t_0: A `float`. The ending time of the sampling (default is epsilon).
          h_init: A `float`. The initial step size (for logSNR).
          atol: A `float`. The absolute tolerance of the solver. For image data, the default setting is 0.0078, followed [1].
          rtol: A `float`. The relative tolerance of the solver. The default setting is 0.05.
          theta: A `float`. The safety hyperparameter for adapting the step size. The default setting is 0.9, followed [1].
          t_err: A `float`. The tolerance for the time. We solve the diffusion ODE until the absolute error between the
              current time and `t_0` is less than `t_err`. The default setting is 1e-5.
          solver_type: either 'dpm_solver' or 'taylor'. The type for the high-order solvers.
              The type slightly impacts the performance. We recommend to use 'dpm_solver' type.
      Returns:
          x_0: A pytorch tensor. The approximated solution at time `t_0`.
  
      [1] A. Jolicoeur-Martineau, K. Li, R. Piché-Taillefer, T. Kachman, and I. Mitliagkas, "Gotta go fast when generating data with score-based models," arXiv preprint arXiv:2105.14080, 2021.
      """
      ns = self.noise_schedule
      s = t_T * torch.ones((x.shape[0],)).to(x)
      lambda_s = ns.marginal_lambda(s)
      lambda_0 = ns.marginal_lambda(t_0 * torch.ones_like(s).to(x))
      h = h_init * torch.ones_like(s).to(x)
      x_prev = x
      nfe = 0
      if order == 2:
          r1 = 0.5
          lower_update = lambda x, s, t: self.dpm_solver_first_update(
              x, s, t, return_intermediate=True
          )
          higher_update = lambda x, s, t, **kwargs: self.singlestep_dpm_solver_second_update(
              x, s, t, r1=r1, solver_type=solver_type, **kwargs
          )
      elif order == 3:
          r1, r2 = 1.0 / 3.0, 2.0 / 3.0
          lower_update = (
              lambda x, s, t: self.singlestep_dpm_solver_second_update(
                  x,
                  s,
                  t,
                  r1=r1,
                  return_intermediate=True,
                  solver_type=solver_type,
              )
          )
          higher_update = lambda x, s, t, **kwargs: self.singlestep_dpm_solver_third_update(
              x, s, t, r1=r1, r2=r2, solver_type=solver_type, **kwargs
          )
      else:
          raise ValueError(
              "For adaptive step size solver, order must be 2 or 3, got {}".format(
                  order
              )
          )
      while torch.abs((s - t_0)).mean() > t_err:
          t = ns.inverse_lambda(lambda_s + h)
          x_lower, lower_noise_kwargs = lower_update(x, s, t)
          x_higher = higher_update(x, s, t, **lower_noise_kwargs)
          delta = torch.max(
              torch.ones_like(x).to(x) * atol,
              rtol * torch.max(torch.abs(x_lower), torch.abs(x_prev)),
          )
          norm_fn = lambda v: torch.sqrt(
              torch.square(v.reshape((v.shape[0], -1))).mean(
                  dim=-1, keepdim=True
              )
          )
          E = norm_fn((x_higher - x_lower) / delta).max()
          if torch.all(E <= 1.0):
              x = x_higher
              s = t
              x_prev = x_lower
              lambda_s = ns.marginal_lambda(s)
          h = torch.min(
              theta * h * torch.float_power(E, -1.0 / order).float(),
              lambda_0 - lambda_s,
          )
          nfe += order
      print("adaptive solver nfe", nfe)
      return x
  
imports: import torch
  import torch.nn.functional
  import math
label_desc: Use image node_id 15 for calling the DPM_Solver obj's underlying member method code with example usage: obj.dpm_solver_adaptive(x, order, t_T, t_0, h_init, atol, rtol, theta, t_err, solver_type) and returns: x