



'''simple docstring'''




from ...configuration_utils import PretrainedConfig


lowerCamelCase							:str				    =					{
    '''google/tapas-base-finetuned-sqa''': (
        '''https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json'''
    ),
    '''google/tapas-base-finetuned-wtq''': (
        '''https://huggingface.co/google/tapas-base-finetuned-wtq/resolve/main/config.json'''
    ),
    '''google/tapas-base-finetuned-wikisql-supervised''': (
        '''https://huggingface.co/google/tapas-base-finetuned-wikisql-supervised/resolve/main/config.json'''
    ),
    '''google/tapas-base-finetuned-tabfact''': (
        '''https://huggingface.co/google/tapas-base-finetuned-tabfact/resolve/main/config.json'''
    ),
}







class 	_lowerCAmelCase							(			__UpperCAmelCase ):
	__SCREAMING_SNAKE_CASE   :		Optional[Any]					=					'tapas'


	def __init__(self       ,      lowercase=30522       ,      lowercase=768       ,      lowercase=12       ,      lowercase=12       ,      lowercase=3072       ,      lowercase="gelu"       ,      lowercase=0.1       ,      lowercase=0.1       ,      lowercase=1024       ,      lowercase=[3, 256, 256, 2, 256, 256, 10]       ,      lowercase=0.02       ,      lowercase=1E-12       ,      lowercase=0       ,      lowercase=10.0       ,      lowercase=0       ,      lowercase=1.0       ,      lowercase=None       ,      lowercase=1.0       ,      lowercase=False       ,      lowercase=None       ,      lowercase=1.0       ,      lowercase=1.0       ,      lowercase=False       ,      lowercase=False       ,      lowercase="ratio"       ,      lowercase=None       ,      lowercase=None       ,      lowercase=64       ,      lowercase=32       ,      lowercase=False       ,      lowercase=True       ,      lowercase=False       ,      lowercase=False       ,      lowercase=True       ,      lowercase=False       ,      lowercase=None       ,      lowercase=None       ,      **lowercase       ,      ):
				super().__init__(pad_token_id=lowercase       ,      **lowercase							)

				# BERT hyperparameters (with updated max_position_embeddings and type_vocab_sizes)
				A_	:						Dict	=     vocab_size
				A_	:						Dict	=     hidden_size
				A_	:						Optional[Any]	=     num_hidden_layers
				A_	:						str	=     num_attention_heads
				A_	:						Union[str, Any]	=     hidden_act
				A_	:						Union[str, Any]	=     intermediate_size
				A_	:						List[Any]	=     hidden_dropout_prob
				A_	:						Tuple	=     attention_probs_dropout_prob
				A_	:						List[str]	=     max_position_embeddings
				A_	:						Dict	=     type_vocab_sizes
				A_	:						Optional[Any]	=     initializer_range
				A_	:						Tuple	=     layer_norm_eps

				# Fine-tuning task hyperparameters
				A_	:						str	=     positive_label_weight
				A_	:						List[Any]	=     num_aggregation_labels
				A_	:						Union[str, Any]	=     aggregation_loss_weight
				A_	:						List[Any]	=     use_answer_as_supervision
				A_	:						int	=     answer_loss_importance
				A_	:						Optional[Any]	=     use_normalized_answer_loss
				A_	:						Dict	=     huber_loss_delta
				A_	:						List[Any]	=     temperature
				A_	:						str	=     aggregation_temperature
				A_	:						List[Any]	=     use_gumbel_for_cells
				A_	:						int	=     use_gumbel_for_aggregation
				A_	:						Dict	=     average_approximation_function
				A_	:						List[str]	=     cell_selection_preference
				A_	:						List[Any]	=     answer_loss_cutoff
				A_	:						Optional[int]	=     max_num_rows
				A_	:						int	=     max_num_columns
				A_	:						Optional[int]	=     average_logits_per_cell
				A_	:						Optional[int]	=     select_one_column
				A_	:						List[Any]	=     allow_empty_column_selection
				A_	:						Union[str, Any]	=     init_cell_selection_weights_to_zero
				A_	:						str	=     reset_position_index_per_cell
				A_	:						List[Any]	=     disable_per_token_loss

				# Aggregation hyperparameters
				A_	:						Optional[int]	=     aggregation_labels
				A_	:						int	=     no_aggregation_label_index

				if isinstance(self.aggregation_labels       ,      lowercase							):
							A_	:						Optional[int]	=     {int(lowercase							): v for k, v in aggregation_labels.items()}




