






"""simple docstring"""





import heapq as hq
import math
from collections.abc import Iterator






class      a						:






    def __init__(       self     :							int       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]					)     ->		Dict:
      lowerCamelCase_         =						str(id_					)
      lowerCamelCase_         =						None
      lowerCamelCase_         =						None
      lowerCamelCase_         =						[]
      lowerCamelCase_         =						{}  # {vertex:distance}






    def __lt__(       self     :							Union[str, Any]       ,						__SCREAMING_SNAKE_CASE     :							str					)     ->		List[str]:
      return self.key < other.key






    def __repr__(       self     :							Tuple					)     ->		Tuple:
      return self.id






    def    UpperCamelCase       (       self     :							List[Any]       ,						__SCREAMING_SNAKE_CASE     :							Any					)     ->		List[str]:
      self.neighbors.append(__SCREAMING_SNAKE_CASE					)






    def    UpperCamelCase       (       self     :							Union[str, Any]       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]       ,						__SCREAMING_SNAKE_CASE     :							Any					)     ->		str:
      lowerCamelCase_         =						weight







def      lowerCamelCase__       (							_lowerCamelCase       :		Union[str, Any]		,				_lowerCamelCase       :		List[str]		,				_lowerCamelCase       :		List[Any]		,				_lowerCamelCase       :		str )      ->				Union[str, Any]:
  # add the neighbors:
  graph[a - 1].add_neighbor(graph[b - 1] )
  graph[b - 1].add_neighbor(graph[a - 1] )
  # add the edges:
  graph[a - 1].add_edge(graph[b - 1]		,				_lowerCamelCase )
  graph[b - 1].add_edge(graph[a - 1]		,				_lowerCamelCase )







def      lowerCamelCase__       (							_lowerCamelCase       :		list		,				_lowerCamelCase       :		Vertex )      ->				list:
  lowerCamelCase_         =						[]
  for u in graph:
    lowerCamelCase_         =						math.inf
    lowerCamelCase_         =						None
  lowerCamelCase_         =						0
  lowerCamelCase_         =						graph[:]
  while q:
    lowerCamelCase_         =						min(_lowerCamelCase )
    q.remove(_lowerCamelCase )
    for v in u.neighbors:
      if (v in q) and (u.edges[v.id] < v.key):
        lowerCamelCase_         =						u
        lowerCamelCase_         =						u.edges[v.id]
  for i in range(1		,				len(_lowerCamelCase ) ):
    a.append((int(graph[i].id ) + 1, int(graph[i].pi.id ) + 1) )
  return a







def      lowerCamelCase__       (							_lowerCamelCase       :		list		,				_lowerCamelCase       :		Vertex )      ->				Iterator[tuple]:
  for u in graph:
    lowerCamelCase_         =						math.inf
    lowerCamelCase_         =						None
  lowerCamelCase_         =						0

  lowerCamelCase_         =						list(_lowerCamelCase )
  hq.heapify(_lowerCamelCase )

  while h:
    lowerCamelCase_         =						hq.heappop(_lowerCamelCase )
    for v in u.neighbors:
      if (v in h) and (u.edges[v.id] < v.key):
        lowerCamelCase_         =						u
        lowerCamelCase_         =						u.edges[v.id]
        hq.heapify(_lowerCamelCase )

  for i in range(1		,				len(_lowerCamelCase ) ):
    yield (int(graph[i].id ) + 1, int(graph[i].pi.id ) + 1)







def      lowerCamelCase__       (							)      ->				None:
  pass


if __name__ == "__main__":
  import doctest

  doctest.testmod()












"""simple docstring"""





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


