





"""simple docstring"""



a_				=    [
    ["""ab-e1""", """ac-e3""", """ad-e5""", """bc-e4""", """bd-e2""", """be-e6""", """bh-e12""", """cd-e2""", """ce-e4""",
     """de-e1""", """df-e8""", """dg-e5""", """dh-e10""", """ef-e3""", """eg-e2""", """fg-e6""", """gh-e6""", """hi-e3"""],
    ["""ab-e1""", """ac-e3""", """ad-e5""", """bc-e4""", """bd-e2""", """be-e6""", """cd-e2""", """de-e1""", """df-e8""",
     """ef-e3""", """eg-e2""", """fg-e6"""],
    ["""ab-e1""", """ac-e3""", """bc-e4""", """bd-e2""", """de-e1""", """df-e8""", """dg-e5""", """ef-e3""", """eg-e2""",
     """eh-e12""", """fg-e6""", """fh-e10""", """gh-e6"""],
    ["""ab-e1""", """ac-e3""", """bc-e4""", """bd-e2""", """bh-e12""", """cd-e2""", """df-e8""", """dh-e10"""],
    ["""ab-e1""", """ac-e3""", """ad-e5""", """bc-e4""", """bd-e2""", """cd-e2""", """ce-e4""", """de-e1""", """df-e8""",
     """dg-e5""", """ef-e3""", """eg-e2""", """fg-e6"""]
]







def 	__lowercase  (     snake_case_						:						Union[str, Any]		)     ->Dict:



				'''simple docstring'''







				__A					:		int						=  set()
				for row in edge_array:
								for item in row:
												distinct_edge.add(item[0]		)
				return list(snake_case_		)







def 	__lowercase  (     snake_case_						:						str       ,snake_case_						:						Optional[int]		)     ->Optional[int]:



				'''simple docstring'''







				__A					:		Union[str, Any]						=  ['''0'''] * len(snake_case_		)
				for i, row in enumerate(snake_case_		):
								for item in row:
												if distinct_edge in item[0]:
																__A					:		Tuple						=  '''1'''
																break
				return "".join(snake_case_		)







def 	__lowercase  (     snake_case_						:						Dict		)     ->Tuple:



				'''simple docstring'''







				__A					:		Any						=  get_distinct_edge(snake_case_		)
				__A					:		Optional[Any]						=  {}

				for item in distinct_edge:
								__A					:		Union[str, Any]						=  get_bitcode(snake_case_       ,snake_case_		)
								# print('bit',bit)
								# bt=''.join(bit)
								__A					:		int						=  bit.count('''1'''		)
								__A					:		Union[str, Any]						=  [s, bit]
				# Store [Distinct edge, WT(Bitcode), Bitcode] in descending order
				__A					:		List[str]						=  [
				    [k, v[0], v[1]]
				    for k, v in sorted(frequency_table.items()       ,key=lambda snake_case_		: v[1][0]       ,reverse=snake_case_		)
				]
				return sorted_frequency_table







def 	__lowercase  (     snake_case_						:						List[str]		)     ->List[Any]:



				'''simple docstring'''







				__A					:		List[Any]						=  {}
				for _, item in enumerate(snake_case_		):
								nodes.setdefault(item[2]       ,[]		).append(item[0]		)
				return nodes







def 	__lowercase  (     snake_case_						:						Any		)     ->Tuple:



				'''simple docstring'''







				__A					:		Tuple						=  {}
				for key, value in nodes.items():
								__A					:		List[Any]						=  value
				return cluster







def 	__lowercase  (     snake_case_						:						List[Any]		)     ->Optional[int]:



				'''simple docstring'''







				return [i * 100 / len(snake_case_		) for i in cluster]







def 	__lowercase  (     )     ->None:



				'''simple docstring'''







				print('''\nNodes\n'''		)
				for key, value in nodes.items():
								print(snake_case_       ,snake_case_		)
				print('''\nSupport\n'''		)
				print(snake_case_		)
				print('''\n Cluster \n'''		)
				for key, value in sorted(cluster.items()       ,reverse=snake_case_		):
								print(snake_case_       ,snake_case_		)
				print('''\n Graph\n'''		)
				for key, value in graph.items():
								print(snake_case_       ,snake_case_		)
				print('''\n Edge List of Frequent subgraphs \n'''		)
				for edge_list in freq_subgraph_edge_list:
								print(snake_case_		)







def 	__lowercase  (     snake_case_						:						Optional[Any]       ,snake_case_						:						List[str]       ,snake_case_						:						Tuple       ,snake_case_						:						Optional[Any]		)     ->Optional[int]:



				'''simple docstring'''







				for i in cluster[ca]:
								__A					:		Tuple						=  0
								__A					:		Union[str, Any]						=  ca + 1
								while ca < max(cluster.keys()		):
												for j in cluster[ca]:
																if int(snake_case_       ,2		) & int(snake_case_       ,2		) == int(snake_case_       ,2		):
																				if tuple(nodes[i]		) in graph:
																								graph[tuple(nodes[i]		)].append(nodes[j]		)
																				else:
																								__A					:		Any						=  [nodes[j]]
																				count += 1
												if count == 0:
																__A					:		List[Any]						=  ca + 1
												else:
																break







def 	__lowercase  (     snake_case_						:						Tuple       ,snake_case_						:						List[Any]		)     ->int:



				'''simple docstring'''







				__A					:		List[Any]						=  cluster[max(cluster.keys()		)]
				__A					:		List[str]						=  '''Header'''
				__A					:		Any						=  {}
				for i in x:
								if (["Header"],) in graph:
												graph[(["Header"],)].append(x[i]		)
								else:
												__A					:		Optional[int]						=  [x[i]]
				for i in x:
								__A					:		Union[str, Any]						=  [['''Header''']]
				__A					:		Any						=  1
				while i < max(snake_case_		) - 1:
								create_edge(snake_case_       ,snake_case_       ,snake_case_       ,snake_case_		)
								__A					:		Any						=  i + 1
				return graph







def 	__lowercase  (     snake_case_						:						List[str]       ,snake_case_						:						str       ,snake_case_						:						Tuple       ,snake_case_						:						Any=None		)     ->Optional[int]:



				'''simple docstring'''







				__A					:		List[str]						=  (path or []) + [start]
				if start == end:
								paths.append(snake_case_		)
				for node in graph[start]:
								if tuple(snake_case_		) not in path:
												my_dfs(snake_case_       ,tuple(snake_case_		)       ,snake_case_       ,snake_case_		)







def 	__lowercase  (     snake_case_						:						Dict       ,snake_case_						:						Union[str, Any]       ,snake_case_						:						Optional[int]		)     ->str:



				'''simple docstring'''







				__A					:		List[str]						=  int(s / 100 * (len(snake_case_		) - 1)		)
				for i in cluster[k]:
								my_dfs(snake_case_       ,tuple(cluster[k][i]		)       ,(['''Header'''],)		)







def 	__lowercase  (     snake_case_						:						Dict		)     ->Dict:



				'''simple docstring'''







				__A					:		Optional[Any]						=  []
				for edges in paths:
								__A					:		List[Any]						=  []
								for j in range(len(snake_case_		) - 1		):
												__A					:		Union[str, Any]						=  list(edges[j]		)
												for e in temp:
																__A					:		Optional[Any]						=  (e[0], e[1])
																el.append(snake_case_		)
								freq_sub_el.append(snake_case_		)
				return freq_sub_el







def 	__lowercase  (     snake_case_						:						Any		)     ->Any:



				'''simple docstring'''







				for i in range(len(snake_case_		)		):
								for j in range(len(edge_array[i]		)		):
												__A					:		Optional[Any]						=  edge_array[i][j].split('''-'''		)
												__A					:		Optional[int]						=  t


if __name__ == "__main__":
							preprocess(edge_array)
							a_				=    get_frequency_table(edge_array)
							a_				=    get_nodes(frequency_table)
							a_				=    get_cluster(nodes)
							a_				=    get_support(cluster)
							a_				=    construct_graph(cluster, nodes)
							find_freq_subgraph_given_support(60, cluster, graph)
							a_				=    []
							a_				=    freq_subgraphs_edge_list(paths)
							print_all()











"""simple docstring"""



import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs


if is_torch_available():
       import torch

if is_vision_available():
       from PIL import Image

       from transformers import VideoMAEImageProcessor






class 	__snake_case      (	unittest.TestCase  ):





 """simple docstring"""


 def __init__(					self      ,		__lowerCamelCase      ,		__lowerCamelCase=7      ,		__lowerCamelCase=3      ,		__lowerCamelCase=10      ,		__lowerCamelCase=18      ,		__lowerCamelCase=30      ,		__lowerCamelCase=400      ,		__lowerCamelCase=True      ,		__lowerCamelCase=None      ,		__lowerCamelCase=True      ,		__lowerCamelCase=[0.5, 0.5, 0.5]      ,		__lowerCamelCase=[0.5, 0.5, 0.5]      ,		__lowerCamelCase=None      ,		):



     '''simple docstring'''




     __A					:		Optional[Any]						=  size if size is not None else {'''shortest_edge''': 18}
     __A					:		Optional[int]						=  crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}

     __A					:		Any						=  parent
     __A					:		Union[str, Any]						=  batch_size
     __A					:		Optional[int]						=  num_channels
     __A					:		int						=  num_frames
     __A					:		Optional[int]						=  image_size
     __A					:		Union[str, Any]						=  min_resolution
     __A					:		int						=  max_resolution
     __A					:		Tuple						=  do_resize
     __A					:		str						=  size
     __A					:		Any						=  do_normalize
     __A					:		Union[str, Any]						=  image_mean
     __A					:		List[str]						=  image_std
     __A					:		Union[str, Any]						=  crop_size







 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     return {
         "image_mean": self.image_mean,
         "image_std": self.image_std,
         "do_normalize": self.do_normalize,
         "do_resize": self.do_resize,
         "size": self.size,
         "crop_size": self.crop_size,
     }






