





'''simple docstring'''




from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


if TYPE_CHECKING:
  from ... import FeatureExtractionMixin, TensorType

lowercase__       : Dict         =       logging.get_logger(__name__)

lowercase__       : Union[str, Any]         =       {
    '''openai/imagegpt-small''': '''''',
    '''openai/imagegpt-medium''': '''''',
    '''openai/imagegpt-large''': '''''',
}


class 					SCREAMING_SNAKE_CASE       (a__				):
     lowerCAmelCase						     =			'''imagegpt'''
     lowerCAmelCase						     =			['''past_key_values''']
     lowerCAmelCase						     =			{
         '''hidden_size''': '''n_embd''',
         '''max_position_embeddings''': '''n_positions''',
         '''num_attention_heads''': '''n_head''',
         '''num_hidden_layers''': '''n_layer''',
     }


     def __init__(		self		,      _UpperCAmelCase=512 + 1		,      _UpperCAmelCase=32 * 32		,      _UpperCAmelCase=512		,      _UpperCAmelCase=24		,      _UpperCAmelCase=8		,      _UpperCAmelCase=None		,      _UpperCAmelCase="quick_gelu"		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=0.1		,      _UpperCAmelCase=1e-5		,      _UpperCAmelCase=0.02		,      _UpperCAmelCase=True		,      _UpperCAmelCase=True		,      _UpperCAmelCase=False		,      _UpperCAmelCase=False		,      _UpperCAmelCase=False		,      **_UpperCAmelCase		,      ):

          '''simple docstring'''






          __A		:					str						=			vocab_size
          __A		:					List[Any]						=			n_positions
          __A		:					List[Any]						=			n_embd
          __A		:					Dict						=			n_layer
          __A		:					str						=			n_head
          __A		:					List[str]						=			n_inner
          __A		:					Optional[Any]						=			activation_function
          __A		:					Optional[Any]						=			resid_pdrop
          __A		:					str						=			embd_pdrop
          __A		:					Tuple						=			attn_pdrop
          __A		:					str						=			layer_norm_epsilon
          __A		:					Union[str, Any]						=			initializer_range
          __A		:					Union[str, Any]						=			scale_attn_weights
          __A		:					List[str]						=			use_cache
          __A		:					int						=			scale_attn_by_inverse_layer_idx
          __A		:					Optional[Any]						=			reorder_and_upcast_attn
          __A		:					Optional[int]						=			tie_word_embeddings

          super().__init__(tie_word_embeddings=_UpperCAmelCase		,      **_UpperCAmelCase)




class 					SCREAMING_SNAKE_CASE       (a__				):


     @property
     def 				SCREAMING_SNAKE_CASE    (		self):

          '''simple docstring'''






          return OrderedDict(
              [
                  ('input_ids', {0: 'batch', 1: 'sequence'}),
              ])


     def 				SCREAMING_SNAKE_CASE    (		self		,      _UpperCAmelCase		,      _UpperCAmelCase = 1		,      _UpperCAmelCase = -1		,      _UpperCAmelCase = False		,      _UpperCAmelCase = None		,      _UpperCAmelCase = 3		,      _UpperCAmelCase = 32		,      _UpperCAmelCase = 32		,      ):

          '''simple docstring'''






          __A		:					List[str]						=			self._generate_dummy_images(_UpperCAmelCase		,      _UpperCAmelCase		,      _UpperCAmelCase		,      _UpperCAmelCase)
          __A		:					Any						=			dict(preprocessor(images=_UpperCAmelCase		,      return_tensors=_UpperCAmelCase))

          return inputs



'''simple docstring'''






from typing import Any

import numpy as np





def lowerCamelCase__     (		__lowerCamelCase			:				np.ndarray				):







   '''simple docstring'''




   return np.array_equal(__lowerCamelCase			,       matrix.conjugate().T				)





def lowerCamelCase__     (		__lowerCamelCase			:				np.ndarray			,       __lowerCamelCase			:				np.ndarray				):







   '''simple docstring'''




   _UpperCAmelCase  :  str				       =v.conjugate().T
   _UpperCAmelCase  :  Optional[int]				       =v_star.dot(__lowerCamelCase				)
   assert isinstance(__lowerCamelCase			,       np.ndarray				)
   return (v_star_dot.dot(__lowerCamelCase				)) / (v_star.dot(__lowerCamelCase				))





def lowerCamelCase__     (		):







   '''simple docstring'''




   _UpperCAmelCase  :  Optional[Any]				       =np.array([[2, 2 + 1J, 4], [2 - 1J, 3, 1J], [4, -1J, 1]]				)
   _UpperCAmelCase  :  List[str]				       =np.array([[1], [2], [3]]				)
   assert is_hermitian(__lowerCamelCase				), f"{a} is not hermitian."
   print(rayleigh_quotient(__lowerCamelCase			,       __lowerCamelCase				)				)

   _UpperCAmelCase  :  List[str]				       =np.array([[1, 2, 4], [2, 3, -1], [4, -1, 1]]				)
   assert is_hermitian(__lowerCamelCase				), f"{a} is not hermitian."
   assert rayleigh_quotient(__lowerCamelCase			,       __lowerCamelCase				) == float(3				)


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 tests()

