



class 		UpperCAmelCase						:





   def __init__(	self			):
         _lowerCAmelCase 			=  0
         _lowerCAmelCase 			=  0
         _lowerCAmelCase 			=  {}





   def 	__lowerCAmelCase							(	self       ,     _lowerCAmelCase			):
         if vertex not in self.adjacency:
               _lowerCAmelCase 			=  {}
               self.num_vertices += 1





   def 	__lowerCAmelCase							(	self       ,     _lowerCAmelCase       ,     _lowerCAmelCase       ,     _lowerCAmelCase			):
         self.add_vertex(_lowerCAmelCase			)
         self.add_vertex(_lowerCAmelCase			)

         if head == tail:
               return

         _lowerCAmelCase 			=  weight
         _lowerCAmelCase 			=  weight





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  self.get_edges()
         for edge in edges:
               _lowerCAmelCase			,   _lowerCAmelCase			,   _lowerCAmelCase 			=  edge
               edges.remove((tail, head, weight)			)
         for i in range(len(_lowerCAmelCase			)			):
               _lowerCAmelCase 			=  list(edges[i]			)

         edges.sort(key=lambda _lowerCAmelCase			: e[2]			)
         for i in range(len(_lowerCAmelCase			) - 1			):
               if edges[i][2] >= edges[i + 1][2]:
                     _lowerCAmelCase 			=  edges[i][2] + 1
         for edge in edges:
               _lowerCAmelCase			,   _lowerCAmelCase			,   _lowerCAmelCase 			=  edge
               _lowerCAmelCase 			=  weight
               _lowerCAmelCase 			=  weight





   def __str__(	self			):
         _lowerCAmelCase 			=  ''''''
         for tail in self.adjacency:
               for head in self.adjacency[tail]:
                     _lowerCAmelCase 			=  self.adjacency[head][tail]
                     string += F'''{head} -> {tail} == {weight}\n'''
         return string.rstrip('''\n'''			)





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  []
         for tail in self.adjacency:
               for head in self.adjacency[tail]:
                     output.append((tail, head, self.adjacency[head][tail])			)
         return output





   def 	__lowerCAmelCase							(	self			):
         return self.adjacency.keys()





   @staticmethod
   def 	__lowerCAmelCase							(	_lowerCAmelCase=None       ,     _lowerCAmelCase=None			):
         _lowerCAmelCase 			=  Graph()
         if vertices is None:
               _lowerCAmelCase 			=  []
         if edges is None:
               _lowerCAmelCase 			=  []
         for vertex in vertices:
               g.add_vertex(_lowerCAmelCase			)
         for edge in edges:
               g.add_edge(*_lowerCAmelCase			)
         return g





   class 		UpperCAmelCase						:





      def __init__(	self			):
            _lowerCAmelCase 			=  {}
            _lowerCAmelCase 			=  {}





      def __len__(	self			):
            return len(self.parent			)





      def 	__lowerCAmelCase							(	self       ,     _lowerCAmelCase			):
            if item in self.parent:
                  return self.find(_lowerCAmelCase			)

            _lowerCAmelCase 			=  item
            _lowerCAmelCase 			=  0
            return item





      def 	__lowerCAmelCase							(	self       ,     _lowerCAmelCase			):
            if item not in self.parent:
                  return self.make_set(_lowerCAmelCase			)
            if item != self.parent[item]:
                  _lowerCAmelCase 			=  self.find(self.parent[item]			)
            return self.parent[item]





      def 	__lowerCAmelCase							(	self       ,     _lowerCAmelCase       ,     _lowerCAmelCase			):
            _lowerCAmelCase 			=  self.find(_lowerCAmelCase			)
            _lowerCAmelCase 			=  self.find(_lowerCAmelCase			)

            if roota == roota:
                  return roota

            if self.rank[roota] > self.rank[roota]:
                  _lowerCAmelCase 			=  roota
                  return roota

            if self.rank[roota] < self.rank[roota]:
                  _lowerCAmelCase 			=  roota
                  return roota

            if self.rank[roota] == self.rank[roota]:
                  self.rank[roota] += 1
                  _lowerCAmelCase 			=  roota
                  return roota
            return None






   @staticmethod
   def 	__lowerCAmelCase							(	_lowerCAmelCase			):
         _lowerCAmelCase 			=  graph.num_vertices

         _lowerCAmelCase 			=  Graph.UnionFind()
         _lowerCAmelCase 			=  []
         while num_components > 1:
               _lowerCAmelCase 			=  {}
               for vertex in graph.get_vertices():
                     _lowerCAmelCase 			=  -1

               _lowerCAmelCase 			=  graph.get_edges()
               for edge in edges:
                     _lowerCAmelCase			,   _lowerCAmelCase			,   _lowerCAmelCase 			=  edge
                     edges.remove((tail, head, weight)			)
               for edge in edges:
                     _lowerCAmelCase			,   _lowerCAmelCase			,   _lowerCAmelCase 			=  edge
                     _lowerCAmelCase 			=  union_find.find(_lowerCAmelCase			)
                     _lowerCAmelCase 			=  union_find.find(_lowerCAmelCase			)
                     if seta != seta:
                           if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
                                 _lowerCAmelCase 			=  [head, tail, weight]

                           if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
                                 _lowerCAmelCase 			=  [head, tail, weight]
               for vertex in cheap_edge:
                     if cheap_edge[vertex] != -1:
                           _lowerCAmelCase			,   _lowerCAmelCase			,   _lowerCAmelCase 			=  cheap_edge[vertex]
                           if union_find.find(_lowerCAmelCase			) != union_find.find(_lowerCAmelCase			):
                                 union_find.union(_lowerCAmelCase       ,     _lowerCAmelCase			)
                                 mst_edges.append(cheap_edge[vertex]			)
                                 _lowerCAmelCase 			=  num_components - 1
         _lowerCAmelCase 			=  Graph.build(edges=_lowerCAmelCase			)
         return mst




# Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


UpperCAmelCase_									=							{
    "configuration_cpmant": ["CPMANT_PRETRAINED_CONFIG_ARCHIVE_MAP", "CpmAntConfig"],
    "tokenization_cpmant": ["CpmAntTokenizer"],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    UpperCAmelCase_									=							[
        "CPMANT_PRETRAINED_MODEL_ARCHIVE_LIST",
        "CpmAntForCausalLM",
        "CpmAntModel",
        "CpmAntPreTrainedModel",
    ]


if TYPE_CHECKING:
    from .configuration_cpmant import CPMANT_PRETRAINED_CONFIG_ARCHIVE_MAP, CpmAntConfig
    from .tokenization_cpmant import CpmAntTokenizer

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_cpmant import (
            CPMANT_PRETRAINED_MODEL_ARCHIVE_LIST,
            CpmAntForCausalLM,
            CpmAntModel,
            CpmAntPreTrainedModel,
        )


else:
    import sys

    UpperCAmelCase_									=							_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)