


import argparse
import copy
def       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				{}

		with open(SCREAMING_SNAKE_CASE					) as f:
				for line in f:
						if line.split()[0] not in dict_of_neighbours:
								lowercase__						=				[]
								_list.append([line.split()[1], line.split()[2]]					)
								lowercase__						=				_list
						else:
								dict_of_neighbours[line.split()[0]].append(
								    [line.split()[1], line.split()[2]]					)
						if line.split()[1] not in dict_of_neighbours:
								lowercase__						=				[]
								_list.append([line.split()[0], line.split()[2]]					)
								lowercase__						=				_list
						else:
								dict_of_neighbours[line.split()[1]].append(
								    [line.split()[0], line.split()[2]]					)

		return dict_of_neighbours
def       _a			(				SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		with open(SCREAMING_SNAKE_CASE					) as f:
				lowercase__						=				f.read(1					)
		lowercase__						=				start_node

		lowercase__						=				[]

		lowercase__						=				start_node

		lowercase__						=				0
		while visiting not in first_solution:
				lowercase__						=				1_00_00
				for k in dict_of_neighbours[visiting]:
						if int(k[1]					) < int(SCREAMING_SNAKE_CASE					) and k[0] not in first_solution:
								lowercase__						=				k[1]
								lowercase__						=				k[0]

				first_solution.append(SCREAMING_SNAKE_CASE					)
				lowercase__						=				distance_of_first_solution + int(SCREAMING_SNAKE_CASE					)
				lowercase__						=				best_node

		first_solution.append(SCREAMING_SNAKE_CASE					)

		lowercase__						=				0
		for k in dict_of_neighbours[first_solution[-2]]:
				if k[0] == start_node:
						break
				position += 1

		lowercase__						=				(
		    distance_of_first_solution
		    + int(dict_of_neighbours[first_solution[-2]][position][1]					)
		    - 1_00_00
		)
		return first_solution, distance_of_first_solution
def       _a			(				SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				[]

		for n in solution[1:-1]:
				lowercase__						=				solution.index(SCREAMING_SNAKE_CASE					)
				for kn in solution[1:-1]:
						lowercase__						=				solution.index(SCREAMING_SNAKE_CASE					)
						if n == kn:
								continue

						lowercase__						=				copy.deepcopy(SCREAMING_SNAKE_CASE					)
						lowercase__						=				kn
						lowercase__						=				n

						lowercase__						=				0

						for k in _tmp[:-1]:
								lowercase__						=				_tmp[_tmp.index(SCREAMING_SNAKE_CASE					) + 1]
								for i in dict_of_neighbours[k]:
										if i[0] == next_node:
												lowercase__						=				distance + int(i[1]					)
						_tmp.append(SCREAMING_SNAKE_CASE					)

						if _tmp not in neighborhood_of_solution:
								neighborhood_of_solution.append(_tmp					)

		lowercase__						=				len(neighborhood_of_solution[0]					) - 1

		neighborhood_of_solution.sort(key=lambda SCREAMING_SNAKE_CASE					: x[index_of_last_item_in_the_list]					)
		return neighborhood_of_solution
def       _a			(				SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				1
		lowercase__						=				first_solution
		lowercase__						=				[]
		lowercase__						=				distance_of_first_solution
		lowercase__						=				solution

		while count <= iters:
				lowercase__						=				find_neighborhood(SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE					)
				lowercase__						=				0
				lowercase__						=				neighborhood[index_of_best_solution]
				lowercase__						=				len(SCREAMING_SNAKE_CASE					) - 1

				lowercase__						=				False
				while not found:
						lowercase__						=				0
						while i < len(SCREAMING_SNAKE_CASE					):
								if best_solution[i] != solution[i]:
										lowercase__						=				best_solution[i]
										lowercase__						=				solution[i]
										break
								lowercase__						=				i + 1

						if [first_exchange_node, second_exchange_node] not in tabu_list and [
						    second_exchange_node,
						    first_exchange_node,
						] not in tabu_list:
								tabu_list.append([first_exchange_node, second_exchange_node]					)
								lowercase__						=				True
								lowercase__						=				best_solution[:-1]
								lowercase__						=				neighborhood[index_of_best_solution][best_cost_index]
								if cost < best_cost:
										lowercase__						=				cost
										lowercase__						=				solution
						else:
								lowercase__						=				index_of_best_solution + 1
								lowercase__						=				neighborhood[index_of_best_solution]

				if len(SCREAMING_SNAKE_CASE					) >= size:
						tabu_list.pop(0					)

				lowercase__						=				count + 1

		return best_solution_ever, best_cost
def       _a			(				SCREAMING_SNAKE_CASE=None					):


		"""simple docstring"""




		lowercase__						=				generate_neighbours(args.File					)

		lowercase__					,		lowercase__						=				generate_first_solution(
		    args.File						,    SCREAMING_SNAKE_CASE					)

		lowercase__					,		lowercase__						=				tabu_search(
		    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    args.Iterations						,    args.Size						,    )

		print(f'Best solution: {best_sol}, with total distance: {best_cost}.'					)


if __name__ == "__main__":
			lowerCAmelCase	=							argparse.ArgumentParser(description='Tabu Search')
			parser.add_argument(
			    '-f',
			    '--File',
			    type=str,
			    help='Path to the file containing the data',
			    required=True,
			)
			parser.add_argument(
			    '-i',
			    '--Iterations',
			    type=int,
			    help='How many iterations the algorithm should perform',
			    required=True,
			)
			parser.add_argument(
			    '-s', '--Size', type=int, help='Size of the tabu list', required=True
			)

			# Pass the arguments to main method
			main(parser.parse_args())






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


lowerCAmelCase	=							logging.get_logger(__name__)

lowerCAmelCase	=							{
    'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json',
}


class 	_a							(      UpperCamelCase__      ):
							_lowercase     :      List[Any]  				=			'''lxmert'''
							_lowercase     :      Any  				=			{}

							def __init__(							self:     Any   ,						UpperCamelCase_:     List[Any]=30_522   ,						UpperCamelCase_:     int=768   ,						UpperCamelCase_:     Optional[Any]=12   ,						UpperCamelCase_:     Dict=9_500   ,						UpperCamelCase_:     List[Any]=1_600   ,						UpperCamelCase_:     List[Any]=400   ,						UpperCamelCase_:     List[str]=3_072   ,						UpperCamelCase_:     int="gelu"   ,						UpperCamelCase_:     Any=0.1   ,						UpperCamelCase_:     int=0.1   ,						UpperCamelCase_:     List[str]=512   ,						UpperCamelCase_:     Optional[int]=2   ,						UpperCamelCase_:     Union[str, Any]=0.02   ,						UpperCamelCase_:     Dict=1E-1_2   ,						UpperCamelCase_:     List[Any]=9   ,						UpperCamelCase_:     List[Any]=5   ,						UpperCamelCase_:     Optional[Any]=5   ,						UpperCamelCase_:     str=2_048   ,						UpperCamelCase_:     Dict=4   ,						UpperCamelCase_:     Any=6.67   ,						UpperCamelCase_:     Dict=True   ,						UpperCamelCase_:     List[str]=True   ,						UpperCamelCase_:     Dict=True   ,						UpperCamelCase_:     Any=True   ,						UpperCamelCase_:     Tuple=True   ,						UpperCamelCase_:     Optional[Any]=True   ,						UpperCamelCase_:     Any=True   ,						**UpperCamelCase_:     Union[str, Any]   ,						)      ->       Union[str, Any]:





									"""simple docstring"""







									lowercase__						=				vocab_size
									lowercase__						=				hidden_size
									lowercase__						=				num_attention_heads
									lowercase__						=				hidden_act
									lowercase__						=				intermediate_size
									lowercase__						=				hidden_dropout_prob
									lowercase__						=				attention_probs_dropout_prob
									lowercase__						=				max_position_embeddings
									lowercase__						=				type_vocab_size
									lowercase__						=				initializer_range
									lowercase__						=				layer_norm_eps
									lowercase__						=				num_qa_labels
									lowercase__						=				num_object_labels
									lowercase__						=				num_attr_labels
									lowercase__						=				l_layers
									lowercase__						=				x_layers
									lowercase__						=				r_layers
									lowercase__						=				visual_feat_dim
									lowercase__						=				visual_pos_dim
									lowercase__						=				visual_loss_normalizer
									lowercase__						=				task_matched
									lowercase__						=				task_mask_lm
									lowercase__						=				task_obj_predict
									lowercase__						=				task_qa
									lowercase__						=				visual_obj_loss
									lowercase__						=				visual_attr_loss
									lowercase__						=				visual_feat_loss
									lowercase__						=				{'''vision''': r_layers, '''cross_encoder''': x_layers, '''language''': l_layers}
									super().__init__(**UpperCamelCase_							)


