



_lowercase				:					Tuple     					=[
    ["""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    UpperCAmelCase					(  lowercase__						:					Union[str, Any]	):



			'''simple docstring'''





			a__					=  set()
			for row in edge_array:
						for item in row:
									distinct_edge.add(item[0]	)
			return list(_SCREAMING_SNAKE_CASE	)




def    UpperCAmelCase					(  lowercase__						:					List[str]				,					lowercase__						:					Dict	):



			'''simple docstring'''





			a__					=  ["""0"""] * len(_SCREAMING_SNAKE_CASE	)
			for i, row in enumerate(_SCREAMING_SNAKE_CASE	):
						for item in row:
									if distinct_edge in item[0]:
												a__					=  """1"""
												break
			return "".join(_SCREAMING_SNAKE_CASE	)




def    UpperCAmelCase					(  lowercase__						:					Dict	):



			'''simple docstring'''





			a__					=  get_distinct_edge(_SCREAMING_SNAKE_CASE	)
			a__					=  {}

			for item in distinct_edge:
						a__					=  get_bitcode(_SCREAMING_SNAKE_CASE				,					_SCREAMING_SNAKE_CASE	)
						# print('bit',bit)
						# bt=''.join(bit)
						a__					=  bit.count("""1"""	)
						a__					=  [s, bit]
			# Store [Distinct edge, WT(Bitcode), Bitcode] in descending order
			a__					=  [
			    [k, v[0], v[1]]
			    for k, v in sorted(frequency_table.items()				,					key=lambda lowercase__	: v[1][0]				,					reverse=_SCREAMING_SNAKE_CASE	)
			]
			return sorted_frequency_table




def    UpperCAmelCase					(  lowercase__						:					str	):



			'''simple docstring'''





			a__					=  {}
			for _, item in enumerate(_SCREAMING_SNAKE_CASE	):
						nodes.setdefault(item[2]				,					[]	).append(item[0]	)
			return nodes




def    UpperCAmelCase					(  lowercase__						:					int	):



			'''simple docstring'''





			a__					=  {}
			for key, value in nodes.items():
						a__					=  value
			return cluster




def    UpperCAmelCase					(  lowercase__						:					Tuple	):



			'''simple docstring'''





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




def    UpperCAmelCase					(  ):



			'''simple docstring'''





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




def    UpperCAmelCase					(  lowercase__						:					str				,					lowercase__						:					Tuple				,					lowercase__						:					Tuple				,					lowercase__						:					Any	):



			'''simple docstring'''





			for i in cluster[ca]:
						a__					=  0
						a__					=  ca + 1
						while ca < max(cluster.keys()	):
									for j in cluster[ca]:
												if int(_SCREAMING_SNAKE_CASE				,					2	) & int(_SCREAMING_SNAKE_CASE				,					2	) == int(_SCREAMING_SNAKE_CASE				,					2	):
															if tuple(nodes[i]	) in graph:
																		graph[tuple(nodes[i]	)].append(nodes[j]	)
															else:
																		a__					=  [nodes[j]]
															count += 1
									if count == 0:
												a__					=  ca + 1
									else:
												break




def    UpperCAmelCase					(  lowercase__						:					int				,					lowercase__						:					Dict	):



			'''simple docstring'''





			a__					=  cluster[max(cluster.keys()	)]
			a__					=  """Header"""
			a__					=  {}
			for i in x:
						if (["Header"],) in graph:
									graph[(["Header"],)].append(x[i]	)
						else:
									a__					=  [x[i]]
			for i in x:
						a__					=  [["""Header"""]]
			a__					=  1
			while i < max(_SCREAMING_SNAKE_CASE	) - 1:
						create_edge(_SCREAMING_SNAKE_CASE				,					_SCREAMING_SNAKE_CASE				,					_SCREAMING_SNAKE_CASE				,					_SCREAMING_SNAKE_CASE	)
						a__					=  i + 1
			return graph




def    UpperCAmelCase					(  lowercase__						:					Any				,					lowercase__						:					Union[str, Any]				,					lowercase__						:					int				,					lowercase__						:					str=None	):



			'''simple docstring'''





			a__					=  (path or []) + [start]
			if start == end:
						paths.append(_SCREAMING_SNAKE_CASE	)
			for node in graph[start]:
						if tuple(_SCREAMING_SNAKE_CASE	) not in path:
									my_dfs(_SCREAMING_SNAKE_CASE				,					tuple(_SCREAMING_SNAKE_CASE	)				,					_SCREAMING_SNAKE_CASE				,					_SCREAMING_SNAKE_CASE	)




def    UpperCAmelCase					(  lowercase__						:					Tuple				,					lowercase__						:					Union[str, Any]				,					lowercase__						:					Tuple	):



			'''simple docstring'''





			a__					=  int(s / 100 * (len(_SCREAMING_SNAKE_CASE	) - 1)	)
			for i in cluster[k]:
						my_dfs(_SCREAMING_SNAKE_CASE				,					tuple(cluster[k][i]	)				,					(["""Header"""],)	)




def    UpperCAmelCase					(  lowercase__						:					List[Any]	):



			'''simple docstring'''





			a__					=  []
			for edges in paths:
						a__					=  []
						for j in range(len(_SCREAMING_SNAKE_CASE	) - 1	):
									a__					=  list(edges[j]	)
									for e in temp:
												a__					=  (e[0], e[1])
												el.append(_SCREAMING_SNAKE_CASE	)
						freq_sub_el.append(_SCREAMING_SNAKE_CASE	)
			return freq_sub_el




def    UpperCAmelCase					(  lowercase__						:					Dict	):



			'''simple docstring'''





			for i in range(len(_SCREAMING_SNAKE_CASE	)	):
						for j in range(len(edge_array[i]	)	):
									a__					=  edge_array[i][j].split("""-"""	)
									a__					=  t


if __name__ == "__main__":
	preprocess(edge_array)
	_lowercase				:					Union[str, Any]     					=get_frequency_table(edge_array)
	_lowercase				:					Union[str, Any]     					=get_nodes(frequency_table)
	_lowercase				:					Tuple     					=get_cluster(nodes)
	_lowercase				:					List[str]     					=get_support(cluster)
	_lowercase				:					Optional[Any]     					=construct_graph(cluster, nodes)
	find_freq_subgraph_given_support(60, cluster, graph)
	_lowercase				:					Any     					=[]
	_lowercase				:					Dict     					=freq_subgraphs_edge_list(paths)
	print_all()








import copy

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


SCREAMING_SNAKE_CASE_		  =			logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_		  =			{
    """facebook/sam-vit-huge""": """https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json""",
    """facebook/sam-vit-large""": """https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json""",
    """facebook/sam-vit-base""": """https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json""",
}

class 						UpperCamelCase__					( lowerCAmelCase_  ):



     '''simple docstring'''

     def __init__(				self		:       List[str]		,lowerCamelCase__		:       int=256		,lowerCamelCase__		:       List[Any]=1024		,lowerCamelCase__		:       Any=16		,lowerCamelCase__		:       Union[str, Any]=16		,lowerCamelCase__		:       int=4		,lowerCamelCase__		:       Tuple="gelu"		,lowerCamelCase__		:       Dict=1e-6		,**lowerCamelCase__		:       int		,)	->						List[str]:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		hidden_size
           SCREAMING_SNAKE_CASE						=		image_size
           SCREAMING_SNAKE_CASE						=		patch_size
           SCREAMING_SNAKE_CASE						=		image_size // patch_size
           SCREAMING_SNAKE_CASE						=		mask_input_channels
           SCREAMING_SNAKE_CASE						=		num_point_embeddings
           SCREAMING_SNAKE_CASE						=		hidden_act
           SCREAMING_SNAKE_CASE						=		layer_norm_eps

class 						UpperCamelCase__					( lowerCAmelCase_  ):



     '''simple docstring'''

     def __init__(				self		:       str		,lowerCamelCase__		:       str=256		,lowerCamelCase__		:       Optional[Any]="relu"		,lowerCamelCase__		:       str=2048		,lowerCamelCase__		:       Union[str, Any]=2		,lowerCamelCase__		:       int=8		,lowerCamelCase__		:       Union[str, Any]=2		,lowerCamelCase__		:       List[Any]=3		,lowerCamelCase__		:       int=3		,lowerCamelCase__		:       Optional[Any]=256		,lowerCamelCase__		:       Tuple=1e-6		,**lowerCamelCase__		:       List[str]		,)	->						Dict:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		hidden_size
           SCREAMING_SNAKE_CASE						=		hidden_act
           SCREAMING_SNAKE_CASE						=		mlp_dim
           SCREAMING_SNAKE_CASE						=		num_hidden_layers
           SCREAMING_SNAKE_CASE						=		num_attention_heads
           SCREAMING_SNAKE_CASE						=		attention_downsample_rate
           SCREAMING_SNAKE_CASE						=		num_multimask_outputs
           SCREAMING_SNAKE_CASE						=		iou_head_depth
           SCREAMING_SNAKE_CASE						=		iou_head_hidden_dim
           SCREAMING_SNAKE_CASE						=		layer_norm_eps

class 						UpperCamelCase__					( lowerCAmelCase_  ):



     '''simple docstring'''

     def __init__(				self		:       Union[str, Any]		,lowerCamelCase__		:       Optional[Any]=768		,lowerCamelCase__		:       Union[str, Any]=256		,lowerCamelCase__		:       Optional[int]=12		,lowerCamelCase__		:       str=12		,lowerCamelCase__		:       Tuple=3		,lowerCamelCase__		:       Optional[Any]=1024		,lowerCamelCase__		:       Optional[int]=16		,lowerCamelCase__		:       Optional[Any]="gelu"		,lowerCamelCase__		:       int=1e-0_6		,lowerCamelCase__		:       Optional[Any]=0.0		,lowerCamelCase__		:       Tuple=1e-1_0		,lowerCamelCase__		:       Any=True		,lowerCamelCase__		:       List[Any]=4.0		,lowerCamelCase__		:       Optional[int]=True		,lowerCamelCase__		:       Union[str, Any]=True		,lowerCamelCase__		:       List[str]=14		,lowerCamelCase__		:       List[str]=[2, 5, 8, 11]		,lowerCamelCase__		:       Tuple=128		,lowerCamelCase__		:       Dict=None		,**lowerCamelCase__		:       Optional[Any]		,)	->						str:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__			)

           SCREAMING_SNAKE_CASE						=		hidden_size
           SCREAMING_SNAKE_CASE						=		output_channels
           SCREAMING_SNAKE_CASE						=		num_hidden_layers
           SCREAMING_SNAKE_CASE						=		num_attention_heads
           SCREAMING_SNAKE_CASE						=		num_channels
           SCREAMING_SNAKE_CASE						=		image_size
           SCREAMING_SNAKE_CASE						=		patch_size
           SCREAMING_SNAKE_CASE						=		hidden_act
           SCREAMING_SNAKE_CASE						=		layer_norm_eps
           SCREAMING_SNAKE_CASE						=		attention_dropout
           SCREAMING_SNAKE_CASE						=		initializer_range
           SCREAMING_SNAKE_CASE						=		qkv_bias
           SCREAMING_SNAKE_CASE						=		mlp_ratio
           SCREAMING_SNAKE_CASE						=		use_abs_pos
           SCREAMING_SNAKE_CASE						=		use_rel_pos
           SCREAMING_SNAKE_CASE						=		window_size
           SCREAMING_SNAKE_CASE						=		global_attn_indexes
           SCREAMING_SNAKE_CASE						=		num_pos_feats
           SCREAMING_SNAKE_CASE						=		int(hidden_size * mlp_ratio			) if mlp_dim is None else mlp_dim

class 						UpperCamelCase__					( lowerCAmelCase_  ):



     '''simple docstring'''

     __snake_case       :      Any						      =     "sam"
     __snake_case       :      Optional[Any]						      =     True






     def __init__(				self		:       Union[str, Any]		,lowerCamelCase__		:       List[Any]=None		,lowerCamelCase__		:       int=None		,lowerCamelCase__		:       int=None		,lowerCamelCase__		:       int=0.02		,**lowerCamelCase__		:       int		,)	->						str:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		vision_config if vision_config is not None else {}
           SCREAMING_SNAKE_CASE						=		prompt_encoder_config if prompt_encoder_config is not None else {}
           SCREAMING_SNAKE_CASE						=		mask_decoder_config if mask_decoder_config is not None else {}

           if isinstance(lowerCamelCase__		,lowerCamelCase__			):
                 SCREAMING_SNAKE_CASE						=		vision_config.to_dict()
           if isinstance(lowerCamelCase__		,lowerCamelCase__			):
                 SCREAMING_SNAKE_CASE						=		prompt_encoder_config.to_dict()
           if isinstance(lowerCamelCase__		,lowerCamelCase__			):
                 SCREAMING_SNAKE_CASE						=		mask_decoder_config.to_dict()

           SCREAMING_SNAKE_CASE						=		SamVisionConfig(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		SamPromptEncoderConfig(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		SamMaskDecoderConfig(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		initializer_range






     def 							SCREAMING_SNAKE_CASE__    (				self		:       Union[str, Any]			)	->						Optional[Any]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE						=		copy.deepcopy(self.__dict__			)
           SCREAMING_SNAKE_CASE						=		self.vision_config.to_dict()
           SCREAMING_SNAKE_CASE						=		self.prompt_encoder_config.to_dict()
           SCREAMING_SNAKE_CASE						=		self.mask_decoder_config.to_dict()
           SCREAMING_SNAKE_CASE						=		self.__class__.model_type
           return output


