



from __future__ import annotations

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

from matplotlib import pyplot as plt







def    _snake_case (       __snake_case					,  __snake_case					,  __snake_case    )     ->     List[Any]:






      '''simple docstring'''







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

      UpperCAmelCase_  :	List[Any]				      =		(low + high) // 2
      UpperCAmelCase_      ,      UpperCAmelCase_      ,      UpperCAmelCase_  :	Optional[int]				      =		max_subarray(lowerCamelCase_					,  lowerCamelCase_					,  lowerCamelCase_    )
      UpperCAmelCase_      ,      UpperCAmelCase_      ,      UpperCAmelCase_  :	Any				      =		max_subarray(lowerCamelCase_					,  mid + 1					,  lowerCamelCase_    )
      UpperCAmelCase_      ,      UpperCAmelCase_      ,      UpperCAmelCase_  :	Any				      =		max_cross_sum(lowerCamelCase_					,  lowerCamelCase_					,  lowerCamelCase_					,  lowerCamelCase_    )
      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 (       __snake_case					,  __snake_case					,  __snake_case					,  __snake_case    )     ->     Any:






      '''simple docstring'''







      UpperCAmelCase_      ,      UpperCAmelCase_  :	Dict				      =		float("-inf"    ), -1
      UpperCAmelCase_      ,      UpperCAmelCase_  :	Optional[Any]				      =		float("-inf"    ), -1

      UpperCAmelCase_  :	Union[str, Any]				      =		0
      for i in range(lowerCamelCase_					,  low - 1					,  -1    ):
            summ += arr[i]
            if summ > left_sum:
                  UpperCAmelCase_  :	int				      =		summ
                  UpperCAmelCase_  :	Dict				      =		i

      UpperCAmelCase_  :	Union[str, Any]				      =		0
      for i in range(mid + 1					,  high + 1    ):
            summ += arr[i]
            if summ > right_sum:
                  UpperCAmelCase_  :	Optional[Any]				      =		summ
                  UpperCAmelCase_  :	Tuple				      =		i

      return max_left, max_right, (left_sum + right_sum)







def    _snake_case (       __snake_case    )     ->     Any:






      '''simple docstring'''







      UpperCAmelCase_  :	List[str]				      =		[randint(1					,  lowerCamelCase_    ) for _ in range(lowerCamelCase_    )]
      UpperCAmelCase_  :	Dict				      =		time.time()
      max_subarray(lowerCamelCase_					,  0					,  input_size - 1    )
      UpperCAmelCase_  :	Optional[Any]				      =		time.time()
      return end - start







def    _snake_case (       )     ->     Optional[Any]:






      '''simple docstring'''







      UpperCAmelCase_  :	Optional[int]				      =		[1_0, 1_0_0, 1_0_0_0, 1_0_0_0_0, 5_0_0_0_0, 1_0_0_0_0_0, 2_0_0_0_0_0, 3_0_0_0_0_0, 4_0_0_0_0_0, 5_0_0_0_0_0]
      UpperCAmelCase_  :	Union[str, Any]				      =		[time_max_subarray(lowerCamelCase_    ) for input_size in input_sizes]
      print("No of Inputs\t\tTime Taken"    )
      for input_size, runtime in zip(lowerCamelCase_					,  lowerCamelCase_    ):
            print(lowerCamelCase_					,  "\t\t"					,  lowerCamelCase_    )
      plt.plot(lowerCamelCase_					,  lowerCamelCase_    )
      plt.xlabel("Number of Inputs"    )
      plt.ylabel("Time taken in seconds"    )
      plt.show()


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

   testmod()





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


__lowerCamelCase         =			logging.get_logger(__name__)

__lowerCamelCase         =			{
    '''microsoft/focalnet-tiny''': '''https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json''',
}


class   snake_case_ (lowercase__ , lowercase__  ):




       """simple docstring"""






       _lowerCamelCase			    =				"""focalnet"""



       def __init__(     self     ,lowercase=224     ,lowercase=4     ,lowercase=3     ,lowercase=96     ,lowercase=False     ,lowercase=[192, 384, 768, 768]     ,lowercase=[2, 2, 6, 2]     ,lowercase=[2, 2, 2, 2]     ,lowercase=[3, 3, 3, 3]     ,lowercase="gelu"     ,lowercase=4.0     ,lowercase=0.0     ,lowercase=0.1     ,lowercase=False     ,lowercase=1E-4     ,lowercase=False     ,lowercase=False     ,lowercase=False     ,lowercase=0.02     ,lowercase=1E-5     ,lowercase=32     ,lowercase=None     ,lowercase=None     ,**lowercase     ,):

             """simple docstring"""





             super().__init__(**lowercase)

             UpperCAmelCase_  :	int				      =		image_size
             UpperCAmelCase_  :	Optional[Any]				      =		patch_size
             UpperCAmelCase_  :	Dict				      =		num_channels
             UpperCAmelCase_  :	Dict				      =		embed_dim
             UpperCAmelCase_  :	Optional[int]				      =		use_conv_embed
             UpperCAmelCase_  :	int				      =		hidden_sizes
             UpperCAmelCase_  :	Optional[int]				      =		depths
             UpperCAmelCase_  :	Optional[Any]				      =		focal_levels
             UpperCAmelCase_  :	Tuple				      =		focal_windows
             UpperCAmelCase_  :	int				      =		hidden_act
             UpperCAmelCase_  :	Any				      =		mlp_ratio
             UpperCAmelCase_  :	List[Any]				      =		hidden_dropout_prob
             UpperCAmelCase_  :	Tuple				      =		drop_path_rate
             UpperCAmelCase_  :	List[str]				      =		use_layerscale
             UpperCAmelCase_  :	List[str]				      =		layerscale_value
             UpperCAmelCase_  :	List[str]				      =		use_post_layernorm
             UpperCAmelCase_  :	Dict				      =		use_post_layernorm_in_modulation
             UpperCAmelCase_  :	int				      =		normalize_modulator
             UpperCAmelCase_  :	Dict				      =		initializer_range
             UpperCAmelCase_  :	str				      =		layer_norm_eps
             UpperCAmelCase_  :	Union[str, Any]				      =		encoder_stride
             UpperCAmelCase_  :	str				      =		["stem"] + [F"""stage{idx}""" for idx in range(1     ,len(self.depths) + 1)]
             UpperCAmelCase_      ,      UpperCAmelCase_  :	Any				      =		get_aligned_output_features_output_indices(
                 out_features=lowercase     ,out_indices=lowercase     ,stage_names=self.stage_names)