'''simple docstring'''




from collections import deque
from math import floor
from random import random
from time import time







class 	_lowerCAmelCase							:


	def __init__(self							):
				A_	:						int	=     {}


	def     _a	(self       ,      lowercase       ,      lowercase       ,      lowercase=1							):
				if self.graph.get(lowercase							):
							if self.graph[u].count([w, v]							) == 0:
										self.graph[u].append([w, v]							)
				else:
							A_	:						Tuple	=     [[w, v]]
				if not self.graph.get(lowercase							):
							A_	:						Union[str, Any]	=     []


	def     _a	(self							):
				return list(self.graph							)


	def     _a	(self       ,      lowercase       ,      lowercase							):
				if self.graph.get(lowercase							):
							for _ in self.graph[u]:
										if _[1] == v:
													self.graph[u].remove(lowercase							)


	def     _a	(self       ,      lowercase=-2       ,      lowercase=-1							):
				if s == d:
							return []
				A_	:						Union[str, Any]	=     []
				A_	:						Dict	=     []
				if s == -2:
							A_	:						List[Any]	=     list(self.graph							)[0]
				stack.append(lowercase							)
				visited.append(lowercase							)
				A_	:						Any	=     s

				while True:
							# check if there is any non isolated nodes
							if len(self.graph[s]							) != 0:
										A_	:						Tuple	=     s
										for node in self.graph[s]:
													if visited.count(node[1]							) < 1:
																if node[1] == d:
																			visited.append(lowercase							)
																			return visited
																else:
																			stack.append(node[1]							)
																			visited.append(node[1]							)
																			A_	:						List[Any]	=     node[1]
																			break

            # check if all the children are visited
							if s == ss:
										stack.pop()
										if len(lowercase							) != 0:
													A_	:						List[str]	=     stack[len(lowercase							) - 1]
							else:
										A_	:						str	=     ss

							# check if se have reached the starting point
							if len(lowercase							) == 0:
										return visited


	def     _a	(self       ,      lowercase=-1							):
				if c == -1:
							A_	:						Tuple	=     floor(random() * 10000							) + 10
				for i in range(lowercase							):
							# every vertex has max 100 edges
							for _ in range(floor(random() * 102							) + 1							):
										A_	:						List[str]	=     floor(random() * c							) + 1
										if n != i:
													self.add_pair(lowercase       ,      lowercase       ,      1							)


	def     _a	(self       ,      lowercase=-2							):
				A_	:						Union[str, Any]	=     deque()
				A_	:						Tuple	=     []
				if s == -2:
							A_	:						int	=     list(self.graph							)[0]
				d.append(lowercase							)
				visited.append(lowercase							)
				while d:
							A_	:						Any	=     d.popleft()
							if len(self.graph[s]							) != 0:
										for node in self.graph[s]:
													if visited.count(node[1]							) < 1:
																d.append(node[1]							)
																visited.append(node[1]							)
				return visited


	def     _a	(self       ,      lowercase							):
				A_	:						Dict	=     0
				for x in self.graph:
							for y in self.graph[x]:
										if y[1] == u:
													count += 1
				return count


	def     _a	(self       ,      lowercase							):
				return len(self.graph[u]							)


	def     _a	(self       ,      lowercase=-2							):
				A_	:						Dict	=     []
				A_	:						Optional[Any]	=     []
				if s == -2:
							A_	:						int	=     list(self.graph							)[0]
				stack.append(lowercase							)
				visited.append(lowercase							)
				A_	:						Optional[Any]	=     s
				A_	:						int	=     []

				while True:
							# check if there is any non isolated nodes
							if len(self.graph[s]							) != 0:
										A_	:						Optional[int]	=     s
										for node in self.graph[s]:
													if visited.count(node[1]							) < 1:
																stack.append(node[1]							)
																visited.append(node[1]							)
																A_	:						Optional[Any]	=     node[1]
																break

            # check if all the children are visited
							if s == ss:
										sorted_nodes.append(stack.pop()							)
										if len(lowercase							) != 0:
													A_	:						int	=     stack[len(lowercase							) - 1]
							else:
										A_	:						Optional[Any]	=     ss

							# check if se have reached the starting point
							if len(lowercase							) == 0:
										return sorted_nodes


	def     _a	(self							):
				A_	:						Dict	=     []
				A_	:						Tuple	=     []
				A_	:						Any	=     list(self.graph							)[0]
				stack.append(lowercase							)
				visited.append(lowercase							)
				A_	:						Optional[int]	=     -2
				A_	:						List[Any]	=     []
				A_	:						List[str]	=     s
				A_	:						Optional[int]	=     False
				A_	:						Union[str, Any]	=     set()

				while True:
							# check if there is any non isolated nodes
							if len(self.graph[s]							) != 0:
										A_	:						List[Any]	=     s
										for node in self.graph[s]:
													if (
													    visited.count(node[1]							) > 0
													    and node[1] != parent
													    and indirect_parents.count(node[1]							) > 0
													    and not on_the_way_back
													):
																A_	:						Dict	=     len(lowercase							) - 1
																while len_stack >= 0:
																			if stack[len_stack] == node[1]:
																						anticipating_nodes.add(node[1]							)
																						break
																			else:
																						anticipating_nodes.add(stack[len_stack]							)
																						len_stack -= 1
													if visited.count(node[1]							) < 1:
																stack.append(node[1]							)
																visited.append(node[1]							)
																A_	:						List[str]	=     node[1]
																break

            # check if all the children are visited
							if s == ss:
										stack.pop()
										A_	:						str	=     True
										if len(lowercase							) != 0:
													A_	:						Union[str, Any]	=     stack[len(lowercase							) - 1]
							else:
										A_	:						Tuple	=     False
										indirect_parents.append(lowercase							)
										A_	:						Tuple	=     s
										A_	:						Tuple	=     ss

							# check if se have reached the starting point
							if len(lowercase							) == 0:
										return list(lowercase							)


	def     _a	(self							):
				A_	:						Union[str, Any]	=     []
				A_	:						str	=     []
				A_	:						List[Any]	=     list(self.graph							)[0]
				stack.append(lowercase							)
				visited.append(lowercase							)
				A_	:						List[Any]	=     -2
				A_	:						Tuple	=     []
				A_	:						Optional[Any]	=     s
				A_	:						Union[str, Any]	=     False
				A_	:						Optional[Any]	=     set()

				while True:
							# check if there is any non isolated nodes
							if len(self.graph[s]							) != 0:
										A_	:						int	=     s
										for node in self.graph[s]:
													if (
													    visited.count(node[1]							) > 0
													    and node[1] != parent
													    and indirect_parents.count(node[1]							) > 0
													    and not on_the_way_back
													):
																A_	:						Dict	=     len(lowercase							) - 1
																while len_stack_minus_one >= 0:
																			if stack[len_stack_minus_one] == node[1]:
																						anticipating_nodes.add(node[1]							)
																						break
																			else:
																						return True
													if visited.count(node[1]							) < 1:
																stack.append(node[1]							)
																visited.append(node[1]							)
																A_	:						Optional[Any]	=     node[1]
																break

            # check if all the children are visited
							if s == ss:
										stack.pop()
										A_	:						List[str]	=     True
										if len(lowercase							) != 0:
													A_	:						Dict	=     stack[len(lowercase							) - 1]
							else:
										A_	:						int	=     False
										indirect_parents.append(lowercase							)
										A_	:						List[Any]	=     s
										A_	:						int	=     ss

							# check if se have reached the starting point
							if len(lowercase							) == 0:
										return False


	def     _a	(self       ,      lowercase=-2       ,      lowercase=-1							):
				A_	:						str	=     time()
				self.dfs(lowercase       ,      lowercase							)
				A_	:						Any	=     time()
				return end - begin


	def     _a	(self       ,      lowercase=-2							):
				A_	:						Union[str, Any]	=     time()
				self.bfs(lowercase							)
				A_	:						Optional[Any]	=     time()
				return end - begin







class 	_lowerCAmelCase							:


	def __init__(self							):
				A_	:						List[str]	=     {}


	def     _a	(self       ,      lowercase       ,      lowercase       ,      lowercase=1							):
				# check if the u exists
				if self.graph.get(lowercase							):
							# if there already is a edge
							if self.graph[u].count([w, v]							) == 0:
										self.graph[u].append([w, v]							)
				else:
							# if u does not exist
							A_	:						int	=     [[w, v]]
				# add the other way
				if self.graph.get(lowercase							):
							# if there already is a edge
							if self.graph[v].count([w, u]							) == 0:
										self.graph[v].append([w, u]							)
				else:
							# if u does not exist
							A_	:						Any	=     [[w, u]]


	def     _a	(self       ,      lowercase       ,      lowercase							):
				if self.graph.get(lowercase							):
							for _ in self.graph[u]:
										if _[1] == v:
													self.graph[u].remove(lowercase							)
        # the other way round
				if self.graph.get(lowercase							):
							for _ in self.graph[v]:
										if _[1] == u:
													self.graph[v].remove(lowercase							)


	def     _a	(self       ,      lowercase=-2       ,      lowercase=-1							):
				if s == d:
							return []
				A_	:						Dict	=     []
				A_	:						List[Any]	=     []
				if s == -2:
							A_	:						str	=     list(self.graph							)[0]
				stack.append(lowercase							)
				visited.append(lowercase							)
				A_	:						List[str]	=     s

				while True:
							# check if there is any non isolated nodes
							if len(self.graph[s]							) != 0:
										A_	:						Union[str, Any]	=     s
										for node in self.graph[s]:
													if visited.count(node[1]							) < 1:
																if node[1] == d:
																			visited.append(lowercase							)
																			return visited
																else:
																			stack.append(node[1]							)
																			visited.append(node[1]							)
																			A_	:						Optional[Any]	=     node[1]
																			break

            # check if all the children are visited
							if s == ss:
										stack.pop()
										if len(lowercase							) != 0:
													A_	:						Dict	=     stack[len(lowercase							) - 1]
							else:
										A_	:						List[str]	=     ss

							# check if se have reached the starting point
							if len(lowercase							) == 0:
										return visited


	def     _a	(self       ,      lowercase=-1							):
				if c == -1:
							A_	:						Union[str, Any]	=     floor(random() * 10000							) + 10
				for i in range(lowercase							):
							# every vertex has max 100 edges
							for _ in range(floor(random() * 102							) + 1							):
										A_	:						Union[str, Any]	=     floor(random() * c							) + 1
										if n != i:
													self.add_pair(lowercase       ,      lowercase       ,      1							)


	def     _a	(self       ,      lowercase=-2							):
				A_	:						int	=     deque()
				A_	:						Optional[Any]	=     []
				if s == -2:
							A_	:						Optional[int]	=     list(self.graph							)[0]
				d.append(lowercase							)
				visited.append(lowercase							)
				while d:
							A_	:						Union[str, Any]	=     d.popleft()
							if len(self.graph[s]							) != 0:
										for node in self.graph[s]:
													if visited.count(node[1]							) < 1:
																d.append(node[1]							)
																visited.append(node[1]							)
				return visited


	def     _a	(self       ,      lowercase							):
				return len(self.graph[u]							)


	def     _a	(self							):
				A_	:						Optional[int]	=     []
				A_	:						Dict	=     []
				A_	:						Union[str, Any]	=     list(self.graph							)[0]
				stack.append(lowercase							)
				visited.append(lowercase							)
				A_	:						List[Any]	=     -2
				A_	:						List[str]	=     []
				A_	:						int	=     s
				A_	:						Optional[int]	=     False
				A_	:						Any	=     set()

				while True:
							# check if there is any non isolated nodes
							if len(self.graph[s]							) != 0:
										A_	:						Tuple	=     s
										for node in self.graph[s]:
													if (
													    visited.count(node[1]							) > 0
													    and node[1] != parent
													    and indirect_parents.count(node[1]							) > 0
													    and not on_the_way_back
													):
																A_	:						int	=     len(lowercase							) - 1
																while len_stack >= 0:
																			if stack[len_stack] == node[1]:
																						anticipating_nodes.add(node[1]							)
																						break
																			else:
																						anticipating_nodes.add(stack[len_stack]							)
																						len_stack -= 1
													if visited.count(node[1]							) < 1:
																stack.append(node[1]							)
																visited.append(node[1]							)
																A_	:						Tuple	=     node[1]
																break

            # check if all the children are visited
							if s == ss:
										stack.pop()
										A_	:						str	=     True
										if len(lowercase							) != 0:
													A_	:						Any	=     stack[len(lowercase							) - 1]
							else:
										A_	:						str	=     False
										indirect_parents.append(lowercase							)
										A_	:						Dict	=     s
										A_	:						List[Any]	=     ss

							# check if se have reached the starting point
							if len(lowercase							) == 0:
										return list(lowercase							)


	def     _a	(self							):
				A_	:						Optional[int]	=     []
				A_	:						Optional[int]	=     []
				A_	:						List[str]	=     list(self.graph							)[0]
				stack.append(lowercase							)
				visited.append(lowercase							)
				A_	:						Any	=     -2
				A_	:						Any	=     []
				A_	:						Tuple	=     s
				A_	:						str	=     False
				A_	:						str	=     set()

				while True:
							# check if there is any non isolated nodes
							if len(self.graph[s]							) != 0:
										A_	:						Dict	=     s
										for node in self.graph[s]:
													if (
													    visited.count(node[1]							) > 0
													    and node[1] != parent
													    and indirect_parents.count(node[1]							) > 0
													    and not on_the_way_back
													):
																A_	:						Any	=     len(lowercase							) - 1
																while len_stack_minus_one >= 0:
																			if stack[len_stack_minus_one] == node[1]:
																						anticipating_nodes.add(node[1]							)
																						break
																			else:
																						return True
													if visited.count(node[1]							) < 1:
																stack.append(node[1]							)
																visited.append(node[1]							)
																A_	:						Optional[Any]	=     node[1]
																break

            # check if all the children are visited
							if s == ss:
										stack.pop()
										A_	:						Union[str, Any]	=     True
										if len(lowercase							) != 0:
													A_	:						List[Any]	=     stack[len(lowercase							) - 1]
							else:
										A_	:						int	=     False
										indirect_parents.append(lowercase							)
										A_	:						int	=     s
										A_	:						int	=     ss

							# check if se have reached the starting point
							if len(lowercase							) == 0:
										return False


	def     _a	(self							):
				return list(self.graph							)


	def     _a	(self       ,      lowercase=-2       ,      lowercase=-1							):
				A_	:						Any	=     time()
				self.dfs(lowercase       ,      lowercase							)
				A_	:						Optional[Any]	=     time()
				return end - begin


	def     _a	(self       ,      lowercase=-2							):
				A_	:						List[Any]	=     time()
				self.bfs(lowercase							)
				A_	:						List[Any]	=     time()
				return end - begin