



def 	__lowercase   ( )				-> Any:
							return [list(range(10_00 - i							,   -10_00 - i							,   -1   )   ) for i in range(10_00   )]


lowerCAmelCase__		:     Union[str, Any]       						=generate_large_matrix()
lowerCAmelCase__		:     Union[str, Any]       						=(
    [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]],
    [[3, 2], [1, 0]],
    [[7, 7, 6]],
    [[7, 7, 6], [-1, -2, -3]],
    grid,
)






def 	__lowercase   ( a__   )				-> List[Any]:
							assert all(row == sorted(lowerCAmelCase_							,   reverse=lowerCAmelCase_   ) for row in grid   )
							assert all(list(lowerCAmelCase_   ) == sorted(lowerCAmelCase_							,   reverse=lowerCAmelCase_   ) for col in zip(*lowerCAmelCase_   )   )






def 	__lowercase   ( a__   )				-> Union[str, Any]:
							__SCREAMING_SNAKE_CASE									=					0
							__SCREAMING_SNAKE_CASE									=					len(lowerCAmelCase_   ) - 1

							# Edge cases such as no values or all numbers are negative.
							if not array or array[0] < 0:
														return 0

							while right + 1 > left:
														__SCREAMING_SNAKE_CASE									=					(left + right) // 2
														__SCREAMING_SNAKE_CASE									=					array[mid]

														# Num must be negative and the index must be greater than or equal to 0.
														if num < 0 and array[mid - 1] >= 0:
																					return mid

														if num >= 0:
																					__SCREAMING_SNAKE_CASE									=					mid + 1
														else:
																					__SCREAMING_SNAKE_CASE									=					mid - 1
    # No negative numbers so return the last index of the array + 1 which is the length.
							return len(lowerCAmelCase_   )






def 	__lowercase   ( a__   )				-> List[str]:
							__SCREAMING_SNAKE_CASE									=					0
							__SCREAMING_SNAKE_CASE									=					len(grid[0]   )

							for i in range(len(lowerCAmelCase_   )   ):
														__SCREAMING_SNAKE_CASE									=					find_negative_index(grid[i][:bound]   )
														total += bound
							return (len(lowerCAmelCase_   ) * len(grid[0]   )) - total






def 	__lowercase   ( a__   )				-> Tuple:
							return len([number for row in grid for number in row if number < 0]   )






def 	__lowercase   ( a__   )				-> List[Any]:
							__SCREAMING_SNAKE_CASE									=					0
							for row in grid:
														for i, number in enumerate(lowerCAmelCase_   ):
																					if number < 0:
																												total += len(lowerCAmelCase_   ) - i
																												break
							return total






def 	__lowercase   ( )				-> List[Any]:
							from timeit import timeit

							print('Running benchmarks'   )
							__SCREAMING_SNAKE_CASE									=					(
							    """from __main__ import count_negatives_binary_search, """
							    """count_negatives_brute_force, count_negatives_brute_force_with_break, grid"""
							)
							for func in (
							    "count_negatives_binary_search",  # took 0.7727 seconds
							    "count_negatives_brute_force_with_break",  # took 4.6505 seconds
							    "count_negatives_brute_force",  # took 12.8160 seconds
							):
														__SCREAMING_SNAKE_CASE									=					timeit(f"""{func}(grid=grid)"""							,   setup=lowerCAmelCase_							,   number=5_00   )
														print(f"""{func}() took {time:0.4f} seconds"""   )


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			benchmark()














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


lowerCamelCase       :       Optional[Any]        =				logging.get_logger(__name__)

lowerCamelCase       :       List[str]        =				{
    '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''',
    # See all CANINE models at https://huggingface.co/models?filter=canine
}

class 						lowerCAmelCase   (       __a	):

					'''simple docstring'''

					_A  :	List[Any]     =					'''canine'''



					def __init__(     self :		List[str]						,   __a :		Optional[int]=768						,   __a :		Any=12						,   __a :		Any=12						,   __a :		Dict=3072						,   __a :		Dict="gelu"						,   __a :		List[Any]=0.1						,   __a :		List[Any]=0.1						,   __a :		Tuple=16384						,   __a :		List[Any]=16						,   __a :		List[Any]=0.02						,   __a :		Optional[Any]=1E-12						,   __a :		Dict=0						,   __a :		List[Any]=0xe_0_0_0						,   __a :		Optional[int]=0xe_0_0_1						,   __a :		Any=4						,   __a :		Dict=4						,   __a :		Optional[int]=8						,   __a :		Any=16384						,   __a :		Optional[Any]=128						,   **__a :		List[str]						,   )	->     Union[str, Any]:


												"""simple docstring"""

												super().__init__(pad_token_id=__a						,   bos_token_id=__a						,   eos_token_id=__a						,   **__a							)

												__lowercase					:							int			=   max_position_embeddings
												__lowercase					:							List[str]			=   hidden_size
												__lowercase					:							List[Any]			=   num_hidden_layers
												__lowercase					:							Dict			=   num_attention_heads
												__lowercase					:							int			=   intermediate_size
												__lowercase					:							Dict			=   hidden_act
												__lowercase					:							Tuple			=   hidden_dropout_prob
												__lowercase					:							Union[str, Any]			=   attention_probs_dropout_prob
												__lowercase					:							Union[str, Any]			=   initializer_range
												__lowercase					:							Any			=   type_vocab_size
												__lowercase					:							int			=   layer_norm_eps

												# Character config:
												__lowercase					:							int			=   downsampling_rate
												__lowercase					:							str			=   upsampling_kernel_size
												__lowercase					:							Union[str, Any]			=   num_hash_functions
												__lowercase					:							Optional[Any]			=   num_hash_buckets
												__lowercase					:							Optional[int]			=   local_transformer_stride