






from typing import Dict

import numpy as np
import torch

from . import residue_constants as rc
from .tensor_utils import tensor_tree_map, tree_map

def   __lowercase       (			snake_case			):







				"""simple docstring"""






				__magic_name__		:Tuple   =   []
				__magic_name__		:Tuple   =   []
				__magic_name__		:Any   =   []

				for rt in rc.restypes:
								__magic_name__		:List[Any]   =   rc.restype_name_to_atomaa_names[rc.restype_atoa[rt]]
								restype_atomaa_to_atomaa_list.append([(rc.atom_order[name] if name else 0) for name in atom_names]			)
								__magic_name__		:List[Any]   =   {name: i for i, name in enumerate(snake_case			)}
								restype_atomaa_to_atomaa_list.append(
								    [(atom_name_to_idxaa[name] if name in atom_name_to_idxaa else 0) for name in rc.atom_types]			)

								restype_atomaa_mask_list.append([(1.0 if name else 0.0) for name in atom_names]			)

				# Add dummy mapping for restype 'UNK'
				restype_atomaa_to_atomaa_list.append([0] * 1_4			)
				restype_atomaa_to_atomaa_list.append([0] * 3_7			)
				restype_atomaa_mask_list.append([0.0] * 1_4			)

				__magic_name__		:int   =   torch.tensor(
				    snake_case,	dtype=torch.intaa,	device=protein['''aatype'''].device,	)
				__magic_name__		:Any   =   torch.tensor(
				    snake_case,	dtype=torch.intaa,	device=protein['''aatype'''].device,	)
				__magic_name__		:List[Any]   =   torch.tensor(
				    snake_case,	dtype=torch.floataa,	device=protein['''aatype'''].device,	)
				__magic_name__		:Optional[int]   =   protein['''aatype'''].to(torch.long			)

				# create the mapping for (residx, atom14) --> atom37, i.e. an array
				# with shape (num_res, 14) containing the atom37 indices for this protein
				__magic_name__		:List[str]   =   restype_atomaa_to_atomaa[protein_aatype]
				__magic_name__		:str   =   restype_atomaa_mask[protein_aatype]

				__magic_name__		:int   =   residx_atomaa_mask
				__magic_name__		:Any   =   residx_atomaa_to_atomaa.long()

				# create the gather indices for mapping back
				__magic_name__		:Dict   =   restype_atomaa_to_atomaa[protein_aatype]
				__magic_name__		:List[str]   =   residx_atomaa_to_atomaa.long()

				# create the corresponding mask
				__magic_name__		:int   =   torch.zeros([2_1, 3_7],	dtype=torch.floataa,	device=protein['''aatype'''].device			)
				for restype, restype_letter in enumerate(rc.restypes			):
								__magic_name__		:str   =   rc.restype_atoa[restype_letter]
								__magic_name__		:Dict   =   rc.residue_atoms[restype_name]
								for atom_name in atom_names:
												__magic_name__		:Dict   =   rc.atom_order[atom_name]
												__magic_name__		:Optional[int]   =   1

				__magic_name__		:str   =   restype_atomaa_mask[protein_aatype]
				__magic_name__		:List[str]   =   residx_atomaa_mask

				return protein

def   __lowercase       (			snake_case			):







				"""simple docstring"""






				__magic_name__		:Tuple   =   tree_map(lambda snake_case			: torch.tensor(snake_case,	device=batch['''aatype'''].device			),	snake_case,	np.ndarray			)
				__magic_name__		:Optional[int]   =   tensor_tree_map(lambda snake_case			: np.array(snake_case			),	make_atomaa_masks(snake_case			)			)
				return out














from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available


SCREAMING_SNAKE_CASE__   :      Optional[int]				=		{"""tokenization_herbert""": ["""HerbertTokenizer"""]}

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE__   :      Optional[Any]				=		["""HerbertTokenizerFast"""]


if TYPE_CHECKING:
					from .tokenization_herbert import HerbertTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_herbert_fast import HerbertTokenizerFast

else:
					import sys

					SCREAMING_SNAKE_CASE__   :      Union[str, Any]				=		_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)






