





"""simple docstring"""
import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase_								=		logging.get_logger(__name__)

lowerCamelCase_								=		{
    "google/pix2struct-textcaps-base": (
        "https://huggingface.co/google/pix2struct-textcaps-base/resolve/main/config.json"
    ),
}






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      int							=  '''pix2struct_text_model'''
       SCREAMING_SNAKE_CASE_   :      int							=  ['''past_key_values''']
       SCREAMING_SNAKE_CASE_   :      List[str]							=  {
           '''hidden_size''': '''hidden_size''',
           '''num_attention_heads''': '''num_heads''',
           '''num_hidden_layers''': '''num_layers''',
       }




       def __init__(						self		,SCREAMING_SNAKE_CASE__=5_02_44		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=64		,SCREAMING_SNAKE_CASE__=20_48		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__=1_28		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=1E-6		,SCREAMING_SNAKE_CASE__=1.0		,SCREAMING_SNAKE_CASE__="gelu_new"		,SCREAMING_SNAKE_CASE__=0		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=0		,SCREAMING_SNAKE_CASE__=1		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=True		,**SCREAMING_SNAKE_CASE__		,)			->      List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  vocab_size
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  hidden_size
             __SCREAMING_SNAKE_CASE   :Dict						=  d_kv
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  d_ff
             __SCREAMING_SNAKE_CASE   :Any						=  num_layers
             __SCREAMING_SNAKE_CASE   :List[str]						=  num_heads
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  relative_attention_num_buckets
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  relative_attention_max_distance
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  dropout_rate
             __SCREAMING_SNAKE_CASE   :Any						=  layer_norm_epsilon
             __SCREAMING_SNAKE_CASE   :List[str]						=  initializer_factor
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  use_cache

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  eos_token_id
             __SCREAMING_SNAKE_CASE   :Any						=  decoder_start_token_id

             # for backwards compatibility
             __SCREAMING_SNAKE_CASE   :Any						=  dense_act_fn

             super().__init__(
                 pad_token_id=SCREAMING_SNAKE_CASE__		,eos_token_id=SCREAMING_SNAKE_CASE__		,decoder_start_token_id=SCREAMING_SNAKE_CASE__		,tie_word_embeddings=SCREAMING_SNAKE_CASE__		,is_decoder=SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__		,)




       @classmethod
       def     _UpperCamelCase     (						cls		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)			->      "PretrainedConfig":





             """simple docstring"""






             cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Dict						=  cls.get_config_dict(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)

             # get the text config dict if we are loading from Pix2StructConfig
             if config_dict.get('''model_type'''							) == "pix2struct":
                   __SCREAMING_SNAKE_CASE   :Optional[Any]						=  config_dict['''text_config''']

             if "model_type" in config_dict and hasattr(cls		,'''model_type'''							) and config_dict["model_type"] != cls.model_type:
                   logger.warning(
                       f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
                       f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''							)

             return cls.from_dict(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      str							=  '''pix2struct_vision_model'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=20_48		,SCREAMING_SNAKE_CASE__=64		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__="gelu_new"		,SCREAMING_SNAKE_CASE__=1E-6		,SCREAMING_SNAKE_CASE__=0.0		,SCREAMING_SNAKE_CASE__=0.0		,SCREAMING_SNAKE_CASE__=1E-10		,SCREAMING_SNAKE_CASE__=1.0		,SCREAMING_SNAKE_CASE__=40_96		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__=1_28		,**SCREAMING_SNAKE_CASE__		,)			->      int:





             """simple docstring"""






             super().__init__(**SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  hidden_size
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  patch_embed_hidden_size
             __SCREAMING_SNAKE_CASE   :Dict						=  d_ff
             __SCREAMING_SNAKE_CASE   :int						=  dropout_rate
             __SCREAMING_SNAKE_CASE   :int						=  num_hidden_layers
             __SCREAMING_SNAKE_CASE   :List[Any]						=  num_attention_heads
             __SCREAMING_SNAKE_CASE   :List[Any]						=  initializer_range
             __SCREAMING_SNAKE_CASE   :int						=  initializer_factor
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  attention_dropout
             __SCREAMING_SNAKE_CASE   :Dict						=  layer_norm_eps
             __SCREAMING_SNAKE_CASE   :int						=  dense_act_fn
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  seq_len
             __SCREAMING_SNAKE_CASE   :Dict						=  relative_attention_num_buckets
             __SCREAMING_SNAKE_CASE   :int						=  relative_attention_max_distance
             __SCREAMING_SNAKE_CASE   :int						=  d_kv




       @classmethod
       def     _UpperCamelCase     (						cls		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)			->      "PretrainedConfig":





             """simple docstring"""






             cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Optional[Any]						=  cls.get_config_dict(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)

             # get the vision config dict if we are loading from Pix2StructConfig
             if config_dict.get('''model_type'''							) == "pix2struct":
                   __SCREAMING_SNAKE_CASE   :Dict						=  config_dict['''vision_config''']

             if "model_type" in config_dict and hasattr(cls		,'''model_type'''							) and config_dict["model_type"] != cls.model_type:
                   logger.warning(
                       f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
                       f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''							)

             return cls.from_dict(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      Optional[Any]							=  '''pix2struct'''
       SCREAMING_SNAKE_CASE_   :      Optional[Any]							=  True




       def __init__(						self		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=1.0		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=True		,**SCREAMING_SNAKE_CASE__		,)			->      Optional[int]:





             """simple docstring"""






             super().__init__(tie_word_embeddings=SCREAMING_SNAKE_CASE__		,is_encoder_decoder=SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)

             if text_config is None:
                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  {}
                   logger.info('''text_config is None. Initializing the Pix2StructTextConfig with default values.'''							)

             if vision_config is None:
                   __SCREAMING_SNAKE_CASE   :List[str]						=  {}
                   logger.info('''vision_config is None. Initializing the Pix2StructVisionConfig with default values.'''							)

             __SCREAMING_SNAKE_CASE   :Dict						=  PixaStructTextConfig(**SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  PixaStructVisionConfig(**SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :Tuple						=  self.text_config.decoder_start_token_id
             __SCREAMING_SNAKE_CASE   :List[Any]						=  self.text_config.pad_token_id
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  self.text_config.eos_token_id

             __SCREAMING_SNAKE_CASE   :int						=  initializer_factor
             __SCREAMING_SNAKE_CASE   :int						=  initializer_range

             __SCREAMING_SNAKE_CASE   :Dict						=  self.initializer_range
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  self.initializer_range

             __SCREAMING_SNAKE_CASE   :List[str]						=  is_vqa




       @classmethod
       def     _UpperCamelCase     (						cls		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)			->      int:





             """simple docstring"""






             return cls(text_config=text_config.to_dict()		,vision_config=vision_config.to_dict()		,**SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  copy.deepcopy(self.__dict__							)
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  self.text_config.to_dict()
             __SCREAMING_SNAKE_CASE   :List[Any]						=  self.vision_config.to_dict()
             __SCREAMING_SNAKE_CASE   :int						=  self.__class__.model_type
             return output






"""simple docstring"""
import qiskit



def      __lowerCamelCase   (							a_     :		int ,   a_     :		int							)			->      qiskit.result.counts.Counts:
      __SCREAMING_SNAKE_CASE   :Tuple						=  qiskit.Aer.get_backend('''aer_simulator'''							)

      # Create a Quantum Circuit acting on the q register
      __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  qiskit.QuantumCircuit(a_ ,   a_							)

      # Apply X (NOT) Gate to Qubits 0 & 1
      circuit.x(0							)
      circuit.x(1							)

      # Map the quantum measurement to the classical bits
      circuit.measure([0, 1] ,   [0, 1]							)

      # Execute the circuit on the qasm simulator
      __SCREAMING_SNAKE_CASE   :Tuple						=  qiskit.execute(a_ ,   a_ ,   shots=10_00							)

      # Return the histogram data of the results of the experiment.
      return job.result().get_counts(a_							)


if __name__ == "__main__":
  lowerCamelCase_								=		single_qubit_measure(2, 2)
  print(f'Total count for various states are: {counts}')