



import logging
import os

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






			"""simple docstring"""





			@staticmethod
			def 		snake_case__			(				lowercase	:       List[str]   )						->					List[Any]:
									"""simple docstring"""







									__lowercase					=				PartialState()
									return not main_process_only or (main_process_only and state.is_main_process)







			def 		snake_case__			(				self	:       List[str]			,     lowercase	:       Any			,     lowercase	:       List[Any]			,     *lowercase	:       Any			,     **lowercase	:       int   )						->					str:
									"""simple docstring"""







									if PartialState._shared_state == {}:
															raise RuntimeError(
															    """You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility."""   )
									__lowercase					=				kwargs.pop("""main_process_only"""			,     UpperCAmelCase_   )
									__lowercase					=				kwargs.pop("""in_order"""			,     UpperCAmelCase_   )

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

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






def  UpperCAmelCase__    (    lowercase__						,       lowercase__ = None   ):
						if log_level is None:
												__lowercase					=				os.environ.get("""ACCELERATE_LOG_LEVEL"""						,       _SCREAMING_SNAKE_CASE   )
						__lowercase					=				logging.getLogger(_SCREAMING_SNAKE_CASE   )
						if log_level is not None:
												logger.setLevel(log_level.upper()   )
												logger.root.setLevel(log_level.upper()   )
						return MultiProcessAdapter(_SCREAMING_SNAKE_CASE						,       {}   )










def  UpperCAmelCase__    (    lowercase__						,       lowercase__   ) ->      bool:
						__lowercase					=				len(lowercase__   )
						__lowercase					=				[[False] * (required_sum + 1) for _ in range(arr_len + 1   )]

						# for each arr value, a sum of zero(0) can be formed by not taking any element
						# hence True/1
						for i in range(arr_len + 1   ):
												__lowercase					=				True

						# sum is not zero and set is empty then false
						for i in range(1						,       required_sum + 1   ):
												__lowercase					=				False

						for i in range(1						,       arr_len + 1   ):
												for j in range(1						,       required_sum + 1   ):
																		if arr[i - 1] > j:
																								__lowercase					=				subset[i - 1][j]
																		if arr[i - 1] <= j:
																								__lowercase					=				subset[i - 1][j] or subset[i - 1][j - arr[i - 1]]

						return subset[arr_len][required_sum]


if __name__ == "__main__":
			import doctest

			doctest.testmod()





