class     lowerCAmelCase_     :







							def __init__(   self      :     Optional[Any] ,			_A      :     list		):
												_UpperCamelCase			     =     set_counts
												_UpperCamelCase			     =     max(_A		)
												_UpperCamelCase			     =     len(_A		)
												_UpperCamelCase			     =     [1] * num_sets
												_UpperCamelCase			     =     list(range(_A		)		)







							def  UpperCamelCase_						(   self      :     int ,			_A      :     int ,			_A      :     int		):
												_UpperCamelCase			     =     self.get_parent(_A		)
												_UpperCamelCase			     =     self.get_parent(_A		)

												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			     =     0
																	_UpperCamelCase			     =     dst_parent
																	if self.ranks[dst_parent] == self.ranks[src_parent]:
																						self.ranks[dst_parent] += 1
																	_UpperCamelCase			     =     self.set_counts[dst_parent]
												else:
																	self.set_counts[src_parent] += self.set_counts[dst_parent]
																	_UpperCamelCase			     =     0
																	_UpperCamelCase			     =     src_parent
																	_UpperCamelCase			     =     self.set_counts[src_parent]

												_UpperCamelCase			     =     max(self.max_set ,			_A		)
												return True







							def  UpperCamelCase_						(   self      :     Optional[int] ,			_A      :     int		):
												if self.parents[disj_set] == disj_set:
																	return disj_set
												_UpperCamelCase			     =     self.get_parent(self.parents[disj_set]		)
												return self.parents[disj_set]

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCAmelCase       =		logging.get_logger(__name__)

_lowerCAmelCase       =		{
    "microsoft/trocr-base-handwritten": (
        "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json"
    ),
    # See all TrOCR models at https://huggingface.co/models?filter=trocr
}
class     lowerCAmelCase_     (       __lowercase ):
							UpperCAmelCase				   =     "trocr"
							UpperCAmelCase				   =     ["past_key_values"]
							UpperCAmelCase				   =     {
							    "num_attention_heads": "decoder_attention_heads",
							    "hidden_size": "d_model",
							    "num_hidden_layers": "decoder_layers",
							}







							def __init__(   self      :     List[str] ,			_A      :     Optional[Any]=5_0265 ,			_A      :     Optional[Any]=1024 ,			_A      :     Optional[Any]=12 ,			_A      :     Any=16 ,			_A      :     Any=4096 ,			_A      :     Optional[Any]="gelu" ,			_A      :     Union[str, Any]=512 ,			_A      :     Dict=0.1 ,			_A      :     List[str]=0.0 ,			_A      :     Optional[Any]=0.0 ,			_A      :     Union[str, Any]=2 ,			_A      :     Any=0.02 ,			_A      :     List[str]=0.0 ,			_A      :     List[str]=True ,			_A      :     str=False ,			_A      :     List[str]=True ,			_A      :     Optional[Any]=True ,			_A      :     Optional[int]=1 ,			_A      :     int=0 ,			_A      :     Any=2 ,			**_A      :     Optional[int] ,			):
												_UpperCamelCase			     =     vocab_size
												_UpperCamelCase			     =     d_model
												_UpperCamelCase			     =     decoder_layers
												_UpperCamelCase			     =     decoder_attention_heads
												_UpperCamelCase			     =     decoder_ffn_dim
												_UpperCamelCase			     =     activation_function
												_UpperCamelCase			     =     max_position_embeddings
												_UpperCamelCase			     =     dropout
												_UpperCamelCase			     =     attention_dropout
												_UpperCamelCase			     =     activation_dropout
												_UpperCamelCase			     =     init_std
												_UpperCamelCase			     =     decoder_layerdrop
												_UpperCamelCase			     =     use_cache
												_UpperCamelCase			     =     scale_embedding
												_UpperCamelCase			     =     use_learned_position_embeddings
												_UpperCamelCase			     =     layernorm_embedding

												super().__init__(
												    pad_token_id=_A ,			bos_token_id=_A ,			eos_token_id=_A ,			decoder_start_token_id=_A ,			**_A ,			)
