



'''simple docstring'''

def 		_snake_case		( )      ->						str:







	"""simple docstring"""
	return [list(range(1_000 - i							,		-1_000 - i							,		-1							)							) for i in range(1_000							)]


UpperCAmelCase     		=   generate_large_matrix()
UpperCAmelCase     		=   (
    [[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 		_snake_case		( _SCREAMING_SNAKE_CASE					:						list[list[int]]							)      ->						int:







	"""simple docstring"""
	assert all(row == sorted(__a							,		reverse=__a							) for row in grid							)
	assert all(list(__a							) == sorted(__a							,		reverse=__a							) for col in zip(*__a							)							)






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						list[int]							)      ->						int:







	"""simple docstring"""
	lowerCAmelCase   =     0
	lowerCAmelCase   =     len(__a							) - 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:
		lowerCAmelCase   =     (left + right) // 2
		lowerCAmelCase   =     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:
			lowerCAmelCase   =     mid + 1
		else:
			lowerCAmelCase   =     mid - 1
    # No negative numbers so return the last index of the array + 1 which is the length.
	return len(__a							)






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						list[list[int]]							)      ->						Dict:







	"""simple docstring"""
	lowerCAmelCase   =     0
	lowerCAmelCase   =     len(grid[0]							)

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






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						list[list[int]]							)      ->						Dict:







	"""simple docstring"""
	return len([number for row in grid for number in row if number < 0]							)






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						list[list[int]]							)      ->						List[Any]:







	"""simple docstring"""
	lowerCAmelCase   =     0
	for row in grid:
		for i, number in enumerate(__a							):
			if number < 0:
				total += len(__a							) - i
				break
	return total






def 		_snake_case		( )      ->						List[str]:







	"""simple docstring"""
	from timeit import timeit

	print("""Running benchmarks"""							)
	lowerCAmelCase   =     (
	    """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
	):
		lowerCAmelCase   =     timeit(f'{func}(grid=grid)'							,		setup=__a							,		number=500							)
		print(f'{func}() took {time:0.4f} seconds'							)


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				benchmark()




'''simple docstring'''

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


UpperCAmelCase     		=   logging.get_logger(__name__)

class __snake_case(				_lowerCAmelCase ):


						'''simple docstring'''



						UpperCAmelCase							:   Optional[int]									=		"timm_backbone"


						def __init__( self     ,	A_=None     ,	A_=3     ,	A_=True     ,	A_=True     ,	A_=None     ,	**A_     ,	)     ->     int:
							super().__init__(**A_				)
							lowerCAmelCase   =     backbone
							lowerCAmelCase   =     num_channels
							lowerCAmelCase   =     features_only
							lowerCAmelCase   =     use_pretrained_backbone
							lowerCAmelCase   =     True
							lowerCAmelCase   =     out_indices if out_indices is not None else (-1,)