

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


SCREAMING_SNAKE_CASE_        =      logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_        =      {
    'microsoft/focalnet-tiny': 'https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json',
}

class 				a  (	UpperCAmelCase							, UpperCAmelCase				):
						_lowercase    						=			"focalnet"


						def __init__(       self						,					A_=224						,					A_=4						,					A_=3						,					A_=96						,					A_=False						,					A_=[192, 384, 768, 768]						,					A_=[2, 2, 6, 2]						,					A_=[2, 2, 2, 2]						,					A_=[3, 3, 3, 3]						,					A_="gelu"						,					A_=4.0						,					A_=0.0						,					A_=0.1						,					A_=False						,					A_=1e-4						,					A_=False						,					A_=False						,					A_=False						,					A_=0.02						,					A_=1e-5						,					A_=32						,					A_=None						,					A_=None						,					**A_						,					):







										'''simple docstring'''


										super().__init__(**A_	)

										_UpperCAmelCase       :		str 		=    image_size
										_UpperCAmelCase       :		Dict 		=    patch_size
										_UpperCAmelCase       :		Dict 		=    num_channels
										_UpperCAmelCase       :		Tuple 		=    embed_dim
										_UpperCAmelCase       :		Optional[Any] 		=    use_conv_embed
										_UpperCAmelCase       :		Dict 		=    hidden_sizes
										_UpperCAmelCase       :		Tuple 		=    depths
										_UpperCAmelCase       :		str 		=    focal_levels
										_UpperCAmelCase       :		List[str] 		=    focal_windows
										_UpperCAmelCase       :		List[Any] 		=    hidden_act
										_UpperCAmelCase       :		Dict 		=    mlp_ratio
										_UpperCAmelCase       :		Tuple 		=    hidden_dropout_prob
										_UpperCAmelCase       :		Dict 		=    drop_path_rate
										_UpperCAmelCase       :		List[str] 		=    use_layerscale
										_UpperCAmelCase       :		Dict 		=    layerscale_value
										_UpperCAmelCase       :		List[Any] 		=    use_post_layernorm
										_UpperCAmelCase       :		int 		=    use_post_layernorm_in_modulation
										_UpperCAmelCase       :		str 		=    normalize_modulator
										_UpperCAmelCase       :		Optional[Any] 		=    initializer_range
										_UpperCAmelCase       :		Tuple 		=    layer_norm_eps
										_UpperCAmelCase       :		Union[str, Any] 		=    encoder_stride
										_UpperCAmelCase       :		List[str] 		=    ["stem"] + [f'stage{idx}' for idx in range(1						,					len(self.depths	) + 1	)]
										_UpperCAmelCase		,							_UpperCAmelCase       :		List[Any] 		=    get_aligned_output_features_output_indices(
										    out_features=A_						,					out_indices=A_						,					stage_names=self.stage_names	)





import logging
import os

from .state import PartialState

class 				a  (	logging.LoggerAdapter				):


						@staticmethod
						def        _UpperCAmelCase				(       A_	):







										'''simple docstring'''


										_UpperCAmelCase       :		Tuple 		=    PartialState()
										return not main_process_only or (main_process_only and state.is_main_process)





						def        _UpperCAmelCase				(       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."	)
										_UpperCAmelCase       :		Tuple 		=    kwargs.pop("main_process_only"						,					A_	)
										_UpperCAmelCase       :		int 		=    kwargs.pop("in_order"						,					A_	)

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

														elif in_order:
																		_UpperCAmelCase       :		Dict 		=    PartialState()
																		for i in range(state.num_processes	):
																						if i == state.process_index:
																										_UpperCAmelCase		,							_UpperCAmelCase       :		Union[str, Any] 		=    self.process(A_						,					A_	)
																										self.logger.log(A_						,					A_						,					*A_						,					**A_	)
																						state.wait_for_everyone()







def 							__SCREAMING_SNAKE_CASE							(				lowerCAmelCase:  str  ,      lowerCAmelCase:  str = None )   ->       List[Any]:
				if log_level is None:
								_UpperCAmelCase       :		List[str] 		=    os.environ.get("ACCELERATE_LOG_LEVEL"  ,      lowerCAmelCase )
				_UpperCAmelCase       :		str 		=    logging.getLogger(lowerCAmelCase )
				if log_level is not None:
								logger.setLevel(log_level.upper() )
								logger.root.setLevel(log_level.upper() )
				return MultiProcessAdapter(lowerCAmelCase  ,      {} )


