import copy
import unittest

from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import (
        MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
        MODEL_FOR_QUESTION_ANSWERING_MAPPING,
        MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
        MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
        LayoutLMvaConfig,
        LayoutLMvaForQuestionAnswering,
        LayoutLMvaForSequenceClassification,
        LayoutLMvaForTokenClassification,
        LayoutLMvaModel,
    )
    from transformers.models.layoutlmva.modeling_layoutlmva import LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
    from PIL import Image

    from transformers import LayoutLMvaImageProcessor



class  SCREAMING_SNAKE_CASE_ :
  '''simple docstring'''


  def __init__(				self    :					Tuple      ,	SCREAMING_SNAKE_CASE__    :					Optional[Any]      ,	SCREAMING_SNAKE_CASE__    :					Any=2      ,	SCREAMING_SNAKE_CASE__    :					Optional[Any]=3      ,	SCREAMING_SNAKE_CASE__    :					List[str]=4      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=2      ,	SCREAMING_SNAKE_CASE__    :					Any=7      ,	SCREAMING_SNAKE_CASE__    :					Dict=True      ,	SCREAMING_SNAKE_CASE__    :					Dict=True      ,	SCREAMING_SNAKE_CASE__    :					str=True      ,	SCREAMING_SNAKE_CASE__    :					List[str]=True      ,	SCREAMING_SNAKE_CASE__    :					Tuple=99      ,	SCREAMING_SNAKE_CASE__    :					Optional[Any]=36      ,	SCREAMING_SNAKE_CASE__    :					List[str]=3      ,	SCREAMING_SNAKE_CASE__    :					str=4      ,	SCREAMING_SNAKE_CASE__    :					int=37      ,	SCREAMING_SNAKE_CASE__    :					int="gelu"      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=0.1      ,	SCREAMING_SNAKE_CASE__    :					Dict=0.1      ,	SCREAMING_SNAKE_CASE__    :					List[str]=5_12      ,	SCREAMING_SNAKE_CASE__    :					str=16      ,	SCREAMING_SNAKE_CASE__    :					int=2      ,	SCREAMING_SNAKE_CASE__    :					List[str]=0.0_2      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]=6      ,	SCREAMING_SNAKE_CASE__    :					Any=6      ,	SCREAMING_SNAKE_CASE__    :					str=3      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]=4      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=None      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]=10_00      ,	)    ->				Optional[Any]:
         A						:     List[str]         =parent
         A						:     List[Any]         =batch_size
         A						:     int         =num_channels
         A						:     str         =image_size
         A						:     str         =patch_size
         A						:     str         =text_seq_length
         A						:     Tuple         =is_training
         A						:     List[str]         =use_input_mask
         A						:     Any         =use_token_type_ids
         A						:     Any         =use_labels
         A						:     Optional[int]         =vocab_size
         A						:     Any         =hidden_size
         A						:     Union[str, Any]         =num_hidden_layers
         A						:     Optional[Any]         =num_attention_heads
         A						:     Tuple         =intermediate_size
         A						:     int         =hidden_act
         A						:     Any         =hidden_dropout_prob
         A						:     Any         =attention_probs_dropout_prob
         A						:     Tuple         =max_position_embeddings
         A						:     int         =type_vocab_size
         A						:     Any         =type_sequence_label_size
         A						:     Any         =initializer_range
         A						:     str         =coordinate_size
         A						:     Tuple         =shape_size
         A						:     int         =num_labels
         A						:     Tuple         =num_choices
         A						:     str         =scope
         A						:     Optional[int]         =range_bbox

         # LayoutLMv3's sequence length equals the number of text tokens + number of patches + 1 (we add 1 for the CLS token)
         A						:     str         =text_seq_length
         A						:     Optional[int]         =(image_size // patch_size) ** 2 + 1
         A						:     List[str]         =self.text_seq_length + self.image_seq_length







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Dict     )    ->				Optional[Any]:
         A						:     Tuple         =ids_tensor([self.batch_size, self.text_seq_length]      ,	self.vocab_size     )

         A						:     int         =ids_tensor([self.batch_size, self.text_seq_length, 4]      ,	self.range_bbox     )
         # Ensure that bbox is legal
         for i in range(bbox.shape[0]     ):
                for j in range(bbox.shape[1]     ):
                       if bbox[i, j, 3] < bbox[i, j, 1]:
                              A						:     List[Any]         =bbox[i, j, 3]
                              A						:     List[str]         =bbox[i, j, 1]
                              A						:     List[str]         =t
                       if bbox[i, j, 2] < bbox[i, j, 0]:
                              A						:     Optional[Any]         =bbox[i, j, 2]
                              A						:     Optional[int]         =bbox[i, j, 0]
                              A						:     Dict         =t

         A						:     str         =floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]     )

         A						:     Tuple         =None
         if self.use_input_mask:
                A						:     str         =random_attention_mask([self.batch_size, self.text_seq_length]     )

         A						:     List[str]         =None
         if self.use_token_type_ids:
                A						:     Tuple         =ids_tensor([self.batch_size, self.text_seq_length]      ,	self.type_vocab_size     )

         A						:     List[Any]         =None
         A						:     Optional[int]         =None
         if self.use_labels:
                A						:     int         =ids_tensor([self.batch_size]      ,	self.type_sequence_label_size     )
                A						:     Optional[int]         =ids_tensor([self.batch_size, self.text_seq_length]      ,	self.num_labels     )

         A						:     Any         =LayoutLMvaConfig(
             vocab_size=self.vocab_size      ,	hidden_size=self.hidden_size      ,	num_hidden_layers=self.num_hidden_layers      ,	num_attention_heads=self.num_attention_heads      ,	intermediate_size=self.intermediate_size      ,	hidden_act=self.hidden_act      ,	hidden_dropout_prob=self.hidden_dropout_prob      ,	attention_probs_dropout_prob=self.attention_probs_dropout_prob      ,	max_position_embeddings=self.max_position_embeddings      ,	type_vocab_size=self.type_vocab_size      ,	initializer_range=self.initializer_range      ,	coordinate_size=self.coordinate_size      ,	shape_size=self.shape_size      ,	input_size=self.image_size      ,	patch_size=self.patch_size      ,	)

         return config, input_ids, bbox, pixel_values, token_type_ids, input_mask, sequence_labels, token_labels







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Optional[Any]      ,	SCREAMING_SNAKE_CASE__    :					List[str]      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]      ,	SCREAMING_SNAKE_CASE__    :					Dict      ,	SCREAMING_SNAKE_CASE__    :					List[str]      ,	SCREAMING_SNAKE_CASE__    :					int      ,	SCREAMING_SNAKE_CASE__    :					List[Any]      ,	SCREAMING_SNAKE_CASE__    :					List[Any]      ,	SCREAMING_SNAKE_CASE__    :					int     )    ->				int:
         A						:     Union[str, Any]         =LayoutLMvaModel(config=SCREAMING_SNAKE_CASE__     )
         model.to(SCREAMING_SNAKE_CASE__     )
         model.eval()

         # text + image
         A						:     int         =model(SCREAMING_SNAKE_CASE__      ,	pixel_values=SCREAMING_SNAKE_CASE__     )
         A						:     Union[str, Any]         =model(
             SCREAMING_SNAKE_CASE__      ,	bbox=SCREAMING_SNAKE_CASE__      ,	pixel_values=SCREAMING_SNAKE_CASE__      ,	attention_mask=SCREAMING_SNAKE_CASE__      ,	token_type_ids=SCREAMING_SNAKE_CASE__     )
         A						:     List[Any]         =model(SCREAMING_SNAKE_CASE__      ,	bbox=SCREAMING_SNAKE_CASE__      ,	pixel_values=SCREAMING_SNAKE_CASE__      ,	token_type_ids=SCREAMING_SNAKE_CASE__     )
         A						:     Optional[Any]         =model(SCREAMING_SNAKE_CASE__      ,	bbox=SCREAMING_SNAKE_CASE__      ,	pixel_values=SCREAMING_SNAKE_CASE__     )

         self.parent.assertEqual(result.last_hidden_state.shape      ,	(self.batch_size, self.seq_length, self.hidden_size)     )

         # text only
         A						:     Dict         =model(SCREAMING_SNAKE_CASE__     )
         self.parent.assertEqual(
             result.last_hidden_state.shape      ,	(self.batch_size, self.text_seq_length, self.hidden_size)     )

         # image only
         A						:     List[str]         =model(pixel_values=SCREAMING_SNAKE_CASE__     )
         self.parent.assertEqual(
             result.last_hidden_state.shape      ,	(self.batch_size, self.image_seq_length, self.hidden_size)     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Dict      ,	SCREAMING_SNAKE_CASE__    :					Dict      ,	SCREAMING_SNAKE_CASE__    :					str      ,	SCREAMING_SNAKE_CASE__    :					int      ,	SCREAMING_SNAKE_CASE__    :					Any      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]      ,	SCREAMING_SNAKE_CASE__    :					Tuple      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]      ,	SCREAMING_SNAKE_CASE__    :					Any     )    ->				Tuple:
         A						:     Union[str, Any]         =self.num_labels
         A						:     Optional[int]         =LayoutLMvaForSequenceClassification(SCREAMING_SNAKE_CASE__     )
         model.to(SCREAMING_SNAKE_CASE__     )
         model.eval()
         A						:     Optional[int]         =model(
             SCREAMING_SNAKE_CASE__      ,	bbox=SCREAMING_SNAKE_CASE__      ,	pixel_values=SCREAMING_SNAKE_CASE__      ,	attention_mask=SCREAMING_SNAKE_CASE__      ,	token_type_ids=SCREAMING_SNAKE_CASE__      ,	labels=SCREAMING_SNAKE_CASE__      ,	)
         self.parent.assertEqual(result.logits.shape      ,	(self.batch_size, self.num_labels)     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Union[str, Any]      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]      ,	SCREAMING_SNAKE_CASE__    :					int      ,	SCREAMING_SNAKE_CASE__    :					Any      ,	SCREAMING_SNAKE_CASE__    :					Dict      ,	SCREAMING_SNAKE_CASE__    :					Tuple      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]      ,	SCREAMING_SNAKE_CASE__    :					int      ,	SCREAMING_SNAKE_CASE__    :					Dict     )    ->				Optional[Any]:
         A						:     Optional[Any]         =self.num_labels
         A						:     Dict         =LayoutLMvaForTokenClassification(config=SCREAMING_SNAKE_CASE__     )
         model.to(SCREAMING_SNAKE_CASE__     )
         model.eval()
         A						:     Tuple         =model(
             SCREAMING_SNAKE_CASE__      ,	bbox=SCREAMING_SNAKE_CASE__      ,	pixel_values=SCREAMING_SNAKE_CASE__      ,	attention_mask=SCREAMING_SNAKE_CASE__      ,	token_type_ids=SCREAMING_SNAKE_CASE__      ,	labels=SCREAMING_SNAKE_CASE__      ,	)
         self.parent.assertEqual(result.logits.shape      ,	(self.batch_size, self.text_seq_length, self.num_labels)     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Dict      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]      ,	SCREAMING_SNAKE_CASE__    :					Dict      ,	SCREAMING_SNAKE_CASE__    :					Any      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]      ,	SCREAMING_SNAKE_CASE__    :					str      ,	SCREAMING_SNAKE_CASE__    :					Tuple      ,	SCREAMING_SNAKE_CASE__    :					str      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]     )    ->				int:
         A						:     List[str]         =LayoutLMvaForQuestionAnswering(config=SCREAMING_SNAKE_CASE__     )
         model.to(SCREAMING_SNAKE_CASE__     )
         model.eval()
         A						:     str         =model(
             SCREAMING_SNAKE_CASE__      ,	bbox=SCREAMING_SNAKE_CASE__      ,	pixel_values=SCREAMING_SNAKE_CASE__      ,	attention_mask=SCREAMING_SNAKE_CASE__      ,	token_type_ids=SCREAMING_SNAKE_CASE__      ,	start_positions=SCREAMING_SNAKE_CASE__      ,	end_positions=SCREAMING_SNAKE_CASE__      ,	)
         self.parent.assertEqual(result.start_logits.shape      ,	(self.batch_size, self.seq_length)     )
         self.parent.assertEqual(result.end_logits.shape      ,	(self.batch_size, self.seq_length)     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Optional[int]     )    ->				Tuple:
         A						:     Tuple         =self.prepare_config_and_inputs()
         (
             (
             A
         )  ,  (
             A
         )  ,  (
             A
         )  ,  (
             A
         )  ,  (
             A
         )  ,  (
             A
         )  ,  (
             A
         )  ,  (
             A
         )  ,  
         )						:     Any         =config_and_inputs
         A						:     Tuple         ={
             'input_ids': input_ids,
             'bbox': bbox,
             'pixel_values': pixel_values,
             'token_type_ids': token_type_ids,
             'attention_mask': input_mask,
         }
         return config, inputs_dict







@require_torch
class  SCREAMING_SNAKE_CASE_ (					lowerCAmelCase_   ,						lowerCAmelCase_   ,						unittest.TestCase			):
  '''simple docstring'''


  lowercase		:     Dict            =				False
  lowercase		:     str            =				False
  lowercase		:     Optional[int]            =				False

  lowercase		:     Optional[int]            =				(
      (
          LayoutLMvaModel,
          LayoutLMvaForSequenceClassification,
          LayoutLMvaForTokenClassification,
          LayoutLMvaForQuestionAnswering,
      )
      if is_torch_available()
      else ()
  )
  lowercase		:     Optional[int]            =				(
      {"document-question-answering": LayoutLMvaForQuestionAnswering, "feature-extraction": LayoutLMvaModel}
      if is_torch_available()
      else {}
  )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Optional[Any]      ,	SCREAMING_SNAKE_CASE__    :					List[str]      ,	SCREAMING_SNAKE_CASE__    :					Optional[Any]      ,	SCREAMING_SNAKE_CASE__    :					int      ,	SCREAMING_SNAKE_CASE__    :					str      ,	SCREAMING_SNAKE_CASE__    :					Optional[int]     )    ->				Optional[int]:
         # `DocumentQuestionAnsweringPipeline` is expected to work with this model, but it combines the text and visual
         # embedding along the sequence dimension (dim 1), which causes an error during post-processing as `p_mask` has
         # the sequence dimension of the text embedding only.
         # (see the line `embedding_output = torch.cat([embedding_output, visual_embeddings], dim=1)`)
         return True







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Any     )    ->				List[Any]:
         A						:     Any         =LayoutLMvaModelTester(self     )
         A						:     Optional[Any]         =ConfigTester(self      ,	config_class=SCREAMING_SNAKE_CASE__      ,	hidden_size=37     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Optional[Any]      ,	SCREAMING_SNAKE_CASE__    :					Union[str, Any]      ,	SCREAMING_SNAKE_CASE__    :					Any      ,	SCREAMING_SNAKE_CASE__    :					List[Any]=False     )    ->				str:
         A						:     List[str]         =copy.deepcopy(SCREAMING_SNAKE_CASE__     )
         if model_class in get_values(SCREAMING_SNAKE_CASE__     ):
                A						:     Any         ={
                    k: v.unsqueeze(1     ).expand(-1      ,	self.model_tester.num_choices      ,	-1     ).contiguous()
                    if isinstance(SCREAMING_SNAKE_CASE__      ,	torch.Tensor     ) and v.ndim > 1
                    else v
                    for k, v in inputs_dict.items()
                }
         if return_labels:
                if model_class in get_values(SCREAMING_SNAKE_CASE__     ):
                       A						:     int         =torch.ones(self.model_tester.batch_size      ,	dtype=torch.long      ,	device=SCREAMING_SNAKE_CASE__     )
                elif model_class in get_values(SCREAMING_SNAKE_CASE__     ):
                       A						:     Optional[int]         =torch.zeros(
                           self.model_tester.batch_size      ,	dtype=torch.long      ,	device=SCREAMING_SNAKE_CASE__     )
                       A						:     Tuple         =torch.zeros(
                           self.model_tester.batch_size      ,	dtype=torch.long      ,	device=SCREAMING_SNAKE_CASE__     )
                elif model_class in [
                    *get_values(SCREAMING_SNAKE_CASE__     ),
                ]:
                       A						:     List[Any]         =torch.zeros(
                           self.model_tester.batch_size      ,	dtype=torch.long      ,	device=SCREAMING_SNAKE_CASE__     )
                elif model_class in [
                    *get_values(SCREAMING_SNAKE_CASE__     ),
                ]:
                       A						:     List[str]         =torch.zeros(
                           (self.model_tester.batch_size, self.model_tester.text_seq_length)      ,	dtype=torch.long      ,	device=SCREAMING_SNAKE_CASE__      ,	)

         return inputs_dict







  def 		SCREAMING_SNAKE_CASE_		(				self    :					List[str]     )    ->				Optional[Any]:
         self.config_tester.run_common_tests()







  def 		SCREAMING_SNAKE_CASE_		(				self    :					int     )    ->				Union[str, Any]:
         A						:     Tuple         =self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					str     )    ->				List[Any]:
         A						:     Optional[Any]         =self.model_tester.prepare_config_and_inputs()
         for type in ["absolute", "relative_key", "relative_key_query"]:
                A						:     int         =type
                self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Optional[int]     )    ->				str:
         A						:     int         =self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE__     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Any     )    ->				str:
         A						:     Any         =self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE__     )







  def 		SCREAMING_SNAKE_CASE_		(				self    :					Dict     )    ->				List[str]:
         A						:     int         =self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE__     )







  @slow
  def 		SCREAMING_SNAKE_CASE_		(				self    :					List[str]     )    ->				Union[str, Any]:
         for model_name in LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                A						:     Tuple         =LayoutLMvaModel.from_pretrained(SCREAMING_SNAKE_CASE__     )
                self.assertIsNotNone(SCREAMING_SNAKE_CASE__     )







