

"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowerCAmelCase						=		{
    """configuration_git""": ["""GIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GitConfig""", """GitVisionConfig"""],
    """processing_git""": ["""GitProcessor"""],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _lowerCAmelCase						=		[
     """GIT_PRETRAINED_MODEL_ARCHIVE_LIST""",
     """GitForCausalLM""",
     """GitModel""",
     """GitPreTrainedModel""",
     """GitVisionModel""",
 ]

if TYPE_CHECKING:
 from .configuration_git import GIT_PRETRAINED_CONFIG_ARCHIVE_MAP, GitConfig, GitVisionConfig
 from .processing_git import GitProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_git import (
      GIT_PRETRAINED_MODEL_ARCHIVE_LIST,
      GitForCausalLM,
      GitModel,
      GitPreTrainedModel,
      GitVisionModel,
  )

else:
 import sys

 _lowerCAmelCase						=		_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)








"""simple docstring"""






import logging
import os

from .state import PartialState







class 	__UpperCamelCase    (    logging.LoggerAdapter						):

  @staticmethod
  def __lowerCamelCase		(		_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Optional[Any]  =    PartialState()
      return not main_process_only or (main_process_only and state.is_main_process)







  def __lowerCamelCase		(		self    ,_A    ,_A    ,*_A    ,**_A      ):
      '''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.'      )
      _lowerCAmelCase       :   Tuple  =    kwargs.pop('main_process_only'    ,_A      )
      _lowerCAmelCase       :   Any  =    kwargs.pop('in_order'    ,_A      )

      if self.isEnabledFor(_A      ):
          if self._should_log(_A      ):
              _lowerCAmelCase,					_lowerCAmelCase       :   Optional[int]  =    self.process(_A    ,_A      )
              self.logger.log(_A    ,_A    ,*_A    ,**_A      )

          elif in_order:
              _lowerCAmelCase       :   str  =    PartialState()
              for i in range(state.num_processes      ):
                  if i == state.process_index:
                      _lowerCAmelCase,					_lowerCAmelCase       :   Optional[int]  =    self.process(_A    ,_A      )
                      self.logger.log(_A    ,_A    ,*_A    ,**_A      )
                  state.wait_for_everyone()





def 		lowerCamelCase__		(					_lowerCamelCase ,   _lowerCamelCase = None   ):

    '''simple docstring'''



    if log_level is None:
        _lowerCAmelCase       :   Union[str, Any]  =    os.environ.get('ACCELERATE_LOG_LEVEL' ,   _lowerCamelCase   )
    _lowerCAmelCase       :   int  =    logging.getLogger(_lowerCamelCase   )
    if log_level is not None:
        logger.setLevel(log_level.upper()   )
        logger.root.setLevel(log_level.upper()   )
    return MultiProcessAdapter(_lowerCamelCase ,   {}   )





