






class 							_lowerCAmelCase:





       """simple docstring"""







       def __init__(   self				):
         UpperCamelCase_:   Optional[int]        =							0
         UpperCamelCase_:   Tuple        =							0
         UpperCamelCase_:   Dict        =							{}





       def      _a       (   self    ,     _lowerCamelCase				):
         if vertex not in self.adjacency:
           UpperCamelCase_:   int        =							{}
           self.num_vertices += 1





       def      _a       (   self    ,     _lowerCamelCase    ,     _lowerCamelCase    ,     _lowerCamelCase				):
         self.add_vertex(A_				)
         self.add_vertex(A_				)

         if head == tail:
           return

         UpperCamelCase_:   Optional[Any]        =							weight
         UpperCamelCase_:   Optional[Any]        =							weight





       def      _a       (   self				):
         UpperCamelCase_:   List[str]        =							self.get_edges()
         for edge in edges:
           UpperCamelCase_ ,UpperCamelCase_ ,UpperCamelCase_:   int        =							edge
           edges.remove((tail, head, weight)				)
         for i in range(len(A_				)				):
           UpperCamelCase_:   Optional[int]        =							list(edges[i]				)

         edges.sort(key=lambda _lowerCamelCase				: e[2]				)
         for i in range(len(A_				) - 1				):
           if edges[i][2] >= edges[i + 1][2]:
             UpperCamelCase_:   Dict        =							edges[i][2] + 1
         for edge in edges:
           UpperCamelCase_ ,UpperCamelCase_ ,UpperCamelCase_:   str        =							edge
           UpperCamelCase_:   Union[str, Any]        =							weight
           UpperCamelCase_:   Dict        =							weight





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





       def      _a       (   self				):
         UpperCamelCase_:   List[str]        =							[]
         for tail in self.adjacency:
           for head in self.adjacency[tail]:
             output.append((tail, head, self.adjacency[head][tail])				)
         return output





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





       @staticmethod
       def      _a       (   _lowerCamelCase=None    ,     _lowerCamelCase=None				):
         UpperCamelCase_:   List[str]        =							Graph()
         if vertices is None:
           UpperCamelCase_:   Optional[Any]        =							[]
         if edges is None:
           UpperCamelCase_:   Dict        =							[]
         for vertex in vertices:
           g.add_vertex(A_				)
         for edge in edges:
           g.add_edge(*A_				)
         return g




       class 							_lowerCAmelCase:





              """simple docstring"""







              def __init__(   self				):
                UpperCamelCase_:   Dict        =							{}
                UpperCamelCase_:   Any        =							{}





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





              def      _a       (   self    ,     _lowerCamelCase				):
                if item in self.parent:
                  return self.find(A_				)

                UpperCamelCase_:   Optional[int]        =							item
                UpperCamelCase_:   List[str]        =							0
                return item





              def      _a       (   self    ,     _lowerCamelCase				):
                if item not in self.parent:
                  return self.make_set(A_				)
                if item != self.parent[item]:
                  UpperCamelCase_:   int        =							self.find(self.parent[item]				)
                return self.parent[item]





              def      _a       (   self    ,     _lowerCamelCase    ,     _lowerCamelCase				):
                UpperCamelCase_:   Optional[int]        =							self.find(A_				)
                UpperCamelCase_:   Tuple        =							self.find(A_				)

                if roota == roota:
                  return roota

                if self.rank[roota] > self.rank[roota]:
                  UpperCamelCase_:   Optional[Any]        =							roota
                  return roota

                if self.rank[roota] < self.rank[roota]:
                  UpperCamelCase_:   Tuple        =							roota
                  return roota

                if self.rank[roota] == self.rank[roota]:
                  self.rank[roota] += 1
                  UpperCamelCase_:   Optional[Any]        =							roota
                  return roota
                return None







       @staticmethod
       def      _a       (   _lowerCamelCase				):
         UpperCamelCase_:   Dict        =							graph.num_vertices

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

           UpperCamelCase_:   str        =							graph.get_edges()
           for edge in edges:
             UpperCamelCase_ ,UpperCamelCase_ ,UpperCamelCase_:   List[str]        =							edge
             edges.remove((tail, head, weight)				)
           for edge in edges:
             UpperCamelCase_ ,UpperCamelCase_ ,UpperCamelCase_:   int        =							edge
             UpperCamelCase_:   Optional[Any]        =							union_find.find(A_				)
             UpperCamelCase_:   List[str]        =							union_find.find(A_				)
             if seta != seta:
               if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
                 UpperCamelCase_:   Dict        =							[head, tail, weight]

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

"""simple docstring"""


from torch import nn






def    _snake_case					(		snake_case__ :  Union[str, Any]  ):
	if act_fn in ["swish", "silu"]:
		return nn.SiLU()
	elif act_fn == "mish":
		return nn.Mish()
	elif act_fn == "gelu":
		return nn.GELU()
	else:
		raise ValueError(F'Unsupported activation function: {act_fn}'  )