
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase						:      List[Any]									= {
    'configuration_x_clip': [
        'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'XCLIPConfig',
        'XCLIPTextConfig',
        'XCLIPVisionConfig',
    ],
    'processing_x_clip': ['XCLIPProcessor'],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase						:      Optional[Any]									= [
      'XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST',
      'XCLIPModel',
      'XCLIPPreTrainedModel',
      'XCLIPTextModel',
      'XCLIPVisionModel',
  ]

if TYPE_CHECKING:
  from .configuration_x_clip import (
      XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
      XCLIPConfig,
      XCLIPTextConfig,
      XCLIPVisionConfig,
  )
  from .processing_x_clip import XCLIPProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_x_clip import (
        XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
        XCLIPModel,
        XCLIPPreTrainedModel,
        XCLIPTextModel,
        XCLIPVisionModel,
    )

else:
  import sys

  lowercase						:      Optional[Any]									= _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

from __future__ import annotations

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

from matplotlib import pyplot as plt




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Sequence[float]		,						_lowerCamelCase				:    int		,						_lowerCamelCase				:    int)      ->					tuple[int | None, int | None, float]:






							'''simple docstring'''





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

							__UpperCamelCase			:     Tuple         =      (low + high) // 2
							__UpperCamelCase     ,		__UpperCamelCase     ,		__UpperCamelCase			:     Dict         =      max_subarray(_lowerCamelCase		,						_lowerCamelCase		,						_lowerCamelCase)
							__UpperCamelCase     ,		__UpperCamelCase     ,		__UpperCamelCase			:     Optional[int]         =      max_subarray(_lowerCamelCase		,						mid + 1		,						_lowerCamelCase)
							__UpperCamelCase     ,		__UpperCamelCase     ,		__UpperCamelCase			:     Dict         =      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 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Sequence[float]		,						_lowerCamelCase				:    int		,						_lowerCamelCase				:    int		,						_lowerCamelCase				:    int)      ->					tuple[int, int, float]:






							'''simple docstring'''





							__UpperCamelCase     ,		__UpperCamelCase			:     Union[str, Any]         =      float("-inf"), -1
							__UpperCamelCase     ,		__UpperCamelCase			:     Optional[int]         =      float("-inf"), -1

							__UpperCamelCase			:     int | float         =      0
							for i in range(_lowerCamelCase		,						low - 1		,						-1):
														summ += arr[i]
														if summ > left_sum:
																					__UpperCamelCase			:     Tuple         =      summ
																					__UpperCamelCase			:     Optional[int]         =      i

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

							return max_left, max_right, (left_sum + right_sum)




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    int)      ->					float:






							'''simple docstring'''





							__UpperCamelCase			:     Tuple         =      [randint(1		,						_lowerCamelCase) for _ in range(_lowerCamelCase)]
							__UpperCamelCase			:     Optional[Any]         =      time.time()
							max_subarray(_lowerCamelCase		,						0		,						input_size - 1)
							__UpperCamelCase			:     Any         =      time.time()
							return end - start




def 			_SCREAMING_SNAKE_CASE      (	)      ->					None:






							'''simple docstring'''





							__UpperCamelCase			:     Dict         =      [10, 100, 1_000, 10_000, 50_000, 100_000, 200_000, 300_000, 400_000, 500_000]
							__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()