code: 
  
  """simple docstring"""
  import argparse
  
  import torch
  
  from transformers import ChineseCLIPConfig, ChineseCLIPModel
  
  
  
  
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase ,  lowerCAmelCase						)  ->   str:
        UpperCAmelCase__ :       Optional[int]						=						pt_weights[F"""{prefix}.in_proj_weight"""].chunk(3 ,  dim=0						)
        UpperCAmelCase__ :       Optional[Any]						=						pt_weights[F"""{prefix}.in_proj_bias"""].chunk(3 ,  dim=0						)
  
        UpperCAmelCase__ :       str						=						pt_weights[F"""{prefix}.out_proj.weight"""]
        UpperCAmelCase__ :       Optional[Any]						=						pt_weights[F"""{prefix}.out_proj.bias"""]
  
        UpperCAmelCase__ :       Union[str, Any]						=						q_proj
        UpperCAmelCase__ :       List[str]						=						q_proj_bias
  
        UpperCAmelCase__ :       List[str]						=						k_proj
        UpperCAmelCase__ :       Dict						=						k_proj_bias
  
        UpperCAmelCase__ :       int						=						v_proj
        UpperCAmelCase__ :       str						=						v_proj_bias
  
        UpperCAmelCase__ :       str						=						out_proj_weights
        UpperCAmelCase__ :       str						=						out_proj_bias
  
  
  
  
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase ,  lowerCAmelCase						)  ->   str:
        copy_linear(hf_mlp.fca ,  lowerCAmelCase ,  F"""{prefix}.c_fc"""						)
        copy_linear(hf_mlp.fca ,  lowerCAmelCase ,  F"""{prefix}.c_proj"""						)
  
  
  
  
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase ,  lowerCAmelCase						)  ->   Optional[Any]:
        UpperCAmelCase__ :       Optional[Any]						=						pt_weights[F"""{prefix}.weight"""].data
        UpperCAmelCase__ :       Union[str, Any]						=						pt_weights[F"""{prefix}.bias"""].data
  
  
  
  
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase ,  lowerCAmelCase						)  ->   Union[str, Any]:
        # copy layer norms
        copy_linear(hf_layer.layer_norma ,  lowerCAmelCase ,  F"""{prefix}.ln_1"""						)
        copy_linear(hf_layer.layer_norma ,  lowerCAmelCase ,  F"""{prefix}.ln_2"""						)
  
        # copy MLP
        copy_mlp(hf_layer.mlp ,  lowerCAmelCase ,  F"""{prefix}.mlp"""						)
  
        # copy attn
        copy_attn_layer(hf_layer.self_attn ,  lowerCAmelCase ,  F"""{prefix}.attn"""						)
  
  
  
  
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase ,  lowerCAmelCase						)  ->   Dict:
        for layer_id, hf_layer in enumerate(lowerCAmelCase						):
              copy_layer(lowerCAmelCase ,  lowerCAmelCase ,  F"""{prefix}.{layer_id}"""						)
  
  
  
  
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase						)  ->   Union[str, Any]:
        # copy projection
        UpperCAmelCase__ :       Tuple						=						pt_weights["""text_projection"""].data.T
  
        # copy text encoder
        for name, param in hf_model.text_model.named_parameters():
              UpperCAmelCase__ :       str						=						pt_weights[F"""bert.{name}"""].data
  
  
  
  
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase						)  ->   Dict:
        # copy projection
        UpperCAmelCase__ :       str						=						pt_weights["""visual.proj"""].data.T
  
        # copy layer norms
        copy_linear(hf_model.vision_model.pre_layrnorm ,  lowerCAmelCase ,  """visual.ln_pre"""						)
        copy_linear(hf_model.vision_model.post_layernorm ,  lowerCAmelCase ,  """visual.ln_post"""						)
  
        # copy embeddings
        UpperCAmelCase__ :       Union[str, Any]						=						pt_weights["""visual.conv1.weight"""].data
        UpperCAmelCase__ :       Optional[int]						=						pt_weights["""visual.class_embedding"""].data
        UpperCAmelCase__ :       List[str]						=						pt_weights["""visual.positional_embedding"""].data
  
        # copy encoder
        copy_layers(hf_model.vision_model.encoder.layers ,  lowerCAmelCase ,  """visual.transformer.resblocks"""						)
  
  
  
  
  @torch.no_grad()
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase ,  lowerCAmelCase=None						)  ->   Optional[Any]:
        assert config_path is not None, "Please specify the ChineseCLIP model config of the corresponding model size."
        UpperCAmelCase__ :       Dict						=						ChineseCLIPConfig.from_pretrained(lowerCAmelCase						)
  
        UpperCAmelCase__ :       int						=						ChineseCLIPModel(lowerCAmelCase						).eval()
  
        UpperCAmelCase__ :       Union[str, Any]						=						torch.load(lowerCAmelCase ,  map_location="""cpu"""						)["""state_dict"""]
        UpperCAmelCase__ :       Optional[Any]						=						{(name[7:] if name.startswith("""module."""						) else name): value for name, value in pt_weights.items()}
  
        copy_text_model_and_projection(lowerCAmelCase ,  lowerCAmelCase						)
        copy_vision_model_and_projection(lowerCAmelCase ,  lowerCAmelCase						)
        UpperCAmelCase__ :       Tuple						=						pt_weights["""logit_scale"""].data
  
        hf_model.save_pretrained(lowerCAmelCase						)
  
  
  if __name__ == "__main__":
      _A						=     argparse.ArgumentParser()
      parser.add_argument(
          """--pytorch_dump_folder_path""",
          default=None,
          type=str,
          help="""Path to the output folder storing converted hf PyTorch model.""",
      )
      parser.add_argument(
          """--checkpoint_path""", default=None, type=str, help="""Path to original github format ChineseCLIP checkpoint."""
      )
      parser.add_argument(
          """--config_path""", default=None, required=True, type=str, help="""Path to hf config.json of model to convert."""
      )
      _A						=     parser.parse_args()
  
      convert_chinese_clip_checkpoint(args.checkpoint_path, args.pytorch_dump_folder_path, args.config_path)
      print("""The conversion is finished!""")
  
  
