






'''simple docstring'''




import random
import unittest

import torch

from diffusers import IFImgaImgPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import (
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin

@skip_mps
class      _UpperCAmelCase    (  a_							,					a_							,					unittest.TestCase		):




   """simple docstring"""

   snake_case					       =		IFImgaImgPipeline
   snake_case					       =		TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'width', 'height'}
   snake_case					       =		TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
   snake_case					       =		PipelineTesterMixin.required_optional_params - {'latents'}

   def 		lowerCAmelCase				(    self				:			Optional[int]	):





         '''simple docstring'''





         return self._get_dummy_components()

   def 		lowerCAmelCase				(    self				:			Any   ,   __UpperCAmelCase				:			Optional[int]   ,   __UpperCAmelCase				:			str=0	):





         '''simple docstring'''





         if str(__UpperCAmelCase	).startswith("mps"	):
               _A      =			torch.manual_seed(__UpperCAmelCase	)
         else:
               _A      =			torch.Generator(device=__UpperCAmelCase	).manual_seed(__UpperCAmelCase	)

         _A      =			floats_tensor((1, 3, 32, 32)   ,   rng=random.Random(__UpperCAmelCase	)	).to(__UpperCAmelCase	)

         _A      =			{
             'prompt': 'A painting of a squirrel eating a burger',
             'image': image,
             'generator': generator,
             'num_inference_steps': 2,
             'output_type': 'numpy',
         }

         return inputs

   def 		lowerCAmelCase				(    self				:			Optional[Any]	):





         '''simple docstring'''





         self._test_save_load_optional_components()

   @unittest.skipIf(
       torch_device != "cuda" or not is_xformers_available()   ,   reason="XFormers attention is only available with CUDA and `xformers` installed"   ,   )
   def 		lowerCAmelCase				(    self				:			Any	):





         '''simple docstring'''





         self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3	)

   @unittest.skipIf(torch_device != "cuda"   ,   reason="float16 requires CUDA"	)
   def 		lowerCAmelCase				(    self				:			int	):





         '''simple docstring'''





         super().test_save_load_floataa(expected_max_diff=1E-1	)

   @unittest.skipIf(torch_device != "cuda"   ,   reason="float16 requires CUDA"	)
   def 		lowerCAmelCase				(    self				:			str	):





         '''simple docstring'''





         super().test_floataa_inference(expected_max_diff=1E-1	)

   def 		lowerCAmelCase				(    self				:			Any	):





         '''simple docstring'''





         self._test_attention_slicing_forward_pass(expected_max_diff=1E-2	)

   def 		lowerCAmelCase				(    self				:			List[str]	):





         '''simple docstring'''





         self._test_save_load_local()

   def 		lowerCAmelCase				(    self				:			Optional[Any]	):





         '''simple docstring'''





         self._test_inference_batch_single_identical(
             expected_max_diff=1E-2   ,   )













'''simple docstring'''




from urllib.error import HTTPError

from bsa import BeautifulSoup
from requests import exceptions, get

lowerCamelCase_							      =      '''https://www.wellrx.com/prescriptions/{0}/{1}/?freshSearch=true'''

def       __lowercase		(    __lowercase     ,						__lowercase ) ->		list | None:

      '''simple docstring'''


      try:
            # Has user provided both inputs?
            if not drug_name or not zip_code:
                  return None

            _A      =			BASE_URL.format(__lowercase     ,						__lowercase )
            _A      =			get(__lowercase )

            # Is the response ok?
            response.raise_for_status()

            # Scrape the data using bs4
            _A      =			BeautifulSoup(response.text     ,						"html.parser" )

            # This list will store the name and price.
            _A      =			[]

            # Fetch all the grids that contains the items.
            _A      =			soup.find_all("div"     ,						{"class": "grid-x pharmCard"} )
            if grid_list and len(__lowercase ) > 0:
                  for grid in grid_list:
                        # Get the pharmacy price.
                        _A      =			grid.find("p"     ,						{"class": "list-title"} ).text

                        # Get price of the drug.
                        _A      =			grid.find("span"     ,						{"p", "price price-large"} ).text

                        pharmacy_price_list.append(
                            {
                                "pharmacy_name": pharmacy_name,
                                "price": price,
                            } )

            return pharmacy_price_list

      except (HTTPError, exceptions.RequestException, ValueError):
            return None


if __name__ == "__main__":
    # Enter a drug name and a zip code
    lowerCamelCase_							      =      input('''Enter drug name: ''').strip()
    lowerCamelCase_							      =      input('''Enter zip code: ''').strip()

    lowerCamelCase_							      =      fetch_pharmacy_and_price_list(
        drug_name, zip_code
    )

    if pharmacy_price_list:
        print(F"""\nSearch results for {drug_name} at location {zip_code}:""")
        for pharmacy_price in pharmacy_price_list:
            lowerCamelCase_							      =      pharmacy_price['''pharmacy_name''']
            lowerCamelCase_							      =      pharmacy_price['''price''']

            print(F"""Pharmacy: {name} Price: {price}""")
    else:
        print(F"""No results found for {drug_name}""")





