





import requests

try:
      from django.contrib.auth import authenticate, login
      from django.shortcuts import redirect, render
except ImportError:
      lowerCAmelCase_        =			lowerCAmelCase_        =			lowerCAmelCase_        =			lowerCAmelCase_        =			print


def 			lowerCamelCase_		(					lowerCAmelCase:		Optional[int] )->						List[Any]:
  # Enter your recaptcha secret key here
  _snake_case      : Optional[int]														=		'secretKey'
  _snake_case      : str														=		'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
  _snake_case      : Any														=		request.POST.get('username' )
  _snake_case      : Dict														=		request.POST.get('password' )
  _snake_case      : List[Any]														=		request.POST.get('g-recaptcha-response' )

  # post recaptcha response to Google's recaptcha api
  _snake_case      : 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
    _snake_case      : Dict														=		authenticate(lowerCAmelCase			,							username=lowerCAmelCase			,							password=lowerCAmelCase )
    if user_in_database:
      login(lowerCAmelCase			,							lowerCAmelCase )
      return redirect('/your-webpage' )
  return render(lowerCAmelCase			,							'login.html' )











import argparse

import torch

from transformers import ImageGPTConfig, ImageGPTForCausalLM, load_tf_weights_in_imagegpt
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()


def 			lowerCamelCase_		(					lowerCAmelCase:		Optional[Any]			,							lowerCAmelCase:		Tuple			,							lowerCAmelCase:		List[Any] )->						Dict:
  # Construct configuration depending on size
  _snake_case      : Tuple														=		{'small': (5_12, 8, 24), 'medium': (10_24, 8, 36), 'large': (15_36, 16, 48)}
  _snake_case							,    _snake_case							,    _snake_case      : Optional[Any]														=		MODELS[model_size]  # set model hyperparameters
  _snake_case      : Union[str, Any]														=		ImageGPTConfig(n_embd=lowerCAmelCase			,							n_layer=lowerCAmelCase			,							n_head=lowerCAmelCase )
  _snake_case      : int														=		ImageGPTForCausalLM(lowerCAmelCase )

  # Load weights from numpy
  load_tf_weights_in_imagegpt(lowerCAmelCase			,							lowerCAmelCase			,							lowerCAmelCase )

  # Save pytorch-model
  _snake_case      : List[Any]														=		pytorch_dump_folder_path + '/' + WEIGHTS_NAME
  _snake_case      : Optional[Any]														=		pytorch_dump_folder_path + '/' + CONFIG_NAME
  print(F"""Save PyTorch model to {pytorch_weights_dump_path}""" )
  torch.save(model.state_dict()			,							lowerCAmelCase )
  print(F"""Save configuration file to {pytorch_config_dump_path}""" )
  with open(lowerCAmelCase			,							'w'			,							encoding='utf-8' ) as f:
    f.write(config.to_json_string() )


if __name__ == "__main__":
      lowerCAmelCase_        =			argparse.ArgumentParser()
      # Required parameters
      parser.add_argument(
          """--imagegpt_checkpoint_path""",
          default=None,
          type=str,
          required=True,
          help="""Path to the TensorFlow checkpoint path.""",
      )
      parser.add_argument(
          """--model_size""",
          default=None,
          type=str,
          required=True,
          help="""Size of the model (can be either 'small', 'medium' or 'large').""",
      )
      parser.add_argument(
          """--pytorch_dump_folder_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
      )
      lowerCAmelCase_        =			parser.parse_args()
      convert_imagegpt_checkpoint_to_pytorch(
          args.imagegpt_checkpoint_path, args.model_size, args.pytorch_dump_folder_path
      )




