




'''simple docstring'''


from __future__ import annotations

import time
from collections.abc import Sequence
from random import randint

from matplotlib import pyplot as plt
def 		snake_case_   (UpperCamelCase	:  Sequence[float]			,						UpperCamelCase	:  int			,						UpperCamelCase	:  int				):





							'''simple docstring'''


							if not arr:
														return None, None, 0
							if low == high:
														return low, high, arr[low]

							_a     					=    (low + high) // 2
							_a					,							_a					,							_a     					=    max_subarray(UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase				)
							_a					,							_a					,							_a     					=    max_subarray(UpperCamelCase			,						mid + 1			,						UpperCamelCase				)
							_a					,							_a					,							_a     					=    max_cross_sum(UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase			,						UpperCamelCase				)
							if left_sum >= right_sum and left_sum >= cross_sum:
														return left_low, left_high, left_sum
							elif right_sum >= left_sum and right_sum >= cross_sum:
														return right_low, right_high, right_sum
							return cross_left, cross_right, cross_sum
def 		snake_case_   (UpperCamelCase	:  Sequence[float]			,						UpperCamelCase	:  int			,						UpperCamelCase	:  int			,						UpperCamelCase	:  int				):





							'''simple docstring'''


							_a					,							_a     					=    float('''-inf'''				), -1
							_a					,							_a     					=    float('''-inf'''				), -1

							_a     					=    0
							for i in range(UpperCamelCase			,						low - 1			,						-1				):
														summ += arr[i]
														if summ > left_sum:
																					_a     					=    summ
																					_a     					=    i

							_a     					=    0
							for i in range(mid + 1			,						high + 1				):
														summ += arr[i]
														if summ > right_sum:
																					_a     					=    summ
																					_a     					=    i

							return max_left, max_right, (left_sum + right_sum)
def 		snake_case_   (UpperCamelCase	:  int				):





							'''simple docstring'''


							_a     					=    [randint(1			,						UpperCamelCase				) for _ in range(UpperCamelCase				)]
							_a     					=    time.time()
							max_subarray(UpperCamelCase			,						0			,						input_size - 1				)
							_a     					=    time.time()
							return end - start
def 		snake_case_   ():





							'''simple docstring'''


							_a     					=    [10, 100, 1000, 1_0000, 5_0000, 10_0000, 20_0000, 30_0000, 40_0000, 50_0000]
							_a     					=    [time_max_subarray(UpperCamelCase				) for input_size in input_sizes]
							print('''No of Inputs\t\tTime Taken'''				)
							for input_size, runtime in zip(UpperCamelCase			,						UpperCamelCase				):
														print(UpperCamelCase			,						'''\t\t'''			,						UpperCamelCase				)
							plt.plot(UpperCamelCase			,						UpperCamelCase				)
							plt.xlabel('''Number of Inputs'''				)
							plt.ylabel('''Time taken in seconds'''				)
							plt.show()


if __name__ == "__main__":
				from doctest import testmod

				testmod()







'''simple docstring'''


from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


_snake_case				:				Dict       							=		logging.get_logger(__name__)

_snake_case				:				Optional[Any]       							=		{
    'shi-labs/nat-mini-in1k-224': 'https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json',
    # See all Nat models at https://huggingface.co/models?filter=nat
}

class       A   (		_a					,_a   ):
							lowercase_          =    'nat'

							lowercase_          =    {
							    'num_attention_heads': 'num_heads',
							    'num_hidden_layers': 'num_layers',
							}







							def __init__(  self	:  List[str]							,      lowerCAmelCase_	:  str=4							,      lowerCAmelCase_	:  Any=3							,      lowerCAmelCase_	:  List[Any]=64							,      lowerCAmelCase_	:  Dict=[3, 4, 6, 5]							,      lowerCAmelCase_	:  Dict=[2, 4, 8, 16]							,      lowerCAmelCase_	:  str=7							,      lowerCAmelCase_	:  Dict=3.0							,      lowerCAmelCase_	:  int=True							,      lowerCAmelCase_	:  Tuple=0.0							,      lowerCAmelCase_	:  str=0.0							,      lowerCAmelCase_	:  List[str]=0.1							,      lowerCAmelCase_	:  int="gelu"							,      lowerCAmelCase_	:  List[str]=0.0_2							,      lowerCAmelCase_	:  str=1e-5							,      lowerCAmelCase_	:  Tuple=0.0							,      lowerCAmelCase_	:  str=None							,      lowerCAmelCase_	:  int=None							,      **lowerCAmelCase_	:  List[Any]							,      )      ->							Any:


														"""simple docstring"""


														super().__init__(**lowerCAmelCase_ )

														_a     					=    patch_size
														_a     					=    num_channels
														_a     					=    embed_dim
														_a     					=    depths
														_a     					=    len(lowerCAmelCase_ )
														_a     					=    num_heads
														_a     					=    kernel_size
														_a     					=    mlp_ratio
														_a     					=    qkv_bias
														_a     					=    hidden_dropout_prob
														_a     					=    attention_probs_dropout_prob
														_a     					=    drop_path_rate
														_a     					=    hidden_act
														_a     					=    layer_norm_eps
														_a     					=    initializer_range
														# we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
														# this indicates the channel dimension after the last stage of the model
														_a     					=    int(embed_dim * 2 ** (len(lowerCAmelCase_ ) - 1) )
														_a     					=    layer_scale_init_value
														_a     					=    ['''stem'''] + [F'stage{idx}' for idx in range(1							,      len(lowerCAmelCase_ ) + 1 )]
														_a					,							_a     					=    get_aligned_output_features_output_indices(
														    out_features=lowerCAmelCase_							,      out_indices=lowerCAmelCase_							,      stage_names=self.stage_names )

