'''simple docstring'''




import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING


_a   :	List[str] 							=   logging.get_logger(__name__)






class 		__A       (__magic_name__   ):
       snake_case       :Optional[Any]				    =					"upernet"






       def __init__(      self				,     UpperCamelCase_=None				,     UpperCamelCase_=5_12				,     UpperCamelCase_=0.0_2				,     UpperCamelCase_=[1, 2, 3, 6]				,     UpperCamelCase_=True				,     UpperCamelCase_=0.4				,     UpperCamelCase_=3_84				,     UpperCamelCase_=2_56				,     UpperCamelCase_=1				,     UpperCamelCase_=False				,     UpperCamelCase_=2_55				,     **UpperCamelCase_				,     ):
              super().__init__(**UpperCamelCase_      )

              if backbone_config is None:
                     logger.info("`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."      )
                     __UpperCAmelCase  :				int       				=		CONFIG_MAPPING["resnet"](out_features=["stage1", "stage2", "stage3", "stage4"]      )
              elif isinstance(UpperCamelCase_				,     UpperCamelCase_      ):
                     __UpperCAmelCase  :				Any       				=		backbone_config.get("model_type"      )
                     __UpperCAmelCase  :				str       				=		CONFIG_MAPPING[backbone_model_type]
                     __UpperCAmelCase  :				Union[str, Any]       				=		config_class.from_dict(UpperCamelCase_      )

              __UpperCAmelCase  :				List[Any]       				=		backbone_config
              __UpperCAmelCase  :				Dict       				=		hidden_size
              __UpperCAmelCase  :				Optional[Any]       				=		initializer_range
              __UpperCAmelCase  :				str       				=		pool_scales
              __UpperCAmelCase  :				Tuple       				=		use_auxiliary_head
              __UpperCAmelCase  :				int       				=		auxiliary_loss_weight
              __UpperCAmelCase  :				List[Any]       				=		auxiliary_in_channels
              __UpperCAmelCase  :				Tuple       				=		auxiliary_channels
              __UpperCAmelCase  :				Any       				=		auxiliary_num_convs
              __UpperCAmelCase  :				Tuple       				=		auxiliary_concat_input
              __UpperCAmelCase  :				List[Any]       				=		loss_ignore_index







       def 			_snake_case						(      self      ):
              __UpperCAmelCase  :				Optional[int]       				=		copy.deepcopy(self.__dict__      )
              __UpperCAmelCase  :				Optional[Any]       				=		self.backbone_config.to_dict()
              __UpperCAmelCase  :				Any       				=		self.__class__.model_type
              return output







'''simple docstring'''




class 		__A       :






       def __init__(      self				,     UpperCamelCase_      ):
              __UpperCAmelCase  :				Any       				=		set_counts
              __UpperCAmelCase  :				int       				=		max(UpperCamelCase_      )
              __UpperCAmelCase  :				List[str]       				=		len(UpperCamelCase_      )
              __UpperCAmelCase  :				Any       				=		[1] * num_sets
              __UpperCAmelCase  :				Any       				=		list(range(UpperCamelCase_      )      )






       def 			_snake_case						(      self				,     UpperCamelCase_				,     UpperCamelCase_      ):
              __UpperCAmelCase  :				Optional[int]       				=		self.get_parent(UpperCamelCase_      )
              __UpperCAmelCase  :				List[Any]       				=		self.get_parent(UpperCamelCase_      )

              if src_parent == dst_parent:
                     return False

              if self.ranks[dst_parent] >= self.ranks[src_parent]:
                     self.set_counts[dst_parent] += self.set_counts[src_parent]
                     __UpperCAmelCase  :				Optional[Any]       				=		0
                     __UpperCAmelCase  :				List[Any]       				=		dst_parent
                     if self.ranks[dst_parent] == self.ranks[src_parent]:
                            self.ranks[dst_parent] += 1
                     __UpperCAmelCase  :				Union[str, Any]       				=		self.set_counts[dst_parent]
              else:
                     self.set_counts[src_parent] += self.set_counts[dst_parent]
                     __UpperCAmelCase  :				Union[str, Any]       				=		0
                     __UpperCAmelCase  :				Dict       				=		src_parent
                     __UpperCAmelCase  :				Dict       				=		self.set_counts[src_parent]

              __UpperCAmelCase  :				Dict       				=		max(self.max_set				,     UpperCamelCase_      )
              return True







       def 			_snake_case						(      self				,     UpperCamelCase_      ):
              if self.parents[disj_set] == disj_set:
                     return disj_set
              __UpperCAmelCase  :				str       				=		self.get_parent(self.parents[disj_set]      )
              return self.parents[disj_set]






