





import logging
import os

from .state import PartialState

class        __SCREAMING_SNAKE_CASE					(     logging.LoggerAdapter       ):






							@staticmethod
							def 				_lowerCamelCase		(						__lowerCAmelCase  ):
														UpperCamelCase__				     =			PartialState()
														return not main_process_only or (main_process_only and state.is_main_process)







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

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

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






def     _UpperCamelCase     (a__   :str   ,			a__   :str = None       ):






							"""simple docstring"""





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











from typing import Any





def     _UpperCamelCase     (a__   :list       ):






							"""simple docstring"""





							if not input_list:
														return []
							UpperCamelCase__				     =			[input_list.count(a__       ) for value in input_list]
							UpperCamelCase__				     =			max(a__       )  # Gets the maximum count in the input list.
							# Gets values of modes
							return sorted({input_list[i] for i, value in enumerate(a__       ) if value == y}       )


if __name__ == "__main__":
					import doctest

					doctest.testmod()




