

import argparse

import torch
from clip import load

from transformers import CLIPConfig, CLIPModel







def _a				( SCREAMING_SNAKE_CASE	:    List[str]					,      SCREAMING_SNAKE_CASE	:    Any	)					->					List[Any]:

 """simple docstring"""






 __lowerCAmelCase			,							__lowerCAmelCase			,							__lowerCAmelCase:     Tuple     			=   pt_attn_layer.in_proj_weight.chunk(3					,      dim=0	)
 __lowerCAmelCase			,							__lowerCAmelCase			,							__lowerCAmelCase:     int     			=   pt_attn_layer.in_proj_bias.chunk(3					,      dim=0	)

 __lowerCAmelCase:     Any     			=   pt_attn_layer.out_proj.weight
 __lowerCAmelCase:     int     			=   pt_attn_layer.out_proj.bias

 __lowerCAmelCase:     Dict     			=   q_proj
 __lowerCAmelCase:     Any     			=   q_proj_bias

 __lowerCAmelCase:     Union[str, Any]     			=   k_proj
 __lowerCAmelCase:     Optional[Any]     			=   k_proj_bias

 __lowerCAmelCase:     Dict     			=   v_proj
 __lowerCAmelCase:     int     			=   v_proj_bias

 __lowerCAmelCase:     Tuple     			=   out_proj_weights
 __lowerCAmelCase:     str     			=   out_proj_bias







def _a				( SCREAMING_SNAKE_CASE	:    List[Any]					,      SCREAMING_SNAKE_CASE	:    int	)					->					str:

 """simple docstring"""






 copy_linear(hf_mlp.fca					,      pt_mlp.c_fc	)
 copy_linear(hf_mlp.fca					,      pt_mlp.c_proj	)







def _a				( SCREAMING_SNAKE_CASE	:    str					,      SCREAMING_SNAKE_CASE	:    str	)					->					Union[str, Any]:

 """simple docstring"""






 __lowerCAmelCase:     List[str]     			=   pt_linear.weight
 __lowerCAmelCase:     Any     			=   pt_linear.bias







def _a				( SCREAMING_SNAKE_CASE	:    Any					,      SCREAMING_SNAKE_CASE	:    List[str]	)					->					List[Any]:

 """simple docstring"""






 copy_linear(hf_layer.layer_norma					,      pt_layer.ln_a	)
 copy_linear(hf_layer.layer_norma					,      pt_layer.ln_a	)

 # copy MLP
 copy_mlp(hf_layer.mlp					,      pt_layer.mlp	)

 # copy attn
 copy_attn_layer(hf_layer.self_attn					,      pt_layer.attn	)







def _a				( SCREAMING_SNAKE_CASE	:    Dict					,      SCREAMING_SNAKE_CASE	:    Any	)					->					Dict:

 """simple docstring"""






 for hf_layer, pt_layer in zip(SCREAMING_SNAKE_CASE					,      SCREAMING_SNAKE_CASE	):
  copy_layer(SCREAMING_SNAKE_CASE					,      SCREAMING_SNAKE_CASE	)







def _a				( SCREAMING_SNAKE_CASE	:    int					,      SCREAMING_SNAKE_CASE	:    Any	)					->					Optional[int]:

 """simple docstring"""






 __lowerCAmelCase:     Optional[Any]     			=   pt_model.token_embedding.weight
 __lowerCAmelCase:     List[str]     			=   pt_model.positional_embedding

 # copy layer norm
 copy_linear(hf_encoder.final_layer_norm					,      pt_model.ln_final	)

 # copy hidden layers
 copy_layers(hf_encoder.encoder.layers					,      pt_model.transformer.resblocks	)







def _a				( SCREAMING_SNAKE_CASE	:    int					,      SCREAMING_SNAKE_CASE	:    Dict	)					->					Any:

 """simple docstring"""






 __lowerCAmelCase:     Any     			=   pt_model.text_projection.data.T

 # copy text encoder
 copy_encoder(hf_model.text_model					,      SCREAMING_SNAKE_CASE	)







