





from __future__ import annotations

from queue import Queue





def 						__SCREAMING_SNAKE_CASE  (    UpperCamelCase__      ,      UpperCamelCase__			)  ->    tuple[int, int]:







					'''simple docstring'''

					a ^= b
					b ^= a
					a ^= b
					return a, b





def 						__SCREAMING_SNAKE_CASE  (    UpperCamelCase__      ,      UpperCamelCase__			)  ->    list[list[int]]:







					'''simple docstring'''

					UpperCAmelCase       		=    1
					while (1 << j) < max_node:
										for i in range(1      ,      max_node + 1			):
															UpperCAmelCase       		=    parent[j - 1][parent[j - 1][i]]
										j += 1
					return parent





def 						__SCREAMING_SNAKE_CASE  (    UpperCamelCase__      ,      UpperCamelCase__      ,      UpperCamelCase__      ,      UpperCamelCase__			)  ->    int:







					'''simple docstring'''

					if level[u] < level[v]:
										UpperCAmelCase		,      UpperCAmelCase       		=    swap(SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_			)
					# making depth of u same as depth of v
					for i in range(18      ,      -1      ,      -1			):
										if level[u] - (1 << i) >= level[v]:
															UpperCAmelCase       		=    parent[i][u]
    # at the same depth if u==v that mean lca is found
					if u == v:
										return u
					# moving both nodes upwards till lca in found
					for i in range(18      ,      -1      ,      -1			):
										if parent[i][u] not in [0, parent[i][v]]:
															UpperCAmelCase		,      UpperCAmelCase       		=    parent[i][u], parent[i][v]
    # returning longest common ancestor of u,v
					return parent[0][u]





def 						__SCREAMING_SNAKE_CASE  (    UpperCamelCase__      ,      UpperCamelCase__      ,      UpperCamelCase__      ,      UpperCamelCase__      ,      UpperCamelCase__ = 1      ,      )  ->    tuple[list[int], list[list[int]]]:







					'''simple docstring'''

					UpperCAmelCase       		=    0
					UpperCAmelCase       		=    Queue(maxsize=SCREAMING_SNAKE_CASE_			)
					q.put(SCREAMING_SNAKE_CASE_			)
					while q.qsize() != 0:
										UpperCAmelCase       		=    q.get()
										for v in graph[u]:
															if level[v] == -1:
																				UpperCAmelCase       		=    level[u] + 1
																				q.put(SCREAMING_SNAKE_CASE_			)
																				UpperCAmelCase       		=    u
					return level, parent





def 						__SCREAMING_SNAKE_CASE  (    )  ->    None:







					'''simple docstring'''

					UpperCAmelCase       		=    13
					# initializing with 0
					UpperCAmelCase       		=    [[0 for _ in range(max_node + 10			)] for _ in range(20			)]
					# initializing with -1 which means every node is unvisited
					UpperCAmelCase       		=    [-1 for _ in range(max_node + 10			)]
					UpperCAmelCase       		=    {
					    1: [2, 3, 4],
					    2: [5],
					    3: [6, 7],
					    4: [8],
					    5: [9, 10],
					    6: [11],
					    7: [],
					    8: [12, 13],
					    9: [],
					    10: [],
					    11: [],
					    12: [],
					    13: [],
					}
					UpperCAmelCase		,      UpperCAmelCase       		=    breadth_first_search(SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      1			)
					UpperCAmelCase       		=    create_sparse(SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_			)
					print('''LCA of node 1 and 3 is: '''      ,      lowest_common_ancestor(1      ,      3      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_			)			)
					print('''LCA of node 5 and 6 is: '''      ,      lowest_common_ancestor(5      ,      6      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_			)			)
					print('''LCA of node 7 and 11 is: '''      ,      lowest_common_ancestor(7      ,      11      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_			)			)
					print('''LCA of node 6 and 7 is: '''      ,      lowest_common_ancestor(6      ,      7      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_			)			)
					print('''LCA of node 4 and 12 is: '''      ,      lowest_common_ancestor(4      ,      12      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_			)			)
					print('''LCA of node 8 and 8 is: '''      ,      lowest_common_ancestor(8      ,      8      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_			)			)


if __name__ == "__main__":
				main()










import json
import os
import tempfile
import unittest

from transformers.modelcard import ModelCard

class      A_	(unittest.TestCase      ):
	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    {
				    '''model_details''': {
				        '''Organization''': '''testing''',
				        '''Model date''': '''today''',
				        '''Model version''': '''v2.1, Developed by Test Corp in 2019.''',
				        '''Architecture''': '''Convolutional Neural Network.''',
				    },
				    '''metrics''': '''BLEU and ROUGE-1''',
				    '''evaluation_data''': {
				        '''Datasets''': {'''BLEU''': '''My-great-dataset-v1''', '''ROUGE-1''': '''My-short-dataset-v2.1'''},
				        '''Preprocessing''': '''See details on https://arxiv.org/pdf/1810.03993.pdf''',
				    },
				    '''training_data''': {
				        '''Dataset''': '''English Wikipedia dump dated 2018-12-01''',
				        '''Preprocessing''': (
				            '''Using SentencePiece vocabulary of size 52k tokens. See details on'''
				            ''' https://arxiv.org/pdf/1810.03993.pdf'''
				        ),
				    },
				    '''quantitative_analyses''': {'''BLEU''': 55.1, '''ROUGE-1''': 7_6},
				}
	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    ModelCard.from_dict(self.inputs_dict		)
				self.assertTrue(hasattr(_A							, '''model_details'''		)		)
				self.assertTrue(hasattr(_A							, '''intended_use'''		)		)
				self.assertTrue(hasattr(_A							, '''factors'''		)		)
				self.assertTrue(hasattr(_A							, '''metrics'''		)		)
				self.assertTrue(hasattr(_A							, '''evaluation_data'''		)		)
				self.assertTrue(hasattr(_A							, '''training_data'''		)		)
				self.assertTrue(hasattr(_A							, '''quantitative_analyses'''		)		)
				self.assertTrue(hasattr(_A							, '''ethical_considerations'''		)		)
				self.assertTrue(hasattr(_A							, '''caveats_and_recommendations'''		)		)
	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    ModelCard.from_dict(self.inputs_dict		)
				UpperCAmelCase       		=    json.loads(modelcard.to_json_string()		)
				for key, value in self.inputs_dict.items():
							self.assertEqual(obj[key]							, _A		)
	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    ModelCard.from_dict(self.inputs_dict		)

				with tempfile.TemporaryDirectory() as tmpdirname:
							UpperCAmelCase       		=    os.path.join(_A							, '''modelcard.json'''		)
							model_card_first.to_json_file(_A		)
							UpperCAmelCase       		=    ModelCard.from_json_file(_A		)

				self.assertEqual(model_card_second.to_dict()							, model_card_first.to_dict()		)







	def 					_lowercase    (   self		):






				'''simple docstring'''







				UpperCAmelCase       		=    ModelCard.from_dict(self.inputs_dict		)

				with tempfile.TemporaryDirectory() as tmpdirname:
							model_card_first.save_pretrained(_A		)
							UpperCAmelCase       		=    ModelCard.from_pretrained(_A		)

				self.assertEqual(model_card_second.to_dict()							, model_card_first.to_dict()		)



