




import random
import unittest

import torch

from diffusers import IFSuperResolutionPipeline
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  lowerCamelCase_							(   _a ,     _a ,     unittest.TestCase      ):


 '''simple docstring'''







 lowercase_       					=					IFSuperResolutionPipeline
 lowercase_       					=					TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'width', 'height'}
 lowercase_       					=					TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
 lowercase_       					=					PipelineTesterMixin.required_optional_params - {'latents'}



 def    lowerCAmelCase_						(							self						:	Optional[int]		):
       return self._get_superresolution_dummy_components()



 def    lowerCAmelCase_						(							self						:	Optional[int]       ,       _lowerCAmelCase						:	List[Any]       ,       _lowerCAmelCase						:	Optional[int]=0		):
       if str(_lowerCAmelCase		).startswith('mps'		):
             SCREAMING_SNAKE_CASE_					=    torch.manual_seed(_lowerCAmelCase		)
       else:
             SCREAMING_SNAKE_CASE_					=    torch.Generator(device=_lowerCAmelCase		).manual_seed(_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_					=    floats_tensor((1, 3, 32, 32)       ,       rng=random.Random(_lowerCAmelCase		)		).to(_lowerCAmelCase		)

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

       return inputs



 @unittest.skipIf(
     torch_device != 'cuda' or not is_xformers_available()       ,       reason='XFormers attention is only available with CUDA and `xformers` installed'       ,       )
 def    lowerCAmelCase_						(							self						:	List[str]		):
       self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3		)



 def    lowerCAmelCase_						(							self						:	Optional[int]		):
       self._test_save_load_optional_components()



 @unittest.skipIf(torch_device != 'cuda'       ,       reason='float16 requires CUDA'		)
 def    lowerCAmelCase_						(							self						:	Union[str, Any]		):
       # Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
       super().test_save_load_floataa(expected_max_diff=1E-1		)



 def    lowerCAmelCase_						(							self						:	Any		):
       self._test_attention_slicing_forward_pass(expected_max_diff=1E-2		)



 def    lowerCAmelCase_						(							self						:	Dict		):
       self._test_save_load_local()




 def    lowerCAmelCase_						(							self						:	Tuple		):
       self._test_inference_batch_single_identical(
           expected_max_diff=1E-2       ,       )












import bsa
import requests

def       UpperCAmelCase_							(   __UpperCAmelCase		:			bsa.element.ResultSet							)      ->				dict[str, str]:
      return {
          "name": soup.ha.a.text,
          "genre": soup.find('span'    ,    class_='genre'							).text.strip(),
          "rating": soup.strong.text,
          "page_link": f"https://www.imdb.com{soup.a.get('href'							)}",
      }

def       UpperCAmelCase_							(   __UpperCAmelCase		:			int = 5							)      ->				tuple:
      SCREAMING_SNAKE_CASE_					=    int(float(__UpperCAmelCase							)							)
      if num_movies < 1:
            return ()
      SCREAMING_SNAKE_CASE_					=    (
          'https://www.imdb.com/search/title?title_type='
          f"feature&sort=num_votes,desc&count={num_movies}"
      )
      SCREAMING_SNAKE_CASE_					=    bsa.BeautifulSoup(requests.get(__UpperCAmelCase							).content    ,    'html.parser'							)
      return tuple(
          get_movie_data_from_soup(__UpperCAmelCase							)
          for movie in source.find_all('div'    ,    class_='lister-item mode-advanced'							)							)


if __name__ == "__main__":
   import json

   lowerCamelCase__				:     int			       =							int(input('How many movies would you like to see? '))
   print(
       ', '.join(
           json.dumps(movie, indent=4) for movie in get_imdb_top_movies(num_movies)
       )
   )