


import math





def __UpperCAmelCase       (		__A			)						->					Any:



       '''simple docstring'''





       assert isinstance(lowerCamelCase_ ,						lowerCamelCase_			) and (
           number >= 0
       ), "'number' must been an int and positive"

       if 1 < number < 4:
              # 2 and 3 are primes
              return True
       elif number < 2 or not number % 2:
              # Negatives, 0, 1 and all even numbers are not primes
              return False

       UpperCAmelCase__										=     range(3 ,						int(math.sqrt(lowerCamelCase_			) + 1			) ,						2			)
       return not any(not number % i for i in odd_numbers			)





def __UpperCAmelCase       (		__A ,						__A=1 ,						**__A			)						->					Optional[int]:



       '''simple docstring'''





       UpperCAmelCase__										=     factor * value
       UpperCAmelCase__										=     value

       while not is_prime(lowerCamelCase_			):
              value += 1 if not ("desc" in kwargs and kwargs["desc"] is True) else -1

       if value == first_value_val:
              return next_prime(value + 1 ,						**lowerCamelCase_			)
       return value









from .imports import is_tqdm_available


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

from ..state import PartialState





def __UpperCAmelCase       (		__A = True ,						*__A ,						**__A			)						->					Any:



       '''simple docstring'''





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