_SCREAMING_SNAKE_CASE					:				Union[str, Any]					    =						{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_SCREAMING_SNAKE_CASE					:				Union[str, Any]					    =						{
    '''vocab_file''': {
        '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt''',
    },
    '''tokenizer_file''': {
        '''unc-nlp/lxmert-base-uncased''': (
            '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json'''
        ),
    },
}

_SCREAMING_SNAKE_CASE					:				Any					    =						{
    '''unc-nlp/lxmert-base-uncased''': 512,
}

_SCREAMING_SNAKE_CASE					:				int					    =						{
    '''unc-nlp/lxmert-base-uncased''': {'''do_lower_case''': True},
}






class      a						(					__snake_case		):
    SCREAMING_SNAKE_CASE						:     int						= VOCAB_FILES_NAMES
    SCREAMING_SNAKE_CASE						:     Optional[Any]						= PRETRAINED_VOCAB_FILES_MAP
    SCREAMING_SNAKE_CASE						:     Any						= PRETRAINED_INIT_CONFIGURATION
    SCREAMING_SNAKE_CASE						:     Any						= PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    SCREAMING_SNAKE_CASE						:     Optional[Any]						= LxmertTokenizer






    def __init__(       self     :							str       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=None       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=None       ,						__SCREAMING_SNAKE_CASE     :							str=True       ,						__SCREAMING_SNAKE_CASE     :							List[Any]="[UNK]"       ,						__SCREAMING_SNAKE_CASE     :							int="[SEP]"       ,						__SCREAMING_SNAKE_CASE     :							int="[PAD]"       ,						__SCREAMING_SNAKE_CASE     :							List[Any]="[CLS]"       ,						__SCREAMING_SNAKE_CASE     :							Any="[MASK]"       ,						__SCREAMING_SNAKE_CASE     :							List[str]=True       ,						__SCREAMING_SNAKE_CASE     :							List[str]=None       ,						**__SCREAMING_SNAKE_CASE     :							Any       ,						)     ->		Any:
      super().__init__(
          __SCREAMING_SNAKE_CASE       ,						tokenizer_file=__SCREAMING_SNAKE_CASE       ,						do_lower_case=__SCREAMING_SNAKE_CASE       ,						unk_token=__SCREAMING_SNAKE_CASE       ,						sep_token=__SCREAMING_SNAKE_CASE       ,						pad_token=__SCREAMING_SNAKE_CASE       ,						cls_token=__SCREAMING_SNAKE_CASE       ,						mask_token=__SCREAMING_SNAKE_CASE       ,						tokenize_chinese_chars=__SCREAMING_SNAKE_CASE       ,						strip_accents=__SCREAMING_SNAKE_CASE       ,						**__SCREAMING_SNAKE_CASE       ,						)

      lowerCamelCase_         =						json.loads(self.backend_tokenizer.normalizer.__getstate__()					)
      if (
          normalizer_state.get('lowercase'       ,						__SCREAMING_SNAKE_CASE					) != do_lower_case
          or normalizer_state.get('strip_accents'       ,						__SCREAMING_SNAKE_CASE					) != strip_accents
          or normalizer_state.get('handle_chinese_chars'       ,						__SCREAMING_SNAKE_CASE					) != tokenize_chinese_chars
      ):
        lowerCamelCase_         =						getattr(__SCREAMING_SNAKE_CASE       ,						normalizer_state.pop('type'					)					)
        lowerCamelCase_         =						do_lower_case
        lowerCamelCase_         =						strip_accents
        lowerCamelCase_         =						tokenize_chinese_chars
        lowerCamelCase_         =						normalizer_class(**__SCREAMING_SNAKE_CASE					)

      lowerCamelCase_         =						do_lower_case






    def    UpperCamelCase       (       self     :							Tuple       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]       ,						__SCREAMING_SNAKE_CASE     :							Tuple=None					)     ->		Dict:
      lowerCamelCase_         =						[self.cls_token_id] + token_ids_a + [self.sep_token_id]

      if token_ids_a:
        output += token_ids_a + [self.sep_token_id]

      return output






    def    UpperCamelCase       (       self     :							str       ,						__SCREAMING_SNAKE_CASE     :							List[int]       ,						__SCREAMING_SNAKE_CASE     :							Optional[List[int]] = None					)     ->		List[int]:
      lowerCamelCase_         =						[self.sep_token_id]
      lowerCamelCase_         =						[self.cls_token_id]
      if token_ids_a is None:
        return len(cls + token_ids_a + sep					) * [0]
      return len(cls + token_ids_a + sep					) * [0] + len(token_ids_a + sep					) * [1]






    def    UpperCamelCase       (       self     :							List[str]       ,						__SCREAMING_SNAKE_CASE     :							str       ,						__SCREAMING_SNAKE_CASE     :							Optional[str] = None					)     ->		Tuple[str]:
      lowerCamelCase_         =						self._tokenizer.model.save(__SCREAMING_SNAKE_CASE       ,						name=__SCREAMING_SNAKE_CASE					)
      return tuple(__SCREAMING_SNAKE_CASE					)




