





'''simple docstring'''

def 						UpperCamelCase    (							_lowerCamelCase : Dict						,	_lowerCamelCase : Tuple	):
    A__    =      [1]
    for i in range(2						,	_lowerCamelCase	):
        factorials.append(factorials[-1] * i	)
    assert 0 <= k < factorials[-1] * n, "k out of bounds"

    A__    =      []
    A__    =      list(range(_lowerCamelCase	)	)

    # Find permutation
    while factorials:
        A__    =      factorials.pop()
        A__,     A__    =      divmod(_lowerCamelCase						,	_lowerCamelCase	)
        permutation.append(elements[number]	)
        elements.remove(elements[number]	)
    permutation.append(elements[0]	)

    return permutation


if __name__ == "__main__":
  import doctest

  doctest.testmod()










'''simple docstring'''

from .imports import is_tqdm_available


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

from ..state import PartialState





def 						UpperCamelCase    (							_lowerCamelCase : bool = True						,	*_lowerCamelCase : Optional[int]						,	**_lowerCamelCase : Optional[Any]	):
    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	)



