






import tempfile

import torch

from diffusers import PNDMScheduler

from .test_schedulers import SchedulerCommonTest


class       __SCREAMING_SNAKE_CASE   (				lowercase__):
      _SCREAMING_SNAKE_CASE		:    str						=   (PNDMScheduler,)
      _SCREAMING_SNAKE_CASE		:    str						=   (("""num_inference_steps""", 50),)






      def  UpperCamelCase__ (		self       ,  **_UpperCamelCase				):






            """simple docstring"""
            lowerCAmelCase__        =  {
                "num_train_timesteps": 10_00,
                "beta_start": 0.00_01,
                "beta_end": 0.02,
                "beta_schedule": "linear",
            }

            config.update(**lowercase_				)
            return config






      def  UpperCamelCase__ (		self       ,  _UpperCamelCase=0       ,  **_UpperCamelCase				):






            """simple docstring"""
            lowerCAmelCase__        =  dict(self.forward_default_kwargs				)
            lowerCAmelCase__        =  kwargs.pop('num_inference_steps'       ,  lowercase_				)
            lowerCAmelCase__        =  self.dummy_sample
            lowerCAmelCase__        =  0.1 * sample
            lowerCAmelCase__        =  [residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]

            for scheduler_class in self.scheduler_classes:
                  lowerCAmelCase__        =  self.get_scheduler_config(**lowercase_				)
                  lowerCAmelCase__        =  scheduler_class(**lowercase_				)
                  scheduler.set_timesteps(lowercase_				)
                  # copy over dummy past residuals
                  lowerCAmelCase__        =  dummy_past_residuals[:]

                  with tempfile.TemporaryDirectory() as tmpdirname:
                        scheduler.save_config(lowercase_				)
                        lowerCAmelCase__        =  scheduler_class.from_pretrained(lowercase_				)
                        new_scheduler.set_timesteps(lowercase_				)
                        # copy over dummy past residuals
                        lowerCAmelCase__        =  dummy_past_residuals[:]

                  lowerCAmelCase__        =  scheduler.step_prk(lowercase_       ,  lowercase_       ,  lowercase_       ,  **lowercase_				).prev_sample
                  lowerCAmelCase__        =  new_scheduler.step_prk(lowercase_       ,  lowercase_       ,  lowercase_       ,  **lowercase_				).prev_sample

                  assert torch.sum(torch.abs(output - new_output				)				) < 1E-5, "Scheduler outputs are not identical"

                  lowerCAmelCase__        =  scheduler.step_plms(lowercase_       ,  lowercase_       ,  lowercase_       ,  **lowercase_				).prev_sample
                  lowerCAmelCase__        =  new_scheduler.step_plms(lowercase_       ,  lowercase_       ,  lowercase_       ,  **lowercase_				).prev_sample

                  assert torch.sum(torch.abs(output - new_output				)				) < 1E-5, "Scheduler outputs are not identical"






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            pass






      def  UpperCamelCase__ (		self       ,  _UpperCamelCase=0       ,  **_UpperCamelCase				):






            """simple docstring"""
            lowerCAmelCase__        =  dict(self.forward_default_kwargs				)
            lowerCAmelCase__        =  kwargs.pop('num_inference_steps'       ,  lowercase_				)
            lowerCAmelCase__        =  self.dummy_sample
            lowerCAmelCase__        =  0.1 * sample
            lowerCAmelCase__        =  [residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]

            for scheduler_class in self.scheduler_classes:
                  lowerCAmelCase__        =  self.get_scheduler_config()
                  lowerCAmelCase__        =  scheduler_class(**lowercase_				)
                  scheduler.set_timesteps(lowercase_				)

                  # copy over dummy past residuals (must be after setting timesteps)
                  lowerCAmelCase__        =  dummy_past_residuals[:]

                  with tempfile.TemporaryDirectory() as tmpdirname:
                        scheduler.save_config(lowercase_				)
                        lowerCAmelCase__        =  scheduler_class.from_pretrained(lowercase_				)
                        # copy over dummy past residuals
                        new_scheduler.set_timesteps(lowercase_				)

                        # copy over dummy past residual (must be after setting timesteps)
                        lowerCAmelCase__        =  dummy_past_residuals[:]

                  lowerCAmelCase__        =  scheduler.step_prk(lowercase_       ,  lowercase_       ,  lowercase_       ,  **lowercase_				).prev_sample
                  lowerCAmelCase__        =  new_scheduler.step_prk(lowercase_       ,  lowercase_       ,  lowercase_       ,  **lowercase_				).prev_sample

                  assert torch.sum(torch.abs(output - new_output				)				) < 1E-5, "Scheduler outputs are not identical"

                  lowerCAmelCase__        =  scheduler.step_plms(lowercase_       ,  lowercase_       ,  lowercase_       ,  **lowercase_				).prev_sample
                  lowerCAmelCase__        =  new_scheduler.step_plms(lowercase_       ,  lowercase_       ,  lowercase_       ,  **lowercase_				).prev_sample

                  assert torch.sum(torch.abs(output - new_output				)				) < 1E-5, "Scheduler outputs are not identical"






      def  UpperCamelCase__ (		self       ,  **_UpperCamelCase				):






            """simple docstring"""
            lowerCAmelCase__        =  self.scheduler_classes[0]
            lowerCAmelCase__        =  self.get_scheduler_config(**lowercase_				)
            lowerCAmelCase__        =  scheduler_class(**lowercase_				)

            lowerCAmelCase__        =  10
            lowerCAmelCase__        =  self.dummy_model()
            lowerCAmelCase__        =  self.dummy_sample_deter
            scheduler.set_timesteps(lowercase_				)

            for i, t in enumerate(scheduler.prk_timesteps				):
                  lowerCAmelCase__        =  model(lowercase_       ,  lowercase_				)
                  lowerCAmelCase__        =  scheduler.step_prk(lowercase_       ,  lowercase_       ,  lowercase_				).prev_sample

            for i, t in enumerate(scheduler.plms_timesteps				):
                  lowerCAmelCase__        =  model(lowercase_       ,  lowercase_				)
                  lowerCAmelCase__        =  scheduler.step_plms(lowercase_       ,  lowercase_       ,  lowercase_				).prev_sample

            return sample






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            lowerCAmelCase__        =  dict(self.forward_default_kwargs				)

            lowerCAmelCase__        =  kwargs.pop('num_inference_steps'       ,  lowercase_				)

            for scheduler_class in self.scheduler_classes:
                  lowerCAmelCase__        =  self.get_scheduler_config()
                  lowerCAmelCase__        =  scheduler_class(**lowercase_				)

                  lowerCAmelCase__        =  self.dummy_sample
                  lowerCAmelCase__        =  0.1 * sample

                  if num_inference_steps is not None and hasattr(lowercase_       ,  'set_timesteps'				):
                        scheduler.set_timesteps(lowercase_				)
                  elif num_inference_steps is not None and not hasattr(lowercase_       ,  'set_timesteps'				):
                        lowerCAmelCase__        =  num_inference_steps

                  # copy over dummy past residuals (must be done after set_timesteps)
                  lowerCAmelCase__        =  [residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]
                  lowerCAmelCase__        =  dummy_past_residuals[:]

                  lowerCAmelCase__        =  scheduler.step_prk(lowercase_       ,  0       ,  lowercase_       ,  **lowercase_				).prev_sample
                  lowerCAmelCase__        =  scheduler.step_prk(lowercase_       ,  1       ,  lowercase_       ,  **lowercase_				).prev_sample

                  self.assertEqual(output_a.shape       ,  sample.shape				)
                  self.assertEqual(output_a.shape       ,  output_a.shape				)

                  lowerCAmelCase__        =  scheduler.step_plms(lowercase_       ,  0       ,  lowercase_       ,  **lowercase_				).prev_sample
                  lowerCAmelCase__        =  scheduler.step_plms(lowercase_       ,  1       ,  lowercase_       ,  **lowercase_				).prev_sample

                  self.assertEqual(output_a.shape       ,  sample.shape				)
                  self.assertEqual(output_a.shape       ,  output_a.shape				)






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            for timesteps in [1_00, 10_00]:
                  self.check_over_configs(num_train_timesteps=lowercase_				)






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            for steps_offset in [0, 1]:
                  self.check_over_configs(steps_offset=lowercase_				)

            lowerCAmelCase__        =  self.scheduler_classes[0]
            lowerCAmelCase__        =  self.get_scheduler_config(steps_offset=1				)
            lowerCAmelCase__        =  scheduler_class(**lowercase_				)
            scheduler.set_timesteps(10				)
            assert torch.equal(
                scheduler.timesteps       ,  torch.LongTensor(
                    [9_01, 8_51, 8_51, 8_01, 8_01, 7_51, 7_51, 7_01, 7_01, 6_51, 6_51, 6_01, 6_01, 5_01, 4_01, 3_01, 2_01, 1_01, 1]				)       ,  )






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            for beta_start, beta_end in zip([0.00_01, 0.0_01]       ,  [0.0_02, 0.02]				):
                  self.check_over_configs(beta_start=lowercase_       ,  beta_end=lowercase_				)






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            for schedule in ["linear", "squaredcos_cap_v2"]:
                  self.check_over_configs(beta_schedule=lowercase_				)






      def  UpperCamelCase__ (		self				):






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






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            for t in [1, 5, 10]:
                  self.check_over_forward(time_step=lowercase_				)






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            for t, num_inference_steps in zip([1, 5, 10]       ,  [10, 50, 1_00]				):
                  self.check_over_forward(num_inference_steps=lowercase_				)






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            lowerCAmelCase__        =  27

            for scheduler_class in self.scheduler_classes:
                  lowerCAmelCase__        =  self.dummy_sample
                  lowerCAmelCase__        =  0.1 * sample

                  lowerCAmelCase__        =  self.get_scheduler_config()
                  lowerCAmelCase__        =  scheduler_class(**lowercase_				)

                  scheduler.set_timesteps(lowercase_				)

                  # before power of 3 fix, would error on first step, so we only need to do two
                  for i, t in enumerate(scheduler.prk_timesteps[:2]				):
                        lowerCAmelCase__        =  scheduler.step_prk(lowercase_       ,  lowercase_       ,  lowercase_				).prev_sample






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            with self.assertRaises(lowercase_				):
                  lowerCAmelCase__        =  self.scheduler_classes[0]
                  lowerCAmelCase__        =  self.get_scheduler_config()
                  lowerCAmelCase__        =  scheduler_class(**lowercase_				)

                  scheduler.step_plms(self.dummy_sample       ,  1       ,  self.dummy_sample				).prev_sample






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            lowerCAmelCase__        =  self.full_loop()
            lowerCAmelCase__        =  torch.sum(torch.abs(lowercase_				)				)
            lowerCAmelCase__        =  torch.mean(torch.abs(lowercase_				)				)

            assert abs(result_sum.item() - 1_98.13_18				) < 1E-2
            assert abs(result_mean.item() - 0.25_80				) < 1E-3






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            lowerCAmelCase__        =  self.full_loop(prediction_type='v_prediction'				)
            lowerCAmelCase__        =  torch.sum(torch.abs(lowercase_				)				)
            lowerCAmelCase__        =  torch.mean(torch.abs(lowercase_				)				)

            assert abs(result_sum.item() - 67.39_86				) < 1E-2
            assert abs(result_mean.item() - 0.08_78				) < 1E-3






      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            lowerCAmelCase__        =  self.full_loop(set_alpha_to_one=lowercase_       ,  beta_start=0.01				)
            lowerCAmelCase__        =  torch.sum(torch.abs(lowercase_				)				)
            lowerCAmelCase__        =  torch.mean(torch.abs(lowercase_				)				)

            assert abs(result_sum.item() - 2_30.03_99				) < 1E-2
            assert abs(result_mean.item() - 0.29_95				) < 1E-3







      def  UpperCamelCase__ (		self				):






            """simple docstring"""
            lowerCAmelCase__        =  self.full_loop(set_alpha_to_one=lowercase_       ,  beta_start=0.01				)
            lowerCAmelCase__        =  torch.sum(torch.abs(lowercase_				)				)
            lowerCAmelCase__        =  torch.mean(torch.abs(lowercase_				)				)

            assert abs(result_sum.item() - 1_86.94_82				) < 1E-2
            assert abs(result_mean.item() - 0.24_34				) < 1E-3













from __future__ import annotations

from collections.abc import Generator

import requests
from bsa import BeautifulSoup

__snake_case      :      Any             =       """https://www.indeed.co.in/jobs?q=mobile+app+development&l="""







def 		_UpperCamelCase				(      UpperCamelCase_    :   str = "mumbai"						)					->				Generator[tuple[str, str], None, None]:

						"""simple docstring"""



						lowerCAmelCase__        =  BeautifulSoup(requests.get(url + location						).content      ,    'html.parser'						)
						# This attribute finds out all the specifics listed in a job
						for job in soup.find_all('div'      ,    attrs={'data-tn-component': 'organicJob'}						):
												lowerCAmelCase__        =  job.find('a'      ,    attrs={'data-tn-element': 'jobTitle'}						).text.strip()
												lowerCAmelCase__        =  job.find('span'      ,    {'class': 'company'}						).text.strip()
												yield job_title, company_name


if __name__ == "__main__":
					for i, job in enumerate(fetch_jobs("""Bangalore"""), 1):
										print(f'Job {i:>2} is {job[0]} at {job[1]}')





