



"""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__      :				List[Any]						)						->   str:

  """simple docstring"""




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










"""simple docstring"""







def 				UpperCamelCase_    (    lowerCAmelCase__      :				Optional[Any]						)						->   Optional[int]:

  """simple docstring"""




  lowerCAmelCase_   :				Tuple								= [0] * len(lowerCAmelCase__						)
  lowerCAmelCase_   :				List[str]								= []
  lowerCAmelCase_   :				Tuple								= [1] * len(lowerCAmelCase__						)

  for values in graph.values():
    for i in values:
      indegree[i] += 1

  for i in range(len(lowerCAmelCase__						)						):
    if indegree[i] == 0:
      queue.append(lowerCAmelCase__						)

  while queue:
    lowerCAmelCase_   :				Union[str, Any]								= queue.pop(0						)
    for x in graph[vertex]:
      indegree[x] -= 1

      if long_dist[vertex] + 1 > long_dist[x]:
        lowerCAmelCase_   :				Any								= long_dist[vertex] + 1

      if indegree[x] == 0:
        queue.append(lowerCAmelCase__						)

  print(max(lowerCAmelCase__						)						)


# Adjacency list of Graph
lowercase__		:				Any          =	{0: [2, 3, 4], 1: [2, 7], 2: [5], 3: [5, 7], 4: [7], 5: [6], 6: [7], 7: []}
longest_distance(graph)