@require_torch
@require_vision
class 	__snake_case      (	SCREAMING_SNAKE_CASE__							,							unittest.TestCase  ):





 """simple docstring"""


 _lowerCamelCase				 =  VideoMAEImageProcessor if is_vision_available() else None

 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     __A					:		List[str]						=  VideoMAEImageProcessingTester(self						)

 @property
 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     return self.image_processor_tester.prepare_image_processor_dict()

 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     __A					:		Dict						=  self.image_processing_class(**self.image_processor_dict						)
     self.assertTrue(hasattr(__lowerCamelCase      ,		'''image_mean'''						)						)
     self.assertTrue(hasattr(__lowerCamelCase      ,		'''image_std'''						)						)
     self.assertTrue(hasattr(__lowerCamelCase      ,		'''do_normalize'''						)						)
     self.assertTrue(hasattr(__lowerCamelCase      ,		'''do_resize'''						)						)
     self.assertTrue(hasattr(__lowerCamelCase      ,		'''do_center_crop'''						)						)
     self.assertTrue(hasattr(__lowerCamelCase      ,		'''size'''						)						)

 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     __A					:		Optional[int]						=  self.image_processing_class.from_dict(self.image_processor_dict						)
     self.assertEqual(image_processor.size      ,		{'''shortest_edge''': 18}						)
     self.assertEqual(image_processor.crop_size      ,		{'''height''': 18, '''width''': 18}						)

     __A					:		Dict						=  self.image_processing_class.from_dict(self.image_processor_dict      ,		size=42      ,		crop_size=84						)
     self.assertEqual(image_processor.size      ,		{'''shortest_edge''': 42}						)
     self.assertEqual(image_processor.crop_size      ,		{'''height''': 84, '''width''': 84}						)

 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     pass

 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     __A					:		List[Any]						=  self.image_processing_class(**self.image_processor_dict						)
     # create random PIL videos
     __A					:		Optional[int]						=  prepare_video_inputs(self.image_processor_tester      ,		equal_resolution=__lowerCamelCase						)
     for video in video_inputs:
         self.assertIsInstance(__lowerCamelCase      ,		__lowerCamelCase						)
         self.assertIsInstance(video[0]      ,		Image.Image						)

     # Test not batched input
     __A					:		Any						=  image_processing(video_inputs[0]      ,		return_tensors='''pt'''						).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,		(
             1,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['''height'''],
             self.image_processor_tester.crop_size['''width'''],
         )      ,		)

     # Test batched
     __A					:		int						=  image_processing(__lowerCamelCase      ,		return_tensors='''pt'''						).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,		(
             self.image_processor_tester.batch_size,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['''height'''],
             self.image_processor_tester.crop_size['''width'''],
         )      ,		)

 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     __A					:		List[Any]						=  self.image_processing_class(**self.image_processor_dict						)
     # create random numpy tensors
     __A					:		List[str]						=  prepare_video_inputs(self.image_processor_tester      ,		equal_resolution=__lowerCamelCase      ,		numpify=__lowerCamelCase						)
     for video in video_inputs:
         self.assertIsInstance(__lowerCamelCase      ,		__lowerCamelCase						)
         self.assertIsInstance(video[0]      ,		np.ndarray						)

     # Test not batched input
     __A					:		List[str]						=  image_processing(video_inputs[0]      ,		return_tensors='''pt'''						).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,		(
             1,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['''height'''],
             self.image_processor_tester.crop_size['''width'''],
         )      ,		)

     # Test batched
     __A					:		int						=  image_processing(__lowerCamelCase      ,		return_tensors='''pt'''						).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,		(
             self.image_processor_tester.batch_size,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['''height'''],
             self.image_processor_tester.crop_size['''width'''],
         )      ,		)







 def       UpperCamelCase__(					self						):



     '''simple docstring'''




     __A					:		Optional[int]						=  self.image_processing_class(**self.image_processor_dict						)
     # create random PyTorch tensors
     __A					:		int						=  prepare_video_inputs(self.image_processor_tester      ,		equal_resolution=__lowerCamelCase      ,		torchify=__lowerCamelCase						)
     for video in video_inputs:
         self.assertIsInstance(__lowerCamelCase      ,		__lowerCamelCase						)
         self.assertIsInstance(video[0]      ,		torch.Tensor						)

     # Test not batched input
     __A					:		Optional[int]						=  image_processing(video_inputs[0]      ,		return_tensors='''pt'''						).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,		(
             1,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['''height'''],
             self.image_processor_tester.crop_size['''width'''],
         )      ,		)

     # Test batched
     __A					:		str						=  image_processing(__lowerCamelCase      ,		return_tensors='''pt'''						).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,		(
             self.image_processor_tester.batch_size,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['''height'''],
             self.image_processor_tester.crop_size['''width'''],
         )      ,		)




