
'''simple docstring'''



import argparse
import os
from functools import reduce

import fairseq
import torch
from datasets import load_dataset

from transformers import WavaVecaProcessor, logging
from transformers.models.dataavec.configuration_dataavec_audio import DataaVecAudioConfig

# Copied from https://github.com/pytorch/fairseq/blob/main/examples/data2vec/models/data2vec_audio.py
from transformers.models.dataavec.dataavec_audio import DataaVecAudioModel as Dummy  # noqa: F401
from transformers.models.dataavec.modeling_dataavec_audio import DataaVecAudioForCTC, DataaVecAudioModel


logging.set_verbosity_info()
UpperCamelCase__					:						Tuple											=     logging.get_logger(__name__)

UpperCamelCase__					:						int											=     {
    "post_extract_proj": "feature_projection.projection",
    "models.0.layer_norm": "feature_projection.layer_norm",
    "self_attn.k_proj": "encoder.layers.*.attention.k_proj",
    "self_attn.v_proj": "encoder.layers.*.attention.v_proj",
    "self_attn.q_proj": "encoder.layers.*.attention.q_proj",
    "self_attn.out_proj": "encoder.layers.*.attention.out_proj",
    "self_attn_layer_norm": "encoder.layers.*.layer_norm",
    "fc1": "encoder.layers.*.feed_forward.intermediate_dense",
    "fc2": "encoder.layers.*.feed_forward.output_dense",
    "final_layer_norm": "encoder.layers.*.final_layer_norm",
    "encoder.layer_norm": "encoder.layer_norm",
    "w2v_model.layer_norm": "feature_projection.layer_norm",
    "w2v_encoder.proj": "lm_head",
    "mask_emb": "masked_spec_embed",
}
UpperCamelCase__					:						Optional[int]											=     [
    "lm_head",
]
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   Optional[int]:




   """simple docstring"""
   for attribute in key.split("""."""  ):
      _SCREAMING_SNAKE_CASE          = getattr(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )

   if weight_type is not None:
      _SCREAMING_SNAKE_CASE          = getattr(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  ).shape
   else:
      _SCREAMING_SNAKE_CASE          = hf_pointer.shape

   if hf_shape != value.shape:
      raise ValueError(
          F"Shape of hf {key + '.' + weight_type if weight_type is not None else ''} is {hf_shape}, but should be"
          F" {value.shape} for {full_name}"  )

   if weight_type == "weight":
      _SCREAMING_SNAKE_CASE          = value
   elif weight_type == "weight_g":
      _SCREAMING_SNAKE_CASE          = value
   elif weight_type == "weight_v":
      _SCREAMING_SNAKE_CASE          = value
   elif weight_type == "bias":
      _SCREAMING_SNAKE_CASE          = value
   else:
      _SCREAMING_SNAKE_CASE          = value

   logger.info(F"{key + '.' + weight_type if weight_type is not None else ''} was initialized from {full_name}."  )
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   Optional[Any]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = []
   _SCREAMING_SNAKE_CASE          = fairseq_model.state_dict()

   if not is_headless:
      _SCREAMING_SNAKE_CASE          = hf_model.dataavec_audio.feature_extractor
      _SCREAMING_SNAKE_CASE          = hf_model.dataavec_audio.encoder.pos_conv_embed

   else:
      _SCREAMING_SNAKE_CASE          = hf_model.feature_extractor
      _SCREAMING_SNAKE_CASE          = hf_model.encoder.pos_conv_embed

   for name, value in fairseq_dict.items():
      _SCREAMING_SNAKE_CASE          = False
      if "conv_layers" in name:
         load_conv_layer(
             SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					)
         _SCREAMING_SNAKE_CASE          = True
      elif "pos_conv" in name:
         load_pos_conv_layer(
             SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					)
         _SCREAMING_SNAKE_CASE          = True
      else:
         for key, mapped_key in MAPPING.items():
            if not is_headless:
               _SCREAMING_SNAKE_CASE          = """data2vec_audio.""" + mapped_key if mapped_key not in TOP_LEVEL_KEYS else mapped_key
            if key in name or key.split("""w2v_model."""  )[-1] == name.split("""."""  )[0]:
               _SCREAMING_SNAKE_CASE          = True
               if "*" in mapped_key:
                  _SCREAMING_SNAKE_CASE          = name.split(SCREAMING_SNAKE_CASE_  )[0].split("""."""  )[-2]
                  _SCREAMING_SNAKE_CASE          = mapped_key.replace("""*"""			,					SCREAMING_SNAKE_CASE_  )
               if "weight_g" in name:
                  _SCREAMING_SNAKE_CASE          = """weight_g"""
               elif "weight_v" in name:
                  _SCREAMING_SNAKE_CASE          = """weight_v"""
               elif "bias" in name:
                  _SCREAMING_SNAKE_CASE          = """bias"""
               elif "weight" in name:
                  # TODO: don't match quantizer.weight_proj
                  _SCREAMING_SNAKE_CASE          = """weight"""
               else:
                  _SCREAMING_SNAKE_CASE          = None
               set_recursively(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )
            continue
      if not is_used:
         unused_weights.append(SCREAMING_SNAKE_CASE_  )

   logger.warning(F"Unused weights: {unused_weights}"  )
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   Optional[int]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = path.split("""."""  )
   return reduce(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   Optional[Any]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = access_by_string(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )
   _SCREAMING_SNAKE_CASE          = hf_weight.data

   if fsq_value.shape != hf_value.shape:
      raise ValueError(F"{full_name} has size {fsq_value.shape}, but {hf_value.shape} was found."  )
   _SCREAMING_SNAKE_CASE          = fsq_value
   logger.info(F"{full_name} was correctly initialized from {hf_weight_path}."  )
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   List[Any]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = full_name.split("""conv_layers."""  )[-1]
   _SCREAMING_SNAKE_CASE          = name.split("""."""  )
   _SCREAMING_SNAKE_CASE          = int(items[0]  )
   _SCREAMING_SNAKE_CASE          = int(items[1]  )

   _SCREAMING_SNAKE_CASE          = name.split("""."""  )[-1]
   if type_id == 0:
      _SCREAMING_SNAKE_CASE          = """conv"""
   elif type_id == 2:
      _SCREAMING_SNAKE_CASE          = """layer_norm"""
   else:
      unused_weights.append(SCREAMING_SNAKE_CASE_  )
      return

   set_weights(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					F"conv_layers.{layer_id}.{layer_type}.{weight_type}"  )
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   Tuple:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = full_name.split("""pos_conv."""  )[-1]
   _SCREAMING_SNAKE_CASE          = name.split("""."""  )
   _SCREAMING_SNAKE_CASE          = int(items[0]  )
   _SCREAMING_SNAKE_CASE          = int(items[1]  )

   _SCREAMING_SNAKE_CASE          = name.split("""."""  )[-1]
   if type_id != 0:
      unused_weights.append(SCREAMING_SNAKE_CASE_  )
      return
   else:
      _SCREAMING_SNAKE_CASE          = """conv"""

   set_weights(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					F"layers.{layer_id}.{layer_type}.{weight_type}"  )
@torch.no_grad()
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_=None			,					SCREAMING_SNAKE_CASE_=None			,					SCREAMING_SNAKE_CASE_=True  )   ->   List[str]:




   """simple docstring"""
   if config_path is not None:
      _SCREAMING_SNAKE_CASE          = DataaVecAudioConfig.from_pretrained(SCREAMING_SNAKE_CASE_  )
   else:
      _SCREAMING_SNAKE_CASE          = DataaVecAudioConfig()

   if not is_finetuned:
      # Modify final_proj layer name
      _SCREAMING_SNAKE_CASE          = DataaVecAudioModel(SCREAMING_SNAKE_CASE_  )
      _SCREAMING_SNAKE_CASE          = os.path.dirname(SCREAMING_SNAKE_CASE_  )

      _SCREAMING_SNAKE_CASE          = torch.load(SCREAMING_SNAKE_CASE_  )
      _SCREAMING_SNAKE_CASE          = state_dict["""model"""].pop("""final_proj.0.weight"""  )
      _SCREAMING_SNAKE_CASE          = state_dict["""model"""].pop("""final_proj.0.bias"""  )
      _SCREAMING_SNAKE_CASE          = os.path.join(SCREAMING_SNAKE_CASE_			,					"""converted.pt"""  )
      torch.save(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )
   else:
      _SCREAMING_SNAKE_CASE          = DataaVecAudioForCTC(SCREAMING_SNAKE_CASE_  )
      _SCREAMING_SNAKE_CASE          = checkpoint_path

   def load_dataavec(SCREAMING_SNAKE_CASE_  ):
      _SCREAMING_SNAKE_CASE       ,							_SCREAMING_SNAKE_CASE       ,							_SCREAMING_SNAKE_CASE          = fairseq.checkpoint_utils.load_model_ensemble_and_task([path]  )
      return model[0].eval()

   _SCREAMING_SNAKE_CASE          = load_dataavec(SCREAMING_SNAKE_CASE_  )

   recursively_load_weights(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					not is_finetuned  )

   _SCREAMING_SNAKE_CASE          = WavaVecaProcessor.from_pretrained("""facebook/wav2vec2-large-lv60"""  )

   _SCREAMING_SNAKE_CASE          = load_dataset("""patrickvonplaten/librispeech_asr_dummy"""			,					"""clean"""			,					split="""validation"""  )
   _SCREAMING_SNAKE_CASE          = [x["""array"""] for x in ds[:4]["""audio"""]]

   _SCREAMING_SNAKE_CASE          = processor(SCREAMING_SNAKE_CASE_			,					return_tensors="""pt"""			,					padding=SCREAMING_SNAKE_CASE_  )

   _SCREAMING_SNAKE_CASE          = inputs.input_values
   _SCREAMING_SNAKE_CASE          = inputs.attention_mask
   #    input_values = inputs.input_values[:, :-1]
   #    attention_mask = inputs.attention_mask[:, :-1]

   hf_wavavec.eval()
   model.eval()
   if is_finetuned:
      _SCREAMING_SNAKE_CASE          = model(source=SCREAMING_SNAKE_CASE_			,					padding_mask=(1 - attention_mask)			,					mask=SCREAMING_SNAKE_CASE_			,					features_only=SCREAMING_SNAKE_CASE_  )[
          """encoder_out"""
      ].transpose(0			,					1  )
      _SCREAMING_SNAKE_CASE          = hf_wavavec(SCREAMING_SNAKE_CASE_			,					attention_mask=SCREAMING_SNAKE_CASE_  )["""logits"""]

      _SCREAMING_SNAKE_CASE          = torch.argmax(SCREAMING_SNAKE_CASE_			,					dim=-1  )
      _SCREAMING_SNAKE_CASE          = processor.batch_decode(SCREAMING_SNAKE_CASE_  )

      print(F"Expected Output: {ds[:4]['text']}, Pred: {output_string}"  )
   else:
      _SCREAMING_SNAKE_CASE          = model(source=SCREAMING_SNAKE_CASE_			,					padding_mask=(1 - attention_mask)			,					mask=SCREAMING_SNAKE_CASE_			,					features_only=SCREAMING_SNAKE_CASE_  )[
          """layer_results"""
      ][-1][0].transpose(0			,					1  )
      _SCREAMING_SNAKE_CASE          = hf_wavavec(SCREAMING_SNAKE_CASE_			,					attention_mask=SCREAMING_SNAKE_CASE_  )["""last_hidden_state"""]

   print(our_output.shape			,					their_output.shape  )
   _SCREAMING_SNAKE_CASE          = torch.max(torch.abs(our_output - their_output  )  ).item()
   print(F"max_absolute_diff = {max_absolute_diff}"  )  # ~ 1e-7
   _SCREAMING_SNAKE_CASE          = torch.allclose(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					atol=1e-3  )
   print("""Do both models output the same tensors?"""			,					"""🔥""" if success else """💩"""  )
   if not success:
      raise Exception("""Something went wRoNg"""  )

   hf_wavavec.save_pretrained(SCREAMING_SNAKE_CASE_  )

   if is_finetuned:
      processor.save_pretrained(SCREAMING_SNAKE_CASE_  )
   else:
      processor.feature_extractor.save_pretrained(SCREAMING_SNAKE_CASE_  )


