'''simple docstring'''





from dataclasses import dataclass
from typing import Optional, Tuple, Union

import numpy as np
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, randn_tensor
from .scheduling_utils import SchedulerMixin






@dataclass
class 				UpperCAmelCase (       _SCREAMING_SNAKE_CASE ):




    '''simple docstring'''







    snake_case__							:   torch.FloatTensor
    snake_case__							:   torch.FloatTensor
    snake_case__							:   Optional[torch.FloatTensor]							=						None






class 				UpperCAmelCase (       _SCREAMING_SNAKE_CASE   ,    _SCREAMING_SNAKE_CASE ):




    '''simple docstring'''







    snake_case__							:   Union[str, Any]							=						2






    @register_to_config
    def __init__(       self    ,							lowercase__ = 0.0_2    ,							lowercase__ = 100    ,							lowercase__ = 1.0_0_7    ,							lowercase__ = 80    ,							lowercase__ = 0.0_5    ,							lowercase__ = 50    ,							)							-> Union[str, Any]:
         # standard deviation of the initial noise distribution
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       sigma_max

         # setable values
         SCREAMING_SNAKE_CASE					:			int    	=       None
         SCREAMING_SNAKE_CASE					:			np.IntTensor    	=       None
         SCREAMING_SNAKE_CASE					:			torch.FloatTensor    	=       None  # sigma(t_i)






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__ = None )							-> torch.FloatTensor:
         return sample






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__ = None )							-> Dict:
         SCREAMING_SNAKE_CASE					:			int    	=       num_inference_steps
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       np.arange(0    ,							self.num_inference_steps )[::-1].copy()
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       torch.from_numpy(lowercase__ ).to(lowercase__ )
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       [
             (
                 self.config.sigma_max**2
                 * (self.config.sigma_min**2 / self.config.sigma_max**2) ** (i / (num_inference_steps - 1))
             )
             for i in self.timesteps
         ]
         SCREAMING_SNAKE_CASE					:			int    	=       torch.tensor(lowercase__    ,							dtype=torch.floataa    ,							device=lowercase__ )






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__    ,							lowercase__ = None )							-> Tuple[torch.FloatTensor, float]:
         if self.config.s_min <= sigma <= self.config.s_max:
              SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       min(self.config.s_churn / self.num_inference_steps    ,							2**0.5 - 1 )
         else:
              SCREAMING_SNAKE_CASE					:			List[Any]    	=       0

         # sample eps ~ N(0, S_noise^2 * I)
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       self.config.s_noise * randn_tensor(sample.shape    ,							generator=lowercase__ ).to(sample.device )
         SCREAMING_SNAKE_CASE					:			int    	=       sigma + gamma * sigma
         SCREAMING_SNAKE_CASE					:			int    	=       sample + ((sigma_hat**2 - sigma**2) ** 0.5 * eps)

         return sample_hat, sigma_hat






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__    ,							lowercase__    ,							lowercase__    ,							lowercase__ = True    ,							)							-> Union[KarrasVeOutput, Tuple]:
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       sample_hat + sigma_hat * model_output
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       (sample_hat - pred_original_sample) / sigma_hat
         SCREAMING_SNAKE_CASE					:			Dict    	=       sample_hat + (sigma_prev - sigma_hat) * derivative

         if not return_dict:
              return (sample_prev, derivative)

         return KarrasVeOutput(
             prev_sample=lowercase__    ,							derivative=lowercase__    ,							pred_original_sample=lowercase__ )






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__    ,							lowercase__    ,							lowercase__    ,							lowercase__    ,							lowercase__    ,							lowercase__ = True    ,							)							-> Union[KarrasVeOutput, Tuple]:
         SCREAMING_SNAKE_CASE					:			Dict    	=       sample_prev + sigma_prev * model_output
         SCREAMING_SNAKE_CASE					:			List[str]    	=       (sample_prev - pred_original_sample) / sigma_prev
         SCREAMING_SNAKE_CASE					:			Any    	=       sample_hat + (sigma_prev - sigma_hat) * (0.5 * derivative + 0.5 * derivative_corr)

         if not return_dict:
              return (sample_prev, derivative)

         return KarrasVeOutput(
             prev_sample=lowercase__    ,							derivative=lowercase__    ,							pred_original_sample=lowercase__ )






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__    ,							lowercase__ )							-> str:
         raise NotImplementedError()




'''simple docstring'''





def     __lowerCAmelCase						(       a_ = 1000		)      ->	int:





     '''simple docstring'''





     SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       2**power
     SCREAMING_SNAKE_CASE					:			Any    	=       str(a_		)
     SCREAMING_SNAKE_CASE					:			int    	=       list(a_		)
     SCREAMING_SNAKE_CASE					:			Any    	=       0

     for i in list_num:
          sum_of_num += int(a_		)

     return sum_of_num


if __name__ == "__main__":
 _lowerCAmelCase  :Tuple  				=    int(input("""Enter the power of 2: """).strip())
 print("""2 ^ """, power, """ = """, 2**power)
 _lowerCAmelCase  :int  				=    solution(power)
 print("""Sum of the digits is: """, result)



