

import numpy as np







def       A_				(   _UpperCAmelCase    ,     _UpperCAmelCase    ,     _UpperCAmelCase = 1e-12    ,     _UpperCAmelCase = 1_00    ,     ):
						assert np.shape(_UpperCAmelCase   )[0] == np.shape(_UpperCAmelCase   )[1]
						# Ensure proper dimensionality.
						assert np.shape(_UpperCAmelCase   )[0] == np.shape(_UpperCAmelCase   )[0]
						# Ensure inputs are either both complex or both real
						assert np.iscomplexobj(_UpperCAmelCase   ) == np.iscomplexobj(_UpperCAmelCase   )
						SCREAMING_SNAKE_CASE_:			Optional[Any]   		=	np.iscomplexobj(_UpperCAmelCase   )
						if is_complex:
												# Ensure complex input_matrix is Hermitian
												assert np.array_equal(_UpperCAmelCase    ,     input_matrix.conj().T   )

						# Set convergence to False. Will define convergence when we exceed max_iterations
						# or when we have small changes from one iteration to next.

						SCREAMING_SNAKE_CASE_:			Dict   		=	False
						SCREAMING_SNAKE_CASE_:			Optional[Any]   		=	0
						SCREAMING_SNAKE_CASE_:			List[str]   		=	0
						SCREAMING_SNAKE_CASE_:			Optional[Any]   		=	1e12

						while not convergence:
												# Multiple matrix by the vector.
												SCREAMING_SNAKE_CASE_:			Optional[int]   		=	np.dot(_UpperCAmelCase    ,     _UpperCAmelCase   )
												# Normalize the resulting output vector.
												SCREAMING_SNAKE_CASE_:			Optional[int]   		=	w / np.linalg.norm(_UpperCAmelCase   )
												# Find rayleigh quotient
												# (faster than usual b/c we know vector is normalized already)
												SCREAMING_SNAKE_CASE_:			int   		=	vector.conj().T if is_complex else vector.T
												SCREAMING_SNAKE_CASE_:			List[Any]   		=	np.dot(_UpperCAmelCase    ,     np.dot(_UpperCAmelCase    ,     _UpperCAmelCase   )   )

												# Check convergence.
												SCREAMING_SNAKE_CASE_:			Tuple   		=	np.abs(lambda_ - lambda_previous   ) / lambda_
												iterations += 1

												if error <= error_tol or iterations >= max_iterations:
																		SCREAMING_SNAKE_CASE_:			Tuple   		=	True

												SCREAMING_SNAKE_CASE_:			List[str]   		=	lambda_

						if is_complex:
												SCREAMING_SNAKE_CASE_:			str   		=	np.real(lambda_   )

						return lambda_, vector







def       A_				(   ):
						SCREAMING_SNAKE_CASE_:			List[Any]   		=	np.array([[41, 4, 20], [4, 26, 30], [20, 30, 50]]   )
						SCREAMING_SNAKE_CASE_:			Union[str, Any]   		=	np.array([41, 4, 20]   )
						SCREAMING_SNAKE_CASE_:			int   		=	real_input_matrix.astype(np.complexaaa   )
						SCREAMING_SNAKE_CASE_:			List[str]   		=	np.triu(1J * complex_input_matrix    ,     1   )
						complex_input_matrix += imag_matrix
						complex_input_matrix += -1 * imag_matrix.T
						SCREAMING_SNAKE_CASE_:			Optional[int]   		=	np.array([41, 4, 20]   ).astype(np.complexaaa   )

						for problem_type in ["real", "complex"]:
												if problem_type == "real":
																		SCREAMING_SNAKE_CASE_:			int   		=	real_input_matrix
																		SCREAMING_SNAKE_CASE_:			Tuple   		=	real_vector
												elif problem_type == "complex":
																		SCREAMING_SNAKE_CASE_:			str   		=	complex_input_matrix
																		SCREAMING_SNAKE_CASE_:			List[Any]   		=	complex_vector

												# Our implementation.
												SCREAMING_SNAKE_CASE_:			Any   		=	power_iteration(_UpperCAmelCase    ,     _UpperCAmelCase   )

												# Numpy implementation.

												# Get eigenvalues and eigenvectors using built-in numpy
												# eigh (eigh used for symmetric or hermetian matrices).
												SCREAMING_SNAKE_CASE_:			Optional[int]   		=	np.linalg.eigh(_UpperCAmelCase   )
												# Last eigenvalue is the maximum one.
												SCREAMING_SNAKE_CASE_:			Optional[int]   		=	eigen_values[-1]
												# Last column in this matrix is eigenvector corresponding to largest eigenvalue.
												SCREAMING_SNAKE_CASE_:			int   		=	eigen_vectors[:, -1]

												# Check our implementation and numpy gives close answers.
												assert np.abs(eigen_value - eigen_value_max   ) <= 1e-6
												# Take absolute values element wise of each eigenvector.
												# as they are only unique to a minus sign.
												assert np.linalg.norm(np.abs(_UpperCAmelCase   ) - np.abs(_UpperCAmelCase   )   ) <= 1e-6


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						test_power_iteration()









