
'''simple docstring'''


__SCREAMING_SNAKE_CASE						=      [
    ["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 					__magic_name__(       UpperCAmelCase__ :       int	):
						UpperCamelCase_     :	Optional[int]					     =     set()
						for row in edge_array:
												for item in row:
																		distinct_edge.add(item[0]	)
						return list(UpperCAmelCase__	)
def 					__magic_name__(       UpperCAmelCase__ :       Optional[Any]							,				UpperCAmelCase__ :       Optional[int]	):
						UpperCamelCase_     :	Optional[Any]					     =     ["""0"""] * len(UpperCAmelCase__	)
						for i, row in enumerate(UpperCAmelCase__	):
												for item in row:
																		if distinct_edge in item[0]:
																								UpperCamelCase_     :	int					     =     """1"""
																								break
						return "".join(UpperCAmelCase__	)
def 					__magic_name__(       UpperCAmelCase__ :       Union[str, Any]	):
						UpperCamelCase_     :	List[str]					     =     get_distinct_edge(UpperCAmelCase__	)
						UpperCamelCase_     :	str					     =     {}

						for item in distinct_edge:
												UpperCamelCase_     :	Tuple					     =     get_bitcode(UpperCAmelCase__							,				UpperCAmelCase__	)
												# print('bit',bit)
												# bt=''.join(bit)
												UpperCamelCase_     :	str					     =     bit.count("""1"""	)
												UpperCamelCase_     :	Union[str, Any]					     =     [s, bit]
						# Store [Distinct edge, WT(Bitcode), Bitcode] in descending order
						UpperCamelCase_     :	List[Any]					     =     [
						    [k, v[0], v[1]]
						    for k, v in sorted(frequency_table.items()							,				key=lambda UpperCAmelCase__	: v[1][0]							,				reverse=UpperCAmelCase__	)
						]
						return sorted_frequency_table
def 					__magic_name__(       UpperCAmelCase__ :       int	):
						UpperCamelCase_     :	Optional[int]					     =     {}
						for _, item in enumerate(UpperCAmelCase__	):
												nodes.setdefault(item[2]							,				[]	).append(item[0]	)
						return nodes
def 					__magic_name__(       UpperCAmelCase__ :       Union[str, Any]	):
						UpperCamelCase_     :	Union[str, Any]					     =     {}
						for key, value in nodes.items():
												UpperCamelCase_     :	int					     =     value
						return cluster
def 					__magic_name__(       UpperCAmelCase__ :       Optional[Any]	):
						return [i * 100 / len(UpperCAmelCase__	) for i in cluster]
def 					__magic_name__(       ):
						print("""\nNodes\n"""	)
						for key, value in nodes.items():
												print(UpperCAmelCase__							,				UpperCAmelCase__	)
						print("""\nSupport\n"""	)
						print(UpperCAmelCase__	)
						print("""\n Cluster \n"""	)
						for key, value in sorted(cluster.items()							,				reverse=UpperCAmelCase__	):
												print(UpperCAmelCase__							,				UpperCAmelCase__	)
						print("""\n Graph\n"""	)
						for key, value in graph.items():
												print(UpperCAmelCase__							,				UpperCAmelCase__	)
						print("""\n Edge List of Frequent subgraphs \n"""	)
						for edge_list in freq_subgraph_edge_list:
												print(UpperCAmelCase__	)
def 					__magic_name__(       UpperCAmelCase__ :       Dict							,				UpperCAmelCase__ :       List[str]							,				UpperCAmelCase__ :       Optional[Any]							,				UpperCAmelCase__ :       Tuple	):
						for i in cluster[ca]:
												UpperCamelCase_     :	Any					     =     0
												UpperCamelCase_     :	Optional[int]					     =     ca + 1
												while ca < max(cluster.keys()	):
																		for j in cluster[ca]:
																								if int(UpperCAmelCase__							,				2	) & int(UpperCAmelCase__							,				2	) == int(UpperCAmelCase__							,				2	):
																														if tuple(nodes[i]	) in graph:
																																				graph[tuple(nodes[i]	)].append(nodes[j]	)
																														else:
																																				UpperCamelCase_     :	Tuple					     =     [nodes[j]]
																														count += 1
																		if count == 0:
																								UpperCamelCase_     :	List[Any]					     =     ca + 1
																		else:
																								break
def 					__magic_name__(       UpperCAmelCase__ :       List[str]							,				UpperCAmelCase__ :       Any	):
						UpperCamelCase_     :	Optional[Any]					     =     cluster[max(cluster.keys()	)]
						UpperCamelCase_     :	Tuple					     =     """Header"""
						UpperCamelCase_     :	Optional[Any]					     =     {}
						for i in x:
												if (["Header"],) in graph:
																		graph[(["Header"],)].append(x[i]	)
												else:
																		UpperCamelCase_     :	Any					     =     [x[i]]
						for i in x:
												UpperCamelCase_     :	Dict					     =     [["""Header"""]]
						UpperCamelCase_     :	str					     =     1
						while i < max(UpperCAmelCase__	) - 1:
												create_edge(UpperCAmelCase__							,				UpperCAmelCase__							,				UpperCAmelCase__							,				UpperCAmelCase__	)
												UpperCamelCase_     :	Dict					     =     i + 1
						return graph
def 					__magic_name__(       UpperCAmelCase__ :       Optional[Any]							,				UpperCAmelCase__ :       Union[str, Any]							,				UpperCAmelCase__ :       Union[str, Any]							,				UpperCAmelCase__ :       List[str]=None	):
						UpperCamelCase_     :	int					     =     (path or []) + [start]
						if start == end:
												paths.append(UpperCAmelCase__	)
						for node in graph[start]:
												if tuple(UpperCAmelCase__	) not in path:
																		my_dfs(UpperCAmelCase__							,				tuple(UpperCAmelCase__	)							,				UpperCAmelCase__							,				UpperCAmelCase__	)
def 					__magic_name__(       UpperCAmelCase__ :       Dict							,				UpperCAmelCase__ :       Union[str, Any]							,				UpperCAmelCase__ :       Dict	):
						UpperCamelCase_     :	List[Any]					     =     int(s / 100 * (len(UpperCAmelCase__	) - 1)	)
						for i in cluster[k]:
												my_dfs(UpperCAmelCase__							,				tuple(cluster[k][i]	)							,				(["""Header"""],)	)
def 					__magic_name__(       UpperCAmelCase__ :       List[Any]	):
						UpperCamelCase_     :	Any					     =     []
						for edges in paths:
												UpperCamelCase_     :	List[Any]					     =     []
												for j in range(len(UpperCAmelCase__	) - 1	):
																		UpperCamelCase_     :	Optional[Any]					     =     list(edges[j]	)
																		for e in temp:
																								UpperCamelCase_     :	int					     =     (e[0], e[1])
																								el.append(UpperCAmelCase__	)
												freq_sub_el.append(UpperCAmelCase__	)
						return freq_sub_el
def 					__magic_name__(       UpperCAmelCase__ :       int	):
						for i in range(len(UpperCAmelCase__	)	):
												for j in range(len(edge_array[i]	)	):
																		UpperCamelCase_     :	int					     =     edge_array[i][j].split("""-"""	)
																		UpperCamelCase_     :	str					     =     t


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






'''simple docstring'''


from typing import Any, Callable, Dict, List, Optional, Union

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


__SCREAMING_SNAKE_CASE						=      logging.get_logger(__name__)  # pylint: disable=invalid-name




class     __snake_case			(    _a	):
		a_          =					["safety_checker", "feature_extractor"]




		def __init__(  self					:str			,    _SCREAMING_SNAKE_CASE					:AutoencoderKL			,    _SCREAMING_SNAKE_CASE					:CLIPTextModel			,    _SCREAMING_SNAKE_CASE					:CLIPTokenizer			,    _SCREAMING_SNAKE_CASE					:UNetaDConditionModel			,    _SCREAMING_SNAKE_CASE					:Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]			,    _SCREAMING_SNAKE_CASE					:StableDiffusionSafetyChecker			,    _SCREAMING_SNAKE_CASE					:CLIPImageProcessor			,    _SCREAMING_SNAKE_CASE					:bool = True			,    )					->			int:






								'''simple docstring'''






								super().__init__()
								if hasattr(scheduler.config			,    """steps_offset""") and scheduler.config.steps_offset != 1:
														UpperCamelCase_     :	Optional[Any]					     =     (
														    F"""The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`"""
														    F""" should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure """
														    """to update the config accordingly as leaving `steps_offset` might led to incorrect results"""
														    """ in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,"""
														    """ it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`"""
														    """ file"""
														)
														deprecate("""steps_offset!=1"""			,    """1.0.0"""			,    _SCREAMING_SNAKE_CASE			,    standard_warn=_SCREAMING_SNAKE_CASE)
														UpperCamelCase_     :	Union[str, Any]					     =     dict(scheduler.config)
														UpperCamelCase_     :	Optional[Any]					     =     1
														UpperCamelCase_     :	int					     =     FrozenDict(_SCREAMING_SNAKE_CASE)

								self.register_modules(
								    vae=_SCREAMING_SNAKE_CASE			,    text_encoder=_SCREAMING_SNAKE_CASE			,    tokenizer=_SCREAMING_SNAKE_CASE			,    unet=_SCREAMING_SNAKE_CASE			,    scheduler=_SCREAMING_SNAKE_CASE			,    safety_checker=_SCREAMING_SNAKE_CASE			,    feature_extractor=_SCREAMING_SNAKE_CASE			,    )
								self.register_to_config(requires_safety_checker=_SCREAMING_SNAKE_CASE)




		@property
		def 	_snake_case	(  self					:Tuple)					->			Dict[str, Any]:






								'''simple docstring'''






								return {k: getattr(self			,    _SCREAMING_SNAKE_CASE) for k in self.config.keys() if not k.startswith("""_""")}




		def 	_snake_case	(  self					:Optional[int]			,    _SCREAMING_SNAKE_CASE					:Optional[Union[str, int]] = "auto")					->			Union[str, Any]:






								'''simple docstring'''






								if slice_size == "auto":
														# half the attention head size is usually a good trade-off between
														# speed and memory
														UpperCamelCase_     :	int					     =     self.unet.config.attention_head_dim // 2
								self.unet.set_attention_slice(_SCREAMING_SNAKE_CASE)




		def 	_snake_case	(  self					:Union[str, Any])					->			Dict:






								'''simple docstring'''






								self.enable_attention_slicing(_SCREAMING_SNAKE_CASE)




		@torch.no_grad()
		def 	_snake_case	(  self					:Union[str, Any]			,    _SCREAMING_SNAKE_CASE					:Union[str, List[str]]			,    _SCREAMING_SNAKE_CASE					:Union[torch.FloatTensor, PIL.Image.Image]			,    _SCREAMING_SNAKE_CASE					:Union[torch.FloatTensor, PIL.Image.Image]			,    _SCREAMING_SNAKE_CASE					:float = 0.8			,    _SCREAMING_SNAKE_CASE					:Optional[int] = 5_0			,    _SCREAMING_SNAKE_CASE					:Optional[float] = 7.5			,    _SCREAMING_SNAKE_CASE					:Optional[Union[str, List[str]]] = None			,    _SCREAMING_SNAKE_CASE					:Optional[int] = 1			,    _SCREAMING_SNAKE_CASE					:Optional[float] = 0.0			,    _SCREAMING_SNAKE_CASE					:Optional[torch.Generator] = None			,    _SCREAMING_SNAKE_CASE					:Optional[str] = "pil"			,    _SCREAMING_SNAKE_CASE					:bool = True			,    _SCREAMING_SNAKE_CASE					:Optional[Callable[[int, int, torch.FloatTensor], None]] = None			,    _SCREAMING_SNAKE_CASE					:int = 1			,    )					->			List[str]:






								'''simple docstring'''






								return StableDiffusionInpaintPipelineLegacy(**self.components)(
								    prompt=_SCREAMING_SNAKE_CASE			,    image=_SCREAMING_SNAKE_CASE			,    mask_image=_SCREAMING_SNAKE_CASE			,    strength=_SCREAMING_SNAKE_CASE			,    num_inference_steps=_SCREAMING_SNAKE_CASE			,    guidance_scale=_SCREAMING_SNAKE_CASE			,    negative_prompt=_SCREAMING_SNAKE_CASE			,    num_images_per_prompt=_SCREAMING_SNAKE_CASE			,    eta=_SCREAMING_SNAKE_CASE			,    generator=_SCREAMING_SNAKE_CASE			,    output_type=_SCREAMING_SNAKE_CASE			,    return_dict=_SCREAMING_SNAKE_CASE			,    callback=_SCREAMING_SNAKE_CASE			,    )




		@torch.no_grad()
		def 	_snake_case	(  self					:List[str]			,    _SCREAMING_SNAKE_CASE					:Union[str, List[str]]			,    _SCREAMING_SNAKE_CASE					:Union[torch.FloatTensor, PIL.Image.Image]			,    _SCREAMING_SNAKE_CASE					:float = 0.8			,    _SCREAMING_SNAKE_CASE					:Optional[int] = 5_0			,    _SCREAMING_SNAKE_CASE					:Optional[float] = 7.5			,    _SCREAMING_SNAKE_CASE					:Optional[Union[str, List[str]]] = None			,    _SCREAMING_SNAKE_CASE					:Optional[int] = 1			,    _SCREAMING_SNAKE_CASE					:Optional[float] = 0.0			,    _SCREAMING_SNAKE_CASE					:Optional[torch.Generator] = None			,    _SCREAMING_SNAKE_CASE					:Optional[str] = "pil"			,    _SCREAMING_SNAKE_CASE					:bool = True			,    _SCREAMING_SNAKE_CASE					:Optional[Callable[[int, int, torch.FloatTensor], None]] = None			,    _SCREAMING_SNAKE_CASE					:int = 1			,    **_SCREAMING_SNAKE_CASE					:int			,    )					->			Any:






								'''simple docstring'''






								return StableDiffusionImgaImgPipeline(**self.components)(
								    prompt=_SCREAMING_SNAKE_CASE			,    image=_SCREAMING_SNAKE_CASE			,    strength=_SCREAMING_SNAKE_CASE			,    num_inference_steps=_SCREAMING_SNAKE_CASE			,    guidance_scale=_SCREAMING_SNAKE_CASE			,    negative_prompt=_SCREAMING_SNAKE_CASE			,    num_images_per_prompt=_SCREAMING_SNAKE_CASE			,    eta=_SCREAMING_SNAKE_CASE			,    generator=_SCREAMING_SNAKE_CASE			,    output_type=_SCREAMING_SNAKE_CASE			,    return_dict=_SCREAMING_SNAKE_CASE			,    callback=_SCREAMING_SNAKE_CASE			,    callback_steps=_SCREAMING_SNAKE_CASE			,    )





		@torch.no_grad()
		def 	_snake_case	(  self					:Any			,    _SCREAMING_SNAKE_CASE					:Union[str, List[str]]			,    _SCREAMING_SNAKE_CASE					:int = 5_1_2			,    _SCREAMING_SNAKE_CASE					:int = 5_1_2			,    _SCREAMING_SNAKE_CASE					:int = 5_0			,    _SCREAMING_SNAKE_CASE					:float = 7.5			,    _SCREAMING_SNAKE_CASE					:Optional[Union[str, List[str]]] = None			,    _SCREAMING_SNAKE_CASE					:Optional[int] = 1			,    _SCREAMING_SNAKE_CASE					:float = 0.0			,    _SCREAMING_SNAKE_CASE					:Optional[torch.Generator] = None			,    _SCREAMING_SNAKE_CASE					:Optional[torch.FloatTensor] = None			,    _SCREAMING_SNAKE_CASE					:Optional[str] = "pil"			,    _SCREAMING_SNAKE_CASE					:bool = True			,    _SCREAMING_SNAKE_CASE					:Optional[Callable[[int, int, torch.FloatTensor], None]] = None			,    _SCREAMING_SNAKE_CASE					:int = 1			,    )					->			List[Any]:






								'''simple docstring'''






								return StableDiffusionPipeline(**self.components)(
								    prompt=_SCREAMING_SNAKE_CASE			,    height=_SCREAMING_SNAKE_CASE			,    width=_SCREAMING_SNAKE_CASE			,    num_inference_steps=_SCREAMING_SNAKE_CASE			,    guidance_scale=_SCREAMING_SNAKE_CASE			,    negative_prompt=_SCREAMING_SNAKE_CASE			,    num_images_per_prompt=_SCREAMING_SNAKE_CASE			,    eta=_SCREAMING_SNAKE_CASE			,    generator=_SCREAMING_SNAKE_CASE			,    latents=_SCREAMING_SNAKE_CASE			,    output_type=_SCREAMING_SNAKE_CASE			,    return_dict=_SCREAMING_SNAKE_CASE			,    callback=_SCREAMING_SNAKE_CASE			,    callback_steps=_SCREAMING_SNAKE_CASE			,    )