style_context: 
  
  """simple docstring"""
  import requests
  
  try:
      from django.contrib.auth import authenticate, login
      from django.shortcuts import redirect, render
  except ImportError:
      _A						=     _A						=     _A						=     _A						=     print
  
  
  
  
  def 				a__	(	lowerCAmelCase						)  ->   str:
        # Enter your recaptcha secret key here
        UpperCAmelCase__ :       int						=						"""secretKey"""
        UpperCAmelCase__ :       Any						=						"""https://www.google.com/recaptcha/api/siteverify"""
  
        # when method is not POST, direct user to login page
        if request.method != "POST":
              return render(lowerCAmelCase ,  """login.html"""						)
  
        # from the frontend, get username, password, and client_key
        UpperCAmelCase__ :       List[Any]						=						request.POST.get("""username"""						)
        UpperCAmelCase__ :       Optional[Any]						=						request.POST.get("""password"""						)
        UpperCAmelCase__ :       List[str]						=						request.POST.get("""g-recaptcha-response"""						)
  
        # post recaptcha response to Google's recaptcha api
        UpperCAmelCase__ :       Any						=						requests.post(lowerCAmelCase ,  data={"""secret""": secret_key, """response""": client_key}						)
        # if the recaptcha api verified our keys
        if response.json().get("""success""" ,  lowerCAmelCase						):
              # authenticate the user
              UpperCAmelCase__ :       List[str]						=						authenticate(lowerCAmelCase ,  username=lowerCAmelCase ,  password=lowerCAmelCase						)
              if user_in_database:
                    login(lowerCAmelCase ,  lowerCAmelCase						)
                    return redirect("""/your-webpage"""						)
        return render(lowerCAmelCase ,  """login.html"""						)
  
  