

from collections.abc import Sequence



def       __lowerCAmelCase      (						A       ,     A = False    ):
	if not arr:
		return 0

	UpperCAmelCase_       				=			0 if allow_empty_subarrays else float("-inf"    )
	UpperCAmelCase_       				=			0.0
	for num in arr:
		UpperCAmelCase_       				=			max(0 if allow_empty_subarrays else num       ,     curr_sum + num    )
		UpperCAmelCase_       				=			max(A       ,     A    )

	return max_sum


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

				testmod()

				_a:    Any 							=			[-2, 1, -3, 4, -1, 2, 1, -5, 4]
				print(F'{max_subarray_sum(nums) = }')


from .imports import is_tqdm_available


if is_tqdm_available():
				from tqdm.auto import tqdm as _tqdm

from ..state import PartialState



def       __lowerCAmelCase      (						A = True       ,     *A       ,     **A    ):
	if not is_tqdm_available():
		raise ImportError("Accelerate's `tqdm` module requires `tqdm` to be installed. Please run `pip install tqdm`."    )
	UpperCAmelCase_       				=			False
	if main_process_only:
		UpperCAmelCase_       				=			PartialState().local_process_index == 0
	return _tqdm(*A       ,     **A       ,     disable=A    )