


"""simple docstring"""




import logging
import os

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


		'''simple docstring'''



		@staticmethod
		def 			__UpperCAmelCase       (  _a      ):
				__a           =			PartialState()
				return not main_process_only or (main_process_only and state.is_main_process)





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

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

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







def        lowercase							(		lowerCAmelCase__ :     str    ,					lowerCAmelCase__ :     str = None			) ->      Any:
		if log_level is None:
				__a           =			os.environ.get('''ACCELERATE_LOG_LEVEL'''    ,					lowerCAmelCase__			)
		__a           =			logging.getLogger(lowerCAmelCase__			)
		if log_level is not None:
				logger.setLevel(log_level.upper()			)
				logger.root.setLevel(log_level.upper()			)
		return MultiProcessAdapter(lowerCAmelCase__    ,					{}			)













# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


_snake_case  :    Dict						    =  {'configuration_mra': ['MRA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MraConfig']}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _snake_case  :    Optional[int]						    =  [
         'MRA_PRETRAINED_MODEL_ARCHIVE_LIST',
         'MraForMaskedLM',
         'MraForMultipleChoice',
         'MraForQuestionAnswering',
         'MraForSequenceClassification',
         'MraForTokenClassification',
         'MraLayer',
         'MraModel',
         'MraPreTrainedModel',
     ]


if TYPE_CHECKING:
     from .configuration_mra import MRA_PRETRAINED_CONFIG_ARCHIVE_MAP, MraConfig

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_mra import (
              MRA_PRETRAINED_MODEL_ARCHIVE_LIST,
              MraForMaskedLM,
              MraForMultipleChoice,
              MraForQuestionAnswering,
              MraForSequenceClassification,
              MraForTokenClassification,
              MraLayer,
              MraModel,
              MraPreTrainedModel,
          )
else:
     import sys

     _snake_case  :    Tuple						    =  _LazyModule(__name__, globals()['__file__'], _import_structure)

