


from .imports import is_tqdm_available


if is_tqdm_available():
  from tqdm.auto import tqdm as _tqdm

from ..state import PartialState




def  a   (lowerCAmelCase__ = True		,				*lowerCAmelCase__		,				**lowerCAmelCase__   ):
   if not is_tqdm_available():
      raise ImportError("""Accelerate's `tqdm` module requires `tqdm` to be installed. Please run `pip install tqdm`."""   )
   __a					=  False
   if main_process_only:
      __a					=  PartialState().local_process_index == 0
   return _tqdm(*lowerCAmelCase__		,				**lowerCAmelCase__		,				disable=lowerCAmelCase__   )







class     __UpperCAmelCase							:


     """simple docstring"""


     def __init__(	self  ,       __A    ):
        __a					=  set_counts
        __a					=  max(__A    )
        __a					=  len(__A    )
        __a					=  [1] * num_sets
        __a					=  list(range(__A    )    )


     def 	snake_case_  (	self  ,       __A  ,       __A    ):
        __a					=  self.get_parent(__A    )
        __a					=  self.get_parent(__A    )

        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]
           __a					=  0
           __a					=  dst_parent
           if self.ranks[dst_parent] == self.ranks[src_parent]:
              self.ranks[dst_parent] += 1
           __a					=  self.set_counts[dst_parent]
        else:
           self.set_counts[src_parent] += self.set_counts[dst_parent]
           __a					=  0
           __a					=  src_parent
           __a					=  self.set_counts[src_parent]

        __a					=  max(self.max_set  ,       __A    )
        return True


     def 	snake_case_  (	self  ,       __A    ):
        if self.parents[disj_set] == disj_set:
           return disj_set
        __a					=  self.get_parent(self.parents[disj_set]    )
        return self.parents[disj_set]



