


import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_layoutlm import LayoutLMTokenizer


UpperCAmelCase__     			=							logging.get_logger(__name__)

UpperCAmelCase__     			=							{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

UpperCAmelCase__     			=							{
    '''vocab_file''': {
        '''microsoft/layoutlm-base-uncased''': (
            '''https://huggingface.co/microsoft/layoutlm-base-uncased/resolve/main/vocab.txt'''
        ),
        '''microsoft/layoutlm-large-uncased''': (
            '''https://huggingface.co/microsoft/layoutlm-large-uncased/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''microsoft/layoutlm-base-uncased''': (
            '''https://huggingface.co/microsoft/layoutlm-base-uncased/resolve/main/tokenizer.json'''
        ),
        '''microsoft/layoutlm-large-uncased''': (
            '''https://huggingface.co/microsoft/layoutlm-large-uncased/resolve/main/tokenizer.json'''
        ),
    },
}

UpperCAmelCase__     			=							{
    '''microsoft/layoutlm-base-uncased''': 512,
    '''microsoft/layoutlm-large-uncased''': 512,
}

UpperCAmelCase__     			=							{
    '''microsoft/layoutlm-base-uncased''': {'''do_lower_case''': True},
    '''microsoft/layoutlm-large-uncased''': {'''do_lower_case''': True},
}







class    lowerCamelCase__     ( lowerCAmelCase):
     SCREAMING_SNAKE_CASE__       =    VOCAB_FILES_NAMES
     SCREAMING_SNAKE_CASE__       =    PRETRAINED_VOCAB_FILES_MAP
     SCREAMING_SNAKE_CASE__       =    PRETRAINED_INIT_CONFIGURATION
     SCREAMING_SNAKE_CASE__       =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     SCREAMING_SNAKE_CASE__       =    LayoutLMTokenizer





     def __init__(self	,  UpperCAmelCase=None	,  UpperCAmelCase=None	,  UpperCAmelCase=True	,  UpperCAmelCase="[UNK]"	,  UpperCAmelCase="[SEP]"	,  UpperCAmelCase="[PAD]"	,  UpperCAmelCase="[CLS]"	,  UpperCAmelCase="[MASK]"	,  UpperCAmelCase=True	,  UpperCAmelCase=None	,  **UpperCAmelCase	,  )  ->     List[str]:
      super().__init__(
          UpperCAmelCase	,  tokenizer_file=UpperCAmelCase	,  do_lower_case=UpperCAmelCase	,  unk_token=UpperCAmelCase	,  sep_token=UpperCAmelCase	,  pad_token=UpperCAmelCase	,  cls_token=UpperCAmelCase	,  mask_token=UpperCAmelCase	,  tokenize_chinese_chars=UpperCAmelCase	,  strip_accents=UpperCAmelCase	,  **UpperCAmelCase	,  )

      _lowercase							   =json.loads(self.backend_tokenizer.normalizer.__getstate__() )
      if (
          normalizer_state.get('''lowercase'''	,  UpperCAmelCase ) != do_lower_case
          or normalizer_state.get('''strip_accents'''	,  UpperCAmelCase ) != strip_accents
          or normalizer_state.get('''handle_chinese_chars'''	,  UpperCAmelCase ) != tokenize_chinese_chars
      ):
       _lowercase							   =getattr(UpperCAmelCase	,  normalizer_state.pop('''type''' ) )
       _lowercase							   =do_lower_case
       _lowercase							   =strip_accents
       _lowercase							   =tokenize_chinese_chars
       _lowercase							   =normalizer_class(**UpperCAmelCase )

      _lowercase							   =do_lower_case





     def   __A      (self	,  UpperCAmelCase	,  UpperCAmelCase=None )  ->     Dict:
      _lowercase							   =[self.cls_token_id] + token_ids_a + [self.sep_token_id]

      if token_ids_a:
       output += token_ids_a + [self.sep_token_id]

      return output





     def   __A      (self	,  UpperCAmelCase	,  UpperCAmelCase = None )  ->     List[int]:
      _lowercase							   =[self.sep_token_id]
      _lowercase							   =[self.cls_token_id]
      if token_ids_a is None:
       return len(cls + token_ids_a + sep ) * [0]
      return len(cls + token_ids_a + sep ) * [0] + len(token_ids_a + sep ) * [1]





     def   __A      (self	,  UpperCAmelCase	,  UpperCAmelCase = None )  ->     Tuple[str]:
      _lowercase							   =self._tokenizer.model.save(UpperCAmelCase	,  name=UpperCAmelCase )
      return tuple(UpperCAmelCase )





import requests

try:
  from django.contrib.auth import authenticate, login
  from django.shortcuts import redirect, render
except ImportError:
  UpperCAmelCase__     			=							UpperCAmelCase__     			=							UpperCAmelCase__     			=							UpperCAmelCase__     			=							print
def        UpperCAmelCase_      (							__snake_case		)  ->    List[str]:







 """simple docstring"""


 _lowercase							   ='''secretKey'''
 _lowercase							   ='''https://www.google.com/recaptcha/api/siteverify'''

 # when method is not POST, direct user to login page
 if request.method != "POST":
  return render(__snake_case  ,		'''login.html'''		)

 # from the frontend, get username, password, and client_key
 _lowercase							   =request.POST.get('''username'''		)
 _lowercase							   =request.POST.get('''password'''		)
 _lowercase							   =request.POST.get('''g-recaptcha-response'''		)

 # post recaptcha response to Google's recaptcha api
 _lowercase							   =requests.post(__snake_case  ,		data={'''secret''': secret_key, '''response''': client_key}		)
 # if the recaptcha api verified our keys
 if response.json().get('''success'''  ,		__snake_case		):
  # authenticate the user
  _lowercase							   =authenticate(__snake_case  ,		username=__snake_case  ,		password=__snake_case		)
  if user_in_database:
   login(__snake_case  ,		__snake_case		)
   return redirect('''/your-webpage'''		)
 return render(__snake_case  ,		'''login.html'''		)