def _a				( SCREAMING_SNAKE_CASE	:    List[str]					,      SCREAMING_SNAKE_CASE	:    Optional[int]	)					->					Any:

 """simple docstring"""






 __lowerCAmelCase:     int     			=   pt_model.visual.proj.data.T

 # copy layer norms
 copy_linear(hf_model.vision_model.pre_layrnorm					,      pt_model.visual.ln_pre	)
 copy_linear(hf_model.vision_model.post_layernorm					,      pt_model.visual.ln_post	)

 # copy embeds
 __lowerCAmelCase:     int     			=   pt_model.visual.conva.weight.data
 __lowerCAmelCase:     int     			=   pt_model.visual.class_embedding
 __lowerCAmelCase:     Any     			=   pt_model.visual.positional_embedding.data

 # copy encoder
 copy_layers(hf_model.vision_model.encoder.layers					,      pt_model.visual.transformer.resblocks	)







@torch.no_grad()
def _a				( SCREAMING_SNAKE_CASE	:    Dict					,      SCREAMING_SNAKE_CASE	:    str					,      SCREAMING_SNAKE_CASE	:    Union[str, Any]=None	)					->					List[str]:

 """simple docstring"""






 if config_path is not None:
  __lowerCAmelCase:     Any     			=   CLIPConfig.from_pretrained(SCREAMING_SNAKE_CASE	)
 else:
  __lowerCAmelCase:     Optional[Any]     			=   CLIPConfig(projection_dim=5_12					,      text_config={}					,      vision_config={}	)

 __lowerCAmelCase:     List[Any]     			=   CLIPModel(SCREAMING_SNAKE_CASE	).eval()

 __lowerCAmelCase			,							__lowerCAmelCase:     Dict     			=   load(SCREAMING_SNAKE_CASE					,      device='cpu'					,      jit=SCREAMING_SNAKE_CASE	)
 __lowerCAmelCase:     int     			=   pt_model.eval()

 copy_text_model_and_projection(SCREAMING_SNAKE_CASE					,      SCREAMING_SNAKE_CASE	)
 copy_vison_model_and_projection(SCREAMING_SNAKE_CASE					,      SCREAMING_SNAKE_CASE	)
 __lowerCAmelCase:     Union[str, Any]     			=   pt_model.logit_scale

 __lowerCAmelCase:     Union[str, Any]     			=   torch.arange(0					,      77	).unsqueeze(0	)
 __lowerCAmelCase:     str     			=   torch.randn(1					,      3					,      2_24					,      2_24	)

 __lowerCAmelCase:     Optional[Any]     			=   hf_model(input_ids=SCREAMING_SNAKE_CASE					,      pixel_values=SCREAMING_SNAKE_CASE					,      return_dict=SCREAMING_SNAKE_CASE	)
 __lowerCAmelCase:     int     			=   hf_outputs.logits_per_image
 __lowerCAmelCase:     List[str]     			=   hf_outputs.logits_per_text
 __lowerCAmelCase			,							__lowerCAmelCase:     int     			=   pt_model(SCREAMING_SNAKE_CASE					,      SCREAMING_SNAKE_CASE	)

 assert torch.allclose(SCREAMING_SNAKE_CASE					,      SCREAMING_SNAKE_CASE					,      atol=1E-3	)
 assert torch.allclose(SCREAMING_SNAKE_CASE					,      SCREAMING_SNAKE_CASE					,      atol=1E-3	)

 hf_model.save_pretrained(SCREAMING_SNAKE_CASE	)


if __name__ == "__main__":
  _a	 =     argparse.ArgumentParser()
  parser.add_argument('''--pytorch_dump_folder_path''', default=None, type=str, help='''Path to the output PyTorch model.''')
  parser.add_argument('''--checkpoint_path''', default=None, type=str, help='''Path to fairseq checkpoint''')
  parser.add_argument('''--config_path''', default=None, type=str, help='''Path to hf config.json of model to convert''')
  _a	 =     parser.parse_args()

  convert_clip_checkpoint(args.checkpoint_path, args.pytorch_dump_folder_path, args.config_path)








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)