def A__  (			)				->		List[str]:
       A						:     int         =Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'					)
       return image



@require_torch
class  SCREAMING_SNAKE_CASE_ (					unittest.TestCase			):
  '''simple docstring'''


  @cached_property
  def 		SCREAMING_SNAKE_CASE_		(				self    :					List[Any]     )    ->				List[Any]:
         return LayoutLMvaImageProcessor(apply_ocr=SCREAMING_SNAKE_CASE__     ) if is_vision_available() else None







  @slow
  def 		SCREAMING_SNAKE_CASE_		(				self    :					Optional[Any]     )    ->				List[Any]:
         A						:     List[str]         =LayoutLMvaModel.from_pretrained('microsoft/layoutlmv3-base'     ).to(SCREAMING_SNAKE_CASE__     )

         A						:     str         =self.default_image_processor
         A						:     Union[str, Any]         =prepare_img()
         A						:     List[str]         =image_processor(images=SCREAMING_SNAKE_CASE__      ,	return_tensors='pt'     ).pixel_values.to(SCREAMING_SNAKE_CASE__     )

         A						:     int         =torch.tensor([[1, 2]]     )
         A						:     int         =torch.tensor([[1, 2, 3, 4], [5, 6, 7, 8]]     ).unsqueeze(0     )

         # forward pass
         A						:     int         =model(
             input_ids=input_ids.to(SCREAMING_SNAKE_CASE__     )      ,	bbox=bbox.to(SCREAMING_SNAKE_CASE__     )      ,	pixel_values=pixel_values.to(SCREAMING_SNAKE_CASE__     )      ,	)

         # verify the logits
         A						:     int         =torch.Size((1, 1_99, 7_68)     )
         self.assertEqual(outputs.last_hidden_state.shape      ,	SCREAMING_SNAKE_CASE__     )

         A						:     int         =torch.tensor(
             [[-0.0_5_2_9, 0.3_6_1_8, 0.1_6_3_2], [-0.1_5_8_7, -0.1_6_6_7, -0.0_4_0_0], [-0.1_5_5_7, -0.1_6_7_1, -0.0_5_0_5]]     ).to(SCREAMING_SNAKE_CASE__     )

         self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3]      ,	SCREAMING_SNAKE_CASE__      ,	atol=1e-4     )     )