import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_convbert import ConvBertTokenizer


lowerCAmelCase							:  Any            =						logging.get_logger(__name__)

lowerCAmelCase							:  Dict            =						{"""vocab_file""": """vocab.txt"""}

lowerCAmelCase							:  List[str]            =						{
    """vocab_file""": {
        """YituTech/conv-bert-base""": """https://huggingface.co/YituTech/conv-bert-base/resolve/main/vocab.txt""",
        """YituTech/conv-bert-medium-small""": (
            """https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/vocab.txt"""
        ),
        """YituTech/conv-bert-small""": """https://huggingface.co/YituTech/conv-bert-small/resolve/main/vocab.txt""",
    }
}

lowerCAmelCase							:  List[Any]            =						{
    """YituTech/conv-bert-base""": 512,
    """YituTech/conv-bert-medium-small""": 512,
    """YituTech/conv-bert-small""": 512,
}


lowerCAmelCase							:  Tuple            =						{
    """YituTech/conv-bert-base""": {"""do_lower_case""": True},
    """YituTech/conv-bert-medium-small""": {"""do_lower_case""": True},
    """YituTech/conv-bert-small""": {"""do_lower_case""": True},
}



class   __lowercase    (			UpperCAmelCase_     ):




			"""simple docstring"""







			_UpperCAmelCase       :							str      							=					VOCAB_FILES_NAMES
			_UpperCAmelCase       :							List[str]      							=					PRETRAINED_VOCAB_FILES_MAP
			_UpperCAmelCase       :							List[Any]      							=					PRETRAINED_INIT_CONFIGURATION
			_UpperCAmelCase       :							Optional[Any]      							=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			_UpperCAmelCase       :							Dict      							=					ConvBertTokenizer



			def __init__(			self  :					Optional[Any]       ,						lowerCAmelCase__  :					Optional[int]=None       ,						lowerCAmelCase__  :					List[str]=None       ,						lowerCAmelCase__  :					str=True       ,						lowerCAmelCase__  :					Any="[UNK]"       ,						lowerCAmelCase__  :					Optional[Any]="[SEP]"       ,						lowerCAmelCase__  :					Any="[PAD]"       ,						lowerCAmelCase__  :					Dict="[CLS]"       ,						lowerCAmelCase__  :					Dict="[MASK]"       ,						lowerCAmelCase__  :					Tuple=True       ,						lowerCAmelCase__  :					str=None       ,						**lowerCAmelCase__  :					Dict       ,						):
									super().__init__(
									    lowerCAmelCase__       ,						tokenizer_file=lowerCAmelCase__       ,						do_lower_case=lowerCAmelCase__       ,						unk_token=lowerCAmelCase__       ,						sep_token=lowerCAmelCase__       ,						pad_token=lowerCAmelCase__       ,						cls_token=lowerCAmelCase__       ,						mask_token=lowerCAmelCase__       ,						tokenize_chinese_chars=lowerCAmelCase__       ,						strip_accents=lowerCAmelCase__       ,						**lowerCAmelCase__       ,						)

									SCREAMING_SNAKE_CASE_:			List[str]  		=	json.loads(self.backend_tokenizer.normalizer.__getstate__())
									if (
									    normalizer_state.get("lowercase"       ,						lowerCAmelCase__) != do_lower_case
									    or normalizer_state.get("strip_accents"       ,						lowerCAmelCase__) != strip_accents
									    or normalizer_state.get("handle_chinese_chars"       ,						lowerCAmelCase__) != tokenize_chinese_chars
									):
															SCREAMING_SNAKE_CASE_:			Optional[int]  		=	getattr(lowerCAmelCase__       ,						normalizer_state.pop("type"))
															SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	do_lower_case
															SCREAMING_SNAKE_CASE_:			List[str]  		=	strip_accents
															SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	tokenize_chinese_chars
															SCREAMING_SNAKE_CASE_:			Optional[int]  		=	normalizer_class(**lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	do_lower_case



			def 	_SCREAMING_SNAKE_CASE      (			self  :					str       ,						lowerCAmelCase__  :					Optional[int]       ,						lowerCAmelCase__  :					Union[str, Any]=None):
									SCREAMING_SNAKE_CASE_:			List[str]  		=	[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 	_SCREAMING_SNAKE_CASE      (			self  :					Optional[Any]       ,						lowerCAmelCase__  :					List[int]       ,						lowerCAmelCase__  :					Optional[List[int]] = None):
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	[self.sep_token_id]
									SCREAMING_SNAKE_CASE_:			int  		=	[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 	_SCREAMING_SNAKE_CASE      (			self  :					List[Any]       ,						lowerCAmelCase__  :					str       ,						lowerCAmelCase__  :					Optional[str] = None):
									SCREAMING_SNAKE_CASE_:			Any  		=	self._tokenizer.model.save(lowerCAmelCase__       ,						name=lowerCAmelCase__)
									return tuple(lowerCAmelCase__)






