






'''simple docstring'''



class UpperCAmelCase_					:




      """simple docstring"""




      def __init__( self			:		List[Any]     ,      UpperCAmelCase			:		list		)  ->  None:


       '''simple docstring'''

       lowercase					:   Union[str, Any]				  =set_counts
       lowercase					:   Any				  =max(UpperCAmelCase		)
       lowercase					:   Optional[Any]				  =len(UpperCAmelCase		)
       lowercase					:   Tuple				  =[1] * num_sets
       lowercase					:   List[Any]				  =list(range(UpperCAmelCase		)		)






      def 				A__      ( self			:		Optional[int]     ,      UpperCAmelCase			:		int     ,      UpperCAmelCase			:		int		)  ->  bool:


       '''simple docstring'''

       lowercase					:   int				  =self.get_parent(UpperCAmelCase		)
       lowercase					:   int				  =self.get_parent(UpperCAmelCase		)

       if src_parent == dst_parent:
        return False

       if self.ranks[dst_parent] >= self.ranks[src_parent]:
        self.set_counts[dst_parent] += self.set_counts[src_parent]
        lowercase					:   str				  =0
        lowercase					:   Dict				  =dst_parent
        if self.ranks[dst_parent] == self.ranks[src_parent]:
         self.ranks[dst_parent] += 1
        lowercase					:   Optional[Any]				  =self.set_counts[dst_parent]
       else:
        self.set_counts[src_parent] += self.set_counts[dst_parent]
        lowercase					:   List[str]				  =0
        lowercase					:   Tuple				  =src_parent
        lowercase					:   int				  =self.set_counts[src_parent]

       lowercase					:   Union[str, Any]				  =max(self.max_set     ,      UpperCAmelCase		)
       return True






      def 				A__      ( self			:		int     ,      UpperCAmelCase			:		int		)  ->  int:


       '''simple docstring'''

       if self.parents[disj_set] == disj_set:
        return disj_set
       lowercase					:   Tuple				  =self.get_parent(self.parents[disj_set]		)
       return self.parents[disj_set]











'''simple docstring'''



import importlib.metadata
from typing import Union

from packaging.version import Version, parse

from .constants import STR_OPERATION_TO_FUNC


SCREAMING_SNAKE_CASE						=	parse(importlib.metadata.version('torch'))


def 							lowercase_				(    __A :       Union[str, Version]					,      __A :       str					,      __A :       str			)       ->      Union[str, Any]:



 """simple docstring"""




 if operation not in STR_OPERATION_TO_FUNC.keys():
  raise ValueError(F'`operation` must be one of {list(STR_OPERATION_TO_FUNC.keys()			)}, received {operation}'			)
 lowercase					:   Any				  =STR_OPERATION_TO_FUNC[operation]
 if isinstance(__A					,      __A			):
  lowercase					:   List[Any]				  =parse(importlib.metadata.version(__A			)			)
 return operation(__A					,      parse(__A			)			)





def 							lowercase_				(    __A :       str					,      __A :       str			)       ->      Tuple:



 """simple docstring"""




 return compare_versions(__A					,      __A					,      __A			)