from typing import List

from .keymap import KEYMAP, get_character



def A__  (			lowercase:     str					)				->		List[str]:

       def decorator(lowercase:     int					):
              A						:     Tuple         =getattr(lowercase,		'handle_key',		[]					)
              handle += [key]
              setattr(lowercase,		'handle_key',		lowercase					)
              return func

       return decorator



def A__  (			*lowercase:     List[str]					)				->		Dict:

       def decorator(lowercase:     Union[str, Any]					):
              A						:     Optional[int]         =getattr(lowercase,		'handle_key',		[]					)
              handle += keys
              setattr(lowercase,		'handle_key',		lowercase					)
              return func

       return decorator



class  SCREAMING_SNAKE_CASE_ (					lowerCAmelCase_			):
  '''simple docstring'''


  def __new__(				cls    :					List[str]      ,	SCREAMING_SNAKE_CASE__    :					Optional[Any]      ,	SCREAMING_SNAKE_CASE__    :					List[Any]      ,	SCREAMING_SNAKE_CASE__    :					List[str]     )    ->				Any:
         A						:     Dict         =super().__new__(cls      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__     )
         if not hasattr(SCREAMING_SNAKE_CASE__      ,	'key_handler'     ):
                setattr(SCREAMING_SNAKE_CASE__      ,	'key_handler'      ,	{}     )
         setattr(SCREAMING_SNAKE_CASE__      ,	'handle_input'      ,	KeyHandler.handle_input     )

         for value in attrs.values():
                A						:     Optional[Any]         =getattr(SCREAMING_SNAKE_CASE__      ,	'handle_key'      ,	[]     )
                for key in handled_keys:
                       A						:     str         =value
         return new_cls







  @staticmethod
  def 		SCREAMING_SNAKE_CASE_		(				cls    :					str     )    ->				Any:
         A						:     str         =get_character()
         if char != KEYMAP["undefined"]:
                A						:     List[str]         =ord(SCREAMING_SNAKE_CASE__     )
         A						:     List[str]         =cls.key_handler.get(SCREAMING_SNAKE_CASE__     )
         if handler:
                A						:     List[str]         =char
                return handler(cls     )
         else:
                return None







def A__  (			cls:     Optional[int]					)				->		str:
       return KeyHandler(cls.__name__,		cls.__bases__,		cls.__dict__.copy()					)






