






import logging
import os

from .state import PartialState
class 			lowerCAmelCase_							(					logging.LoggerAdapter       ):




							@staticmethod
							def     __snake_case       ( SCREAMING_SNAKE_CASE_  : Any						):
											lowerCAmelCase__         =    PartialState()
											return not main_process_only or (main_process_only and state.is_main_process)




							def     __snake_case       ( self  : List[str]			,				SCREAMING_SNAKE_CASE_  : Any			,				SCREAMING_SNAKE_CASE_  : int			,				*SCREAMING_SNAKE_CASE_  : Tuple			,				**SCREAMING_SNAKE_CASE_  : Dict						):
											if PartialState._shared_state == {}:
															raise RuntimeError(
															    '''You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility.'''						)
											lowerCAmelCase__         =    kwargs.pop('''main_process_only'''			,				lowerCAmelCase__						)
											lowerCAmelCase__         =    kwargs.pop('''in_order'''			,				lowerCAmelCase__						)

											if self.isEnabledFor(lowerCAmelCase__						):
															if self._should_log(lowerCAmelCase__						):
																			lowerCAmelCase__         =    self.process(lowerCAmelCase__			,				lowerCAmelCase__						)
																			self.logger.log(lowerCAmelCase__			,				lowerCAmelCase__			,				*lowerCAmelCase__			,				**lowerCAmelCase__						)

															elif in_order:
																			lowerCAmelCase__         =    PartialState()
																			for i in range(state.num_processes						):
																							if i == state.process_index:
																											lowerCAmelCase__         =    self.process(lowerCAmelCase__			,				lowerCAmelCase__						)
																											self.logger.log(lowerCAmelCase__			,				lowerCAmelCase__			,				*lowerCAmelCase__			,				**lowerCAmelCase__						)
																							state.wait_for_everyone()





def 						lowerCAmelCase_		(lowercase__    :							str  ,       lowercase__    :							str = None							)		->     str:


				'''simple docstring'''




				if log_level is None:
								lowerCAmelCase__         =    os.environ.get('''ACCELERATE_LOG_LEVEL'''  ,       lowercase__							)
				lowerCAmelCase__         =    logging.getLogger(lowercase__							)
				if log_level is not None:
								logger.setLevel(log_level.upper()							)
								logger.root.setLevel(log_level.upper()							)
				return MultiProcessAdapter(lowercase__  ,       {}							)










'''simple docstring'''



from __future__ import annotations
def        UpperCAmelCase (    A	:					list[int]       ,		A	:					int					):
							if len(A					) < k or k < 0:
														raise ValueError('''Invalid Input'''					)
							SCREAMING_SNAKE_CASE       :   Dict         =      sum(array[:k]					)
							for i in range(len(A					) - k					):
														SCREAMING_SNAKE_CASE       :   Optional[Any]         =      current_sum - array[i] + array[i + k]
														SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      max(A       ,		A					)
							return max_sum


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

							testmod()
							lowerCAmelCase_  :							Optional[int]             =    [randint(-1000, 1000) for i in range(100)]
							lowerCAmelCase_  :							Optional[int]             =    randint(0, 110)
							print(f'The maximum sum of {k} consecutive elements is {max_sum_in_array(array,k)}')




