

'''simple docstring'''





import tempfile
import unittest

import numpy as np
import torch

from diffusers import DiffusionPipeline
from diffusers.models.attention_processor import Attention, AttnAddedKVProcessor






class 							A_				(	unittest.TestCase      ):


     def 						UpperCAmelCase						(							self    :	Optional[int]    ,						UpperCAmelCase    :	List[Any] = False      )							->			str:
      __lowerCAmelCase:     Any     			=   1_0

      if only_cross_attention:
       __lowerCAmelCase:     Tuple     			=   1_2
      else:
       # when only cross attention is not set, the cross attention dim must be the same as the query dim
       __lowerCAmelCase:     Optional[int]     			=   query_dim

      return {
          "query_dim": query_dim,
          "cross_attention_dim": cross_attention_dim,
          "heads": 2,
          "dim_head": 4,
          "added_kv_proj_dim": 6,
          "norm_num_groups": 1,
          "only_cross_attention": only_cross_attention,
          "processor": AttnAddedKVProcessor(),
      }


     def 						UpperCAmelCase						(							self    :	List[str]    ,						UpperCAmelCase    :	Dict    ,						UpperCAmelCase    :	List[str]      )							->			str:
      __lowerCAmelCase:     Tuple     			=   2

      __lowerCAmelCase:     Any     			=   torch.rand(UpperCAmelCase    ,						UpperCAmelCase    ,						3    ,						2      )
      __lowerCAmelCase:     int     			=   torch.rand(UpperCAmelCase    ,						4    ,						UpperCAmelCase      )
      __lowerCAmelCase:     str     			=   None

      return {
          "hidden_states": hidden_states,
          "encoder_hidden_states": encoder_hidden_states,
          "attention_mask": attention_mask,
      }


     def 						UpperCAmelCase						(							self    :	Optional[int]      )							->			Tuple:
      torch.manual_seed(0      )

      __lowerCAmelCase:     List[Any]     			=   self.get_constructor_arguments(only_cross_attention=UpperCAmelCase      )
      __lowerCAmelCase:     int     			=   Attention(**UpperCAmelCase      )

      self.assertTrue(attn.to_k is not None      )
      self.assertTrue(attn.to_v is not None      )

      __lowerCAmelCase:     int     			=   self.get_forward_arguments(
          query_dim=constructor_args['query_dim']    ,						added_kv_proj_dim=constructor_args['added_kv_proj_dim']      )

      __lowerCAmelCase:     str     			=   attn(**UpperCAmelCase      )

      # only self attention

      torch.manual_seed(0      )

      __lowerCAmelCase:     Optional[Any]     			=   self.get_constructor_arguments(only_cross_attention=UpperCAmelCase      )
      __lowerCAmelCase:     int     			=   Attention(**UpperCAmelCase      )

      self.assertTrue(attn.to_k is None      )
      self.assertTrue(attn.to_v is None      )

      __lowerCAmelCase:     Union[str, Any]     			=   self.get_forward_arguments(
          query_dim=constructor_args['query_dim']    ,						added_kv_proj_dim=constructor_args['added_kv_proj_dim']      )

      __lowerCAmelCase:     Any     			=   attn(**UpperCAmelCase      )

      self.assertTrue((only_cross_attn_out != self_and_cross_attn_out).all()      )







class 							A_				(	unittest.TestCase      ):


     def 						UpperCAmelCase						(							self    :	Optional[Any]      )							->			List[str]:
      __lowerCAmelCase:     str     			=   DiffusionPipeline.from_pretrained('hf-internal-testing/tiny-stable-diffusion-pipe'    ,						safety_checker=UpperCAmelCase      )

      __lowerCAmelCase:     List[str]     			=   pipe(
          'foo'    ,						num_inference_steps=2    ,						generator=torch.Generator('cpu'      ).manual_seed(0      )    ,						output_type='np'    ,						).images

      # the initial conversion succeeds
      __lowerCAmelCase:     Optional[Any]     			=   DiffusionPipeline.from_pretrained(
          'hf-internal-testing/tiny-stable-diffusion-pipe'    ,						device_map='sequential'    ,						safety_checker=UpperCAmelCase      )

      __lowerCAmelCase:     Dict     			=   pipe(
          'foo'    ,						num_inference_steps=2    ,						generator=torch.Generator('cpu'      ).manual_seed(0      )    ,						output_type='np'    ,						).images

      with tempfile.TemporaryDirectory() as tmpdir:
       # save the converted model
       pipe.save_pretrained(UpperCAmelCase      )

       # can also load the converted weights
       __lowerCAmelCase:     Tuple     			=   DiffusionPipeline.from_pretrained(UpperCAmelCase    ,						device_map='sequential'    ,						safety_checker=UpperCAmelCase      )

      __lowerCAmelCase:     List[Any]     			=   pipe(
          'foo'    ,						num_inference_steps=2    ,						generator=torch.Generator('cpu'      ).manual_seed(0      )    ,						output_type='np'    ,						).images

      self.assertTrue(np.allclose(UpperCAmelCase    ,						UpperCAmelCase    ,						atol=1E-5      )      )
      self.assertTrue(np.allclose(UpperCAmelCase    ,						UpperCAmelCase    ,						atol=1E-5      )      )








import requests
from bsa import BeautifulSoup







def _a				( SCREAMING_SNAKE_CASE	:    int					,      SCREAMING_SNAKE_CASE	:    str	)					->					str:

 """simple docstring"""






 __lowerCAmelCase:     Tuple     			=   (
     'https://www.horoscope.com/us/horoscopes/general/'
     f'''horoscope-general-daily-{day}.aspx?sign={zodiac_sign}'''
 )
 __lowerCAmelCase:     Optional[Any]     			=   BeautifulSoup(requests.get(SCREAMING_SNAKE_CASE	).content					,      'html.parser'	)
 return soup.find('div'					,      class_='main-horoscope'	).p.text


if __name__ == "__main__":
  print('''Daily Horoscope. \n''')
  print(
      '''enter your Zodiac sign number:\n''',
      '''1. Aries\n''',
      '''2. Taurus\n''',
      '''3. Gemini\n''',
      '''4. Cancer\n''',
      '''5. Leo\n''',
      '''6. Virgo\n''',
      '''7. Libra\n''',
      '''8. Scorpio\n''',
      '''9. Sagittarius\n''',
      '''10. Capricorn\n''',
      '''11. Aquarius\n''',
      '''12. Pisces\n''',
  )
  _a	 =     int(input('''number> ''').strip())
  print('''choose some day:\n''', '''yesterday\n''', '''today\n''', '''tomorrow\n''')
  _a	 =     input('''enter the day> ''')
  _a	 =     horoscope(zodiac_sign, day)
  print(horoscope_text)





