




"""simple docstring"""






class lowerCAmelCase__			:






			'''simple docstring'''



			def __init__(						self						):
							_lowerCamelCase  :    List[Any]					=					0
							_lowerCamelCase  :    int					=					0
							_lowerCamelCase  :    Any					=					{}
			def       A_					(						self						,   lowercase						):
							if vertex not in self.adjacency:
											_lowerCamelCase  :    Optional[int]					=					{}
											self.num_vertices += 1
			def       A_					(						self						,   lowercase						,   lowercase						,   lowercase						):
							self.add_vertex(lowercase						)
							self.add_vertex(lowercase						)

							if head == tail:
											return

							_lowerCamelCase  :    Tuple					=					weight
							_lowerCamelCase  :    Tuple					=					weight
			def       A_					(						self						):
							_lowerCamelCase  :    Union[str, Any]					=					self.get_edges()
							for edge in edges:
											_lowerCamelCase,				_lowerCamelCase,				_lowerCamelCase  :    Dict					=					edge
											edges.remove((tail, head, weight)						)
							for i in range(len(lowercase						)						):
											_lowerCamelCase  :    List[str]					=					list(edges[i]						)

							edges.sort(key=lambda lowercase						: e[2]						)
							for i in range(len(lowercase						) - 1						):
											if edges[i][2] >= edges[i + 1][2]:
															_lowerCamelCase  :    int					=					edges[i][2] + 1
							for edge in edges:
											_lowerCamelCase,				_lowerCamelCase,				_lowerCamelCase  :    Optional[int]					=					edge
											_lowerCamelCase  :    List[str]					=					weight
											_lowerCamelCase  :    Tuple					=					weight
			def __str__(						self						):
							_lowerCamelCase  :    Union[str, Any]					=					''
							for tail in self.adjacency:
											for head in self.adjacency[tail]:
															_lowerCamelCase  :    Dict					=					self.adjacency[head][tail]
															string += F'''{head} -> {tail} == {weight}\n'''
							return string.rstrip('\n'						)
			def       A_					(						self						):
							_lowerCamelCase  :    Tuple					=					[]
							for tail in self.adjacency:
											for head in self.adjacency[tail]:
															output.append((tail, head, self.adjacency[head][tail])						)
							return output
			def       A_					(						self						):
							return self.adjacency.keys()
			@staticmethod
			def       A_					(						lowercase=None						,   lowercase=None						):
							_lowerCamelCase  :    int					=					Graph()
							if vertices is None:
											_lowerCamelCase  :    List[str]					=					[]
							if edges is None:
											_lowerCamelCase  :    Tuple					=					[]
							for vertex in vertices:
											g.add_vertex(lowercase						)
							for edge in edges:
											g.add_edge(*lowercase						)
							return g






			class lowerCAmelCase__			:






						'''simple docstring'''



						def __init__(						self						):
										_lowerCamelCase  :    Dict					=					{}
										_lowerCamelCase  :    List[str]					=					{}
						def __len__(						self						):
										return len(self.parent						)
						def       A_					(						self						,   lowercase						):
										if item in self.parent:
														return self.find(lowercase						)

										_lowerCamelCase  :    List[Any]					=					item
										_lowerCamelCase  :    Optional[Any]					=					0
										return item
						def       A_					(						self						,   lowercase						):
										if item not in self.parent:
														return self.make_set(lowercase						)
										if item != self.parent[item]:
														_lowerCamelCase  :    List[Any]					=					self.find(self.parent[item]						)
										return self.parent[item]






						def       A_					(						self						,   lowercase						,   lowercase						):
										_lowerCamelCase  :    Union[str, Any]					=					self.find(lowercase						)
										_lowerCamelCase  :    int					=					self.find(lowercase						)

										if roota == roota:
														return roota

										if self.rank[roota] > self.rank[roota]:
														_lowerCamelCase  :    int					=					roota
														return roota

										if self.rank[roota] < self.rank[roota]:
														_lowerCamelCase  :    Optional[int]					=					roota
														return roota

										if self.rank[roota] == self.rank[roota]:
														self.rank[roota] += 1
														_lowerCamelCase  :    Optional[Any]					=					roota
														return roota
										return None

			@staticmethod
			def       A_					(						lowercase						):
							_lowerCamelCase  :    Optional[Any]					=					graph.num_vertices

							_lowerCamelCase  :    Any					=					Graph.UnionFind()
							_lowerCamelCase  :    List[Any]					=					[]
							while num_components > 1:
											_lowerCamelCase  :    int					=					{}
											for vertex in graph.get_vertices():
															_lowerCamelCase  :    Union[str, Any]					=					-1

											_lowerCamelCase  :    Optional[int]					=					graph.get_edges()
											for edge in edges:
															_lowerCamelCase,				_lowerCamelCase,				_lowerCamelCase  :    Optional[int]					=					edge
															edges.remove((tail, head, weight)						)
											for edge in edges:
															_lowerCamelCase,				_lowerCamelCase,				_lowerCamelCase  :    Any					=					edge
															_lowerCamelCase  :    Optional[Any]					=					union_find.find(lowercase						)
															_lowerCamelCase  :    List[str]					=					union_find.find(lowercase						)
															if seta != seta:
																			if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
																							_lowerCamelCase  :    List[Any]					=					[head, tail, weight]

																			if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
																							_lowerCamelCase  :    Dict					=					[head, tail, weight]
											for vertex in cheap_edge:
															if cheap_edge[vertex] != -1:
																			_lowerCamelCase,				_lowerCamelCase,				_lowerCamelCase  :    List[Any]					=					cheap_edge[vertex]
																			if union_find.find(lowercase						) != union_find.find(lowercase						):
																							union_find.union(lowercase						,   lowercase						)
																							mst_edges.append(cheap_edge[vertex]						)
																							_lowerCamelCase  :    List[str]					=					num_components - 1
							_lowerCamelCase  :    Any					=					Graph.build(edges=lowercase						)
							return mst





"""simple docstring"""






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


lowercase__  		=		logging.get_logger(__name__)

lowercase__  		=		{
    """google/realm-cc-news-pretrained-embedder""": (
        """https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/config.json"""
    ),
    """google/realm-cc-news-pretrained-encoder""": (
        """https://huggingface.co/google/realm-cc-news-pretrained-encoder/resolve/main/config.json"""
    ),
    """google/realm-cc-news-pretrained-scorer""": (
        """https://huggingface.co/google/realm-cc-news-pretrained-scorer/resolve/main/config.json"""
    ),
    """google/realm-cc-news-pretrained-openqa""": (
        """https://huggingface.co/google/realm-cc-news-pretrained-openqa/aresolve/main/config.json"""
    ),
    """google/realm-orqa-nq-openqa""": """https://huggingface.co/google/realm-orqa-nq-openqa/resolve/main/config.json""",
    """google/realm-orqa-nq-reader""": """https://huggingface.co/google/realm-orqa-nq-reader/resolve/main/config.json""",
    """google/realm-orqa-wq-openqa""": """https://huggingface.co/google/realm-orqa-wq-openqa/resolve/main/config.json""",
    """google/realm-orqa-wq-reader""": """https://huggingface.co/google/realm-orqa-wq-reader/resolve/main/config.json""",
    # See all REALM models at https://huggingface.co/models?filter=realm
}






class lowerCAmelCase__			(  lowercase		):






			'''simple docstring'''



			lowerCamelCase__   =    """realm"""
			def __init__(						self						,   lowercase=30522						,   lowercase=768						,   lowercase=128						,   lowercase=12						,   lowercase=12						,   lowercase=8						,   lowercase=3072						,   lowercase="gelu_new"						,   lowercase=0.1						,   lowercase=0.1						,   lowercase=512						,   lowercase=2						,   lowercase=0.02						,   lowercase=1E-12						,   lowercase=256						,   lowercase=10						,   lowercase=1E-3						,   lowercase=5						,   lowercase=320						,   lowercase=13353718						,   lowercase=5000						,   lowercase=1						,   lowercase=0						,   lowercase=2						,   **lowercase						,   ):
							super().__init__(pad_token_id=lowercase						,   bos_token_id=lowercase						,   eos_token_id=lowercase						,   **lowercase						)

							# Common config
							_lowerCamelCase  :    str					=					vocab_size
							_lowerCamelCase  :    Dict					=					max_position_embeddings
							_lowerCamelCase  :    int					=					hidden_size
							_lowerCamelCase  :    Optional[Any]					=					retriever_proj_size
							_lowerCamelCase  :    Dict					=					num_hidden_layers
							_lowerCamelCase  :    Any					=					num_attention_heads
							_lowerCamelCase  :    int					=					num_candidates
							_lowerCamelCase  :    List[Any]					=					intermediate_size
							_lowerCamelCase  :    int					=					hidden_act
							_lowerCamelCase  :    Union[str, Any]					=					hidden_dropout_prob
							_lowerCamelCase  :    Dict					=					attention_probs_dropout_prob
							_lowerCamelCase  :    Union[str, Any]					=					initializer_range
							_lowerCamelCase  :    List[Any]					=					type_vocab_size
							_lowerCamelCase  :    int					=					layer_norm_eps

							# Reader config
							_lowerCamelCase  :    Tuple					=					span_hidden_size
							_lowerCamelCase  :    int					=					max_span_width
							_lowerCamelCase  :    Tuple					=					reader_layer_norm_eps
							_lowerCamelCase  :    Union[str, Any]					=					reader_beam_size
							_lowerCamelCase  :    Union[str, Any]					=					reader_seq_len

							# Retrieval config
							_lowerCamelCase  :    Optional[Any]					=					num_block_records
							_lowerCamelCase  :    str					=					searcher_beam_size