code: 
  
  
  '''simple docstring'''
  
  from typing import Dict, Tuple, overload
  
  import torch
  import torch.types
  from torch import nn
  
  from . import residue_constants as rc
  from .rigid_utils import Rigid, Rotation
  from .tensor_utils import batched_gather
  
  
  
  
  
  @overload
  def lowerCamelCase    (    lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			None	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	...
  
  
  
  
  
  @overload
  def lowerCamelCase    (    lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	...
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Tuple	,	lowerCAmelCase       :			Any	,	lowerCAmelCase       :			Any	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					int  			=  aatype == rc.restype_order['G']
  	__magic_name__ :					Optional[int]  			=  rc.atom_order['CA']
  	__magic_name__ :					int  			=  rc.atom_order['CB']
  	__magic_name__ :					List[str]  			=  torch.where(
  	    is_gly[..., None].expand(*((-1,) * len(is_gly.shape	))	,	3	)	,	all_atom_positions[..., ca_idx, :]	,	all_atom_positions[..., cb_idx, :]	,	)
  
  	if all_atom_masks is not None:
  		__magic_name__ :					List[Any]  			=  torch.where(
  		    lowerCAmelCase	,	all_atom_masks[..., ca_idx]	,	all_atom_masks[..., cb_idx]	,	)
  		return pseudo_beta, pseudo_beta_mask
  	else:
  		return pseudo_beta
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			Dict[str, torch.Tensor]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					int  			=  batched_gather(
  	    lowerCAmelCase	,	batch['residx_atom37_to_atom14']	,	dim=-2	,	no_batch_dims=len(atomaa.shape[:-2]	)	,	)
  
  	__magic_name__ :					Tuple  			=  atomaa_data * batch['atom37_atom_exists'][..., None]
  
  	return atomaa_data
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Dict[str, torch.Tensor]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					Optional[Any]  			=  template_feats['template_aatype']
  	__magic_name__ :					Union[str, Any]  			=  template_feats['template_torsion_angles_sin_cos']
  	__magic_name__ :					int  			=  template_feats['template_alt_torsion_angles_sin_cos']
  	__magic_name__ :					List[str]  			=  template_feats['template_torsion_angles_mask']
  	__magic_name__ :					int  			=  torch.cat(
  	    [
  	        nn.functional.one_hot(lowerCAmelCase	,	22	),
  	        torsion_angles_sin_cos.reshape(*torsion_angles_sin_cos.shape[:-2]	,	14	),
  	        alt_torsion_angles_sin_cos.reshape(*alt_torsion_angles_sin_cos.shape[:-2]	,	14	),
  	        torsion_angles_mask,
  	    ]	,	dim=-1	,	)
  
  	return template_angle_feat
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Dict[str, torch.Tensor]	,	lowerCAmelCase       :			torch.types.Number	,	lowerCAmelCase       :			torch.types.Number	,	lowerCAmelCase       :			int	,	lowerCAmelCase       :			bool = False	,	lowerCAmelCase       :			float = 1e-20	,	lowerCAmelCase       :			float = 1e8	,	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					Tuple  			=  batch['template_pseudo_beta_mask']
  	__magic_name__ :					List[str]  			=  template_mask[..., None] * template_mask[..., None, :]
  
  	# Compute distogram (this seems to differ slightly from Alg. 5)
  	__magic_name__ :					Optional[Any]  			=  batch['template_pseudo_beta']
  	__magic_name__ :					Union[str, Any]  			=  torch.sum((tpb[..., None, :] - tpb[..., None, :, :]) ** 2	,	dim=-1	,	keepdim=lowerCAmelCase	)
  	__magic_name__ :					Any  			=  torch.linspace(lowerCAmelCase	,	lowerCAmelCase	,	lowerCAmelCase	,	device=tpb.device	) ** 2
  	__magic_name__ :					str  			=  torch.cat([lower[1:], lower.new_tensor([inf]	)]	,	dim=-1	)
  	__magic_name__ :					Optional[Any]  			=  ((dgram > lower) * (dgram < upper)).type(dgram.dtype	)
  
  	__magic_name__ :					str  			=  [dgram, template_mask_ad[..., None]]
  
  	__magic_name__ :					torch.LongTensor  			=  nn.functional.one_hot(
  	    batch['template_aatype']	,	rc.restype_num + 2	,	)
  
  	__magic_name__ :					List[Any]  			=  batch['template_aatype'].shape[-1]
  	to_concat.append(aatype_one_hot[..., None, :, :].expand(*aatype_one_hot.shape[:-2]	,	lowerCAmelCase	,	-1	,	-1	)	)
  	to_concat.append(aatype_one_hot[..., None, :].expand(*aatype_one_hot.shape[:-2]	,	-1	,	lowerCAmelCase	,	-1	)	)
  
  	__magic_name__			,       __magic_name__			,       __magic_name__ :					List[str]  			=  [rc.atom_order[a] for a in ['N', 'CA', 'C']]
  	__magic_name__ :					Dict  			=  Rigid.make_transform_from_reference(
  	    n_xyz=batch['template_all_atom_positions'][..., n, :]	,	ca_xyz=batch['template_all_atom_positions'][..., ca, :]	,	c_xyz=batch['template_all_atom_positions'][..., c, :]	,	eps=lowerCAmelCase	,	)
  	__magic_name__ :					int  			=  rigids.get_trans()[..., None, :, :]
  	__magic_name__ :					List[str]  			=  rigids[..., None].invert_apply(lowerCAmelCase	)
  
  	__magic_name__ :					Optional[int]  			=  torch.rsqrt(eps + torch.sum(rigid_vec**2	,	dim=-1	)	)
  
  	__magic_name__ :					Tuple  			=  batch['template_all_atom_mask']
  	__magic_name__ :					Union[str, Any]  			=  t_aa_masks[..., n] * t_aa_masks[..., ca] * t_aa_masks[..., c]
  	__magic_name__ :					Dict  			=  template_mask[..., None] * template_mask[..., None, :]
  
  	__magic_name__ :					Union[str, Any]  			=  inv_distance_scalar * template_mask_ad
  	__magic_name__ :					int  			=  rigid_vec * inv_distance_scalar[..., None]
  
  	if not use_unit_vector:
  		__magic_name__ :					Union[str, Any]  			=  unit_vector * 0.0
  
  	to_concat.extend(torch.unbind(unit_vector[..., None, :]	,	dim=-1	)	)
  	to_concat.append(template_mask_ad[..., None]	)
  
  	__magic_name__ :					Optional[int]  			=  torch.cat(lowerCAmelCase	,	dim=-1	)
  	__magic_name__ :					Tuple  			=  act * template_mask_ad[..., None]
  
  	return act
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Dict[str, torch.Tensor]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					torch.LongTensor  			=  nn.functional.one_hot(batch['extra_msa']	,	23	)
  	__magic_name__ :					str  			=  [
  	    msa_ahot,
  	    batch['extra_has_deletion'].unsqueeze(-1	),
  	    batch['extra_deletion_value'].unsqueeze(-1	),
  	]
  	return torch.cat(lowerCAmelCase	,	dim=-1	)
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Rigid	,	lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	,	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					Optional[int]  			=  rrgdf[aatype, ...]
  
  	# [*, N, 8] transformations, i.e.
  	#   One [*, N, 8, 3, 3] rotation matrix and
  	#   One [*, N, 8, 3]    translation matrix
  	__magic_name__ :					List[str]  			=  r.from_tensor_axa(lowerCAmelCase	)
  
  	__magic_name__ :					List[Any]  			=  alpha.new_zeros((*((1,) * len(alpha.shape[:-1]	)), 2)	)
  	__magic_name__ :					List[Any]  			=  1
  
  	# [*, N, 8, 2]
  	__magic_name__ :					List[Any]  			=  torch.cat([bb_rot.expand(*alpha.shape[:-2]	,	-1	,	-1	), alpha]	,	dim=-2	)
  
  	# [*, N, 8, 3, 3]
  	# Produces rotation matrices of the form:
  	# [
  	#   [1, 0  , 0  ],
  	#   [0, a_2,-a_1],
  	#   [0, a_1, a_2]
  	# ]
  	# This follows the original code rather than the supplement, which uses
  	# different indices.
  
  	__magic_name__ :					List[Any]  			=  alpha.new_zeros(default_r.get_rots().get_rot_mats().shape	)
  	__magic_name__ :					Dict  			=  1
  	__magic_name__ :					str  			=  alpha[..., 1]
  	__magic_name__ :					str  			=  -alpha[..., 0]
  	__magic_name__ :					Optional[int]  			=  alpha
  
  	__magic_name__ :					Optional[Any]  			=  default_r.compose(Rigid(Rotation(rot_mats=lowerCAmelCase	)	,	lowerCAmelCase	)	)
  
  	__magic_name__ :					Optional[Any]  			=  all_frames[..., 5]
  	__magic_name__ :					Union[str, Any]  			=  all_frames[..., 6]
  	__magic_name__ :					Any  			=  all_frames[..., 7]
  
  	__magic_name__ :					Optional[Any]  			=  all_frames[..., 4]
  	__magic_name__ :					Optional[int]  			=  chia_frame_to_bb.compose(lowerCAmelCase	)
  	__magic_name__ :					Tuple  			=  chia_frame_to_bb.compose(lowerCAmelCase	)
  	__magic_name__ :					Union[str, Any]  			=  chia_frame_to_bb.compose(lowerCAmelCase	)
  
  	__magic_name__ :					Tuple  			=  Rigid.cat(
  	    [
  	        all_frames[..., :5],
  	        chia_frame_to_bb.unsqueeze(-1	),
  	        chia_frame_to_bb.unsqueeze(-1	),
  	        chia_frame_to_bb.unsqueeze(-1	),
  	    ]	,	dim=-1	,	)
  
  	__magic_name__ :					Union[str, Any]  			=  r[..., None].compose(lowerCAmelCase	)
  
  	return all_frames_to_global
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Rigid	,	lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	,	lowerCAmelCase       :			torch.Tensor	,	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					Optional[Any]  			=  group_idx[aatype, ...]
  
  	# [*, N, 14, 8]
  	__magic_name__ :					torch.LongTensor  			=  nn.functional.one_hot(
  	    lowerCAmelCase	,	num_classes=default_frames.shape[-3]	,	)
  
  	# [*, N, 14, 8]
  	__magic_name__ :					Any  			=  r[..., None, :] * group_mask_one_hot
  
  	# [*, N, 14]
  	__magic_name__ :					List[Any]  			=  t_atoms_to_global.map_tensor_fn(lambda lowerCAmelCase	: torch.sum(lowerCAmelCase	,	dim=-1	)	)
  
  	# [*, N, 14, 1]
  	__magic_name__ :					List[Any]  			=  atom_mask[aatype, ...].unsqueeze(-1	)
  
  	# [*, N, 14, 3]
  	__magic_name__ :					Dict  			=  lit_positions[aatype, ...]
  	__magic_name__ :					Optional[Any]  			=  t_atoms_to_global.apply(lowerCAmelCase	)
  	__magic_name__ :					Union[str, Any]  			=  pred_positions * atom_mask
  
  	return pred_positions
style_context: 
  
  
  '''simple docstring'''
  
  lowerCAmelCase   :int								=    [
      ['''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    (    lowerCAmelCase       :			Tuple	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					Union[str, Any]  			=  set()
  	for row in edge_array:
  		for item in row:
  			distinct_edge.add(item[0]	)
  	return list(lowerCAmelCase	)
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			List[str]	,	lowerCAmelCase       :			Optional[int]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					List[Any]  			=  ['0'] * len(lowerCAmelCase	)
  	for i, row in enumerate(lowerCAmelCase	):
  		for item in row:
  			if distinct_edge in item[0]:
  				__magic_name__ :					str  			=  '1'
  				break
  	return "".join(lowerCAmelCase	)
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Tuple	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					Any  			=  get_distinct_edge(lowerCAmelCase	)
  	__magic_name__ :					Union[str, Any]  			=  {}
  
  	for item in distinct_edge:
  		__magic_name__ :					Union[str, Any]  			=  get_bitcode(lowerCAmelCase	,	lowerCAmelCase	)
  		# print('bit',bit)
  		# bt=''.join(bit)
  		__magic_name__ :					Dict  			=  bit.count('1'	)
  		__magic_name__ :					Dict  			=  [s, bit]
  	# Store [Distinct edge, WT(Bitcode), Bitcode] in descending order
  	__magic_name__ :					Optional[Any]  			=  [
  	    [k, v[0], v[1]]
  	    for k, v in sorted(frequency_table.items()	,	key=lambda lowerCAmelCase	: v[1][0]	,	reverse=lowerCAmelCase	)
  	]
  	return sorted_frequency_table
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			List[str]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					Tuple  			=  {}
  	for _, item in enumerate(lowerCAmelCase	):
  		nodes.setdefault(item[2]	,	[]	).append(item[0]	)
  	return nodes
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			List[str]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					str  			=  {}
  	for key, value in nodes.items():
  		__magic_name__ :					Union[str, Any]  			=  value
  	return cluster
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			List[str]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	return [i * 100 / len(lowerCAmelCase	) for i in cluster]
  
  
  
  
  
  def lowerCamelCase    (    ):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	print('\nNodes\n'	)
  	for key, value in nodes.items():
  		print(lowerCAmelCase	,	lowerCAmelCase	)
  	print('\nSupport\n'	)
  	print(lowerCAmelCase	)
  	print('\n Cluster \n'	)
  	for key, value in sorted(cluster.items()	,	reverse=lowerCAmelCase	):
  		print(lowerCAmelCase	,	lowerCAmelCase	)
  	print('\n Graph\n'	)
  	for key, value in graph.items():
  		print(lowerCAmelCase	,	lowerCAmelCase	)
  	print('\n Edge List of Frequent subgraphs \n'	)
  	for edge_list in freq_subgraph_edge_list:
  		print(lowerCAmelCase	)
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			int	,	lowerCAmelCase       :			str	,	lowerCAmelCase       :			Optional[Any]	,	lowerCAmelCase       :			int	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	for i in cluster[ca]:
  		__magic_name__ :					Tuple  			=  0
  		__magic_name__ :					Any  			=  ca + 1
  		while ca < max(cluster.keys()	):
  			for j in cluster[ca]:
  				if int(lowerCAmelCase	,	2	) & int(lowerCAmelCase	,	2	) == int(lowerCAmelCase	,	2	):
  					if tuple(nodes[i]	) in graph:
  						graph[tuple(nodes[i]	)].append(nodes[j]	)
  					else:
  						__magic_name__ :					List[Any]  			=  [nodes[j]]
  					count += 1
  			if count == 0:
  				__magic_name__ :					Tuple  			=  ca + 1
  			else:
  				break
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Any	,	lowerCAmelCase       :			List[Any]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					str  			=  cluster[max(cluster.keys()	)]
  	__magic_name__ :					Dict  			=  'Header'
  	__magic_name__ :					Optional[Any]  			=  {}
  	for i in x:
  		if (["Header"],) in graph:
  			graph[(["Header"],)].append(x[i]	)
  		else:
  			__magic_name__ :					List[str]  			=  [x[i]]
  	for i in x:
  		__magic_name__ :					Union[str, Any]  			=  [['Header']]
  	__magic_name__ :					List[str]  			=  1
  	while i < max(lowerCAmelCase	) - 1:
  		create_edge(lowerCAmelCase	,	lowerCAmelCase	,	lowerCAmelCase	,	lowerCAmelCase	)
  		__magic_name__ :					Dict  			=  i + 1
  	return graph
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Dict	,	lowerCAmelCase       :			Tuple	,	lowerCAmelCase       :			List[Any]	,	lowerCAmelCase       :			Union[str, Any]=None	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					str  			=  (path or []) + [start]
  	if start == end:
  		paths.append(lowerCAmelCase	)
  	for node in graph[start]:
  		if tuple(lowerCAmelCase	) not in path:
  			my_dfs(lowerCAmelCase	,	tuple(lowerCAmelCase	)	,	lowerCAmelCase	,	lowerCAmelCase	)
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Optional[Any]	,	lowerCAmelCase       :			Tuple	,	lowerCAmelCase       :			Union[str, Any]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					Union[str, Any]  			=  int(s / 100 * (len(lowerCAmelCase	) - 1)	)
  	for i in cluster[k]:
  		my_dfs(lowerCAmelCase	,	tuple(cluster[k][i]	)	,	(['Header'],)	)
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			Optional[int]	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	__magic_name__ :					str  			=  []
  	for edges in paths:
  		__magic_name__ :					List[Any]  			=  []
  		for j in range(len(lowerCAmelCase	) - 1	):
  			__magic_name__ :					List[str]  			=  list(edges[j]	)
  			for e in temp:
  				__magic_name__ :					Optional[int]  			=  (e[0], e[1])
  				el.append(lowerCAmelCase	)
  		freq_sub_el.append(lowerCAmelCase	)
  	return freq_sub_el
  
  
  
  
  
  def lowerCamelCase    (    lowerCAmelCase       :			str	):
  
  
  
  
  
  	"""simple docstring"""
  
  
  
  
  
  
  
  	for i in range(len(lowerCAmelCase	)	):
  		for j in range(len(edge_array[i]	)	):
  			__magic_name__ :					Any  			=  edge_array[i][j].split('-'	)
  			__magic_name__ :					Tuple  			=  t
  
  
  if __name__ == "__main__":
  							preprocess(edge_array)
  							lowerCAmelCase   :List[str]								=    get_frequency_table(edge_array)
  							lowerCAmelCase   :List[str]								=    get_nodes(frequency_table)
  							lowerCAmelCase   :Optional[int]								=    get_cluster(nodes)
  							lowerCAmelCase   :Tuple								=    get_support(cluster)
  							lowerCAmelCase   :Tuple								=    construct_graph(cluster, nodes)
  							find_freq_subgraph_given_support(6_0, cluster, graph)
  							lowerCAmelCase   :list								=    []
  							lowerCAmelCase   :str								=    freq_subgraphs_edge_list(paths)
  							print_all()