
'''simple docstring'''



import torch

from diffusers import KDPMaDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest





class 	A							(				lowerCAmelCase_ ):
			lowerCamelCase							:							Dict										=     (KDPMaDiscreteScheduler,)
			lowerCamelCase							:							Tuple										=     10



			def A__       (    self				,   **lowerCamelCase__				)	->						Optional[Any]:




									'''simple docstring'''



									lowercase__							       =				{
									    """num_train_timesteps""": 1_100,
									    """beta_start""": 0.00_01,
									    """beta_end""": 0.02,
									    """beta_schedule""": """linear""",
									}

									config.update(**__lowerCAmelCase				)
									return config



			def A__       (    self				)	->						Any:




									'''simple docstring'''



									for timesteps in [10, 50, 100, 1_000]:
															self.check_over_configs(num_train_timesteps=__lowerCAmelCase				)



			def A__       (    self				)	->						Optional[Any]:




									'''simple docstring'''



									for beta_start, beta_end in zip([0.0_00_01, 0.00_01, 0.0_01]				,   [0.00_02, 0.0_02, 0.02]				):
															self.check_over_configs(beta_start=__lowerCAmelCase				,   beta_end=__lowerCAmelCase				)



			def A__       (    self				)	->						List[str]:




									'''simple docstring'''



									for schedule in ["linear", "scaled_linear"]:
															self.check_over_configs(beta_schedule=__lowerCAmelCase				)



			def A__       (    self				)	->						List[Any]:




									'''simple docstring'''



									for prediction_type in ["epsilon", "v_prediction"]:
															self.check_over_configs(prediction_type=__lowerCAmelCase				)



			def A__       (    self				)	->						List[Any]:




									'''simple docstring'''



									lowercase__							       =				self.scheduler_classes[0]
									lowercase__							       =				self.get_scheduler_config(prediction_type="""v_prediction"""				)
									lowercase__							       =				scheduler_class(**__lowerCAmelCase				)

									scheduler.set_timesteps(self.num_inference_steps				)

									lowercase__							       =				self.dummy_model()
									lowercase__							       =				self.dummy_sample_deter * scheduler.init_noise_sigma
									lowercase__							       =				sample.to(__lowerCAmelCase				)

									for i, t in enumerate(scheduler.timesteps				):
															lowercase__							       =				scheduler.scale_model_input(__lowerCAmelCase				,   __lowerCAmelCase				)

															lowercase__							       =				model(__lowerCAmelCase				,   __lowerCAmelCase				)

															lowercase__							       =				scheduler.step(__lowerCAmelCase				,   __lowerCAmelCase				,   __lowerCAmelCase				)
															lowercase__							       =				output.prev_sample

									lowercase__							       =				torch.sum(torch.abs(__lowerCAmelCase				)				)
									lowercase__							       =				torch.mean(torch.abs(__lowerCAmelCase				)				)

									if torch_device in ["cpu", "mps"]:
															assert abs(result_sum.item() - 4.6934e-07				) < 1e-2
															assert abs(result_mean.item() - 6.1112e-10				) < 1e-3
									else:
															# CUDA
															assert abs(result_sum.item() - 4.693_4286_5017_0972e-07				) < 1e-2
															assert abs(result_mean.item() - 0.00_02				) < 1e-3



			def A__       (    self				)	->						List[str]:




									'''simple docstring'''



									if torch_device == "mps":
															return
									lowercase__							       =				self.scheduler_classes[0]
									lowercase__							       =				self.get_scheduler_config()
									lowercase__							       =				scheduler_class(**__lowerCAmelCase				)

									scheduler.set_timesteps(self.num_inference_steps				)

									lowercase__							       =				self.dummy_model()
									lowercase__							       =				self.dummy_sample_deter * scheduler.init_noise_sigma
									lowercase__							       =				sample.to(__lowerCAmelCase				)

									for i, t in enumerate(scheduler.timesteps				):
															lowercase__							       =				scheduler.scale_model_input(__lowerCAmelCase				,   __lowerCAmelCase				)

															lowercase__							       =				model(__lowerCAmelCase				,   __lowerCAmelCase				)

															lowercase__							       =				scheduler.step(__lowerCAmelCase				,   __lowerCAmelCase				,   __lowerCAmelCase				)
															lowercase__							       =				output.prev_sample

									lowercase__							       =				torch.sum(torch.abs(__lowerCAmelCase				)				)
									lowercase__							       =				torch.mean(torch.abs(__lowerCAmelCase				)				)

									if torch_device in ["cpu", "mps"]:
															assert abs(result_sum.item() - 20.41_25				) < 1e-2
															assert abs(result_mean.item() - 0.02_66				) < 1e-3
									else:
															# CUDA
															assert abs(result_sum.item() - 20.41_25				) < 1e-2
															assert abs(result_mean.item() - 0.02_66				) < 1e-3



			def A__       (    self				)	->						List[str]:




									'''simple docstring'''



									if torch_device == "mps":
															return
									lowercase__							       =				self.scheduler_classes[0]
									lowercase__							       =				self.get_scheduler_config()
									lowercase__							       =				scheduler_class(**__lowerCAmelCase				)

									scheduler.set_timesteps(self.num_inference_steps				,   device=__lowerCAmelCase				)

									lowercase__							       =				self.dummy_model()
									lowercase__							       =				self.dummy_sample_deter.to(__lowerCAmelCase				) * scheduler.init_noise_sigma

									for t in scheduler.timesteps:
															lowercase__							       =				scheduler.scale_model_input(__lowerCAmelCase				,   __lowerCAmelCase				)

															lowercase__							       =				model(__lowerCAmelCase				,   __lowerCAmelCase				)

															lowercase__							       =				scheduler.step(__lowerCAmelCase				,   __lowerCAmelCase				,   __lowerCAmelCase				)
															lowercase__							       =				output.prev_sample

									lowercase__							       =				torch.sum(torch.abs(__lowerCAmelCase				)				)
									lowercase__							       =				torch.mean(torch.abs(__lowerCAmelCase				)				)

									if str(__lowerCAmelCase				).startswith("""cpu"""				):
															# The following sum varies between 148 and 156 on mps. Why?
															assert abs(result_sum.item() - 20.41_25				) < 1e-2
															assert abs(result_mean.item() - 0.02_66				) < 1e-3
									else:
															# CUDA
															assert abs(result_sum.item() - 20.41_25				) < 1e-2
															assert abs(result_mean.item() - 0.02_66				) < 1e-3







"""simple docstring"""


import requests

UpperCAmelCase__     						=  """"""  # <-- Put your OpenWeatherMap appid here!
UpperCAmelCase__     						=  """https://api.openweathermap.org/data/2.5/"""






def 			__UpperCAmelCase    (	lowercase = "Chicago"      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """weather"""      ,params=locals()						).json()






def 			__UpperCAmelCase    (	lowercase = "Kolkata, India"      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """forecast"""      ,params=locals()						).json()






def 			__UpperCAmelCase    (	lowercase = 55.68      ,lowercase = 12.57      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """onecall"""      ,params=locals()						).json()


if __name__ == "__main__":
    from pprint import pprint

    while True:
        UpperCAmelCase__     						=  input("""Enter a location:""").strip()
        if location:
            pprint(current_weather(location))
        else:
            break