if __name__ == "__main__":
     UpperCamelCase__					:						List[Any]											=     argparse.ArgumentParser()
     parser.add_argument("--pytorch_dump_folder_path", default=None, type=str, help="Path to the output PyTorch model.")
     parser.add_argument("--checkpoint_path", default=None, type=str, help="Path to fairseq checkpoint")
     parser.add_argument("--dict_path", default=None, type=str, help="Path to dict of fine-tuned model")
     parser.add_argument("--config_path", default=None, type=str, help="Path to hf config.json of model to convert")
     parser.add_argument(
         "--not_finetuned", action="store_true", help="Whether the model to convert is a fine-tuned model or not"
     )
     UpperCamelCase__					:						Optional[Any]											=     parser.parse_args()
     convert_wavaveca_checkpoint(
         args.checkpoint_path, args.pytorch_dump_folder_path, args.config_path, args.dict_path, not args.not_finetuned
     )








'''simple docstring'''



UpperCamelCase__					:						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       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_  )   ->   List[str]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = set()
   for row in edge_array:
      for item in row:
         distinct_edge.add(item[0]  )
   return list(SCREAMING_SNAKE_CASE_  )
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   List[str]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = ["""0"""] * len(SCREAMING_SNAKE_CASE_  )
   for i, row in enumerate(SCREAMING_SNAKE_CASE_  ):
      for item in row:
         if distinct_edge in item[0]:
            _SCREAMING_SNAKE_CASE          = """1"""
            break
   return "".join(SCREAMING_SNAKE_CASE_  )
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_  )   ->   Union[str, Any]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = get_distinct_edge(SCREAMING_SNAKE_CASE_  )
   _SCREAMING_SNAKE_CASE          = {}

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




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = {}
   for _, item in enumerate(SCREAMING_SNAKE_CASE_  ):
      nodes.setdefault(item[2]			,					[]  ).append(item[0]  )
   return nodes
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_  )   ->   int:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = {}
   for key, value in nodes.items():
      _SCREAMING_SNAKE_CASE          = value
   return cluster
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_  )   ->   str:




   """simple docstring"""
   return [i * 1_00 / len(SCREAMING_SNAKE_CASE_  ) for i in cluster]
def       lowerCAmelCase_		( )   ->   None:




   """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       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   Optional[int]:




   """simple docstring"""
   for i in cluster[ca]:
      _SCREAMING_SNAKE_CASE          = 0
      _SCREAMING_SNAKE_CASE          = 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:
                  _SCREAMING_SNAKE_CASE          = [nodes[j]]
               count += 1
         if count == 0:
            _SCREAMING_SNAKE_CASE          = ca + 1
         else:
            break
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   Optional[int]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = cluster[max(cluster.keys()  )]
   _SCREAMING_SNAKE_CASE          = """Header"""
   _SCREAMING_SNAKE_CASE          = {}
   for i in x:
      if (["Header"],) in graph:
         graph[(["Header"],)].append(x[i]  )
      else:
         _SCREAMING_SNAKE_CASE          = [x[i]]
   for i in x:
      _SCREAMING_SNAKE_CASE          = [["""Header"""]]
   _SCREAMING_SNAKE_CASE          = 1
   while i < max(SCREAMING_SNAKE_CASE_  ) - 1:
      create_edge(SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )
      _SCREAMING_SNAKE_CASE          = i + 1
   return graph
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_=None  )   ->   List[Any]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = (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       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   int:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = int(s / 1_00 * (len(SCREAMING_SNAKE_CASE_  ) - 1)  )
   for i in cluster[k]:
      my_dfs(SCREAMING_SNAKE_CASE_			,					tuple(cluster[k][i]  )			,					(["""Header"""],)  )
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_  )   ->   Optional[Any]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE          = []
   for edges in paths:
      _SCREAMING_SNAKE_CASE          = []
      for j in range(len(SCREAMING_SNAKE_CASE_  ) - 1  ):
         _SCREAMING_SNAKE_CASE          = list(edges[j]  )
         for e in temp:
            _SCREAMING_SNAKE_CASE          = (e[0], e[1])
            el.append(SCREAMING_SNAKE_CASE_  )
      freq_sub_el.append(SCREAMING_SNAKE_CASE_  )
   return freq_sub_el
def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_  )   ->   Any:




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


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






