




"""simple docstring"""







import operator as op


__A   :  Optional[Any]					=      'scaler.pt'
__A   :  Dict					=      'pytorch_model'
__A   :  Optional[Any]					=      'random_states'
__A   :  List[Any]					=      'optimizer'
__A   :  Optional[int]					=      'scheduler'
__A   :  Union[str, Any]					=      'pytorch_model.bin'
__A   :  Union[str, Any]					=      'pytorch_model.bin.index.json'
__A   :  Optional[Any]					=      'model.safetensors'
__A   :  Dict					=      'model.safetensors.index.json'
__A   :  Optional[Any]					=      '1.10.2'
__A   :  List[str]					=      'py38'
__A   :  List[Any]					=      '4.17.0'
__A   :  str					=      ['ml.p3.16xlarge', 'ml.p3dn.24xlarge', 'ml.p4dn.24xlarge']
__A   :  Optional[Any]					=      ['FULL_SHARD', 'SHARD_GRAD_OP', 'NO_SHARD', 'HYBRID_SHARD', 'HYBRID_SHARD_ZERO2']
__A   :  Optional[int]					=      ['TRANSFORMER_BASED_WRAP', 'SIZE_BASED_WRAP', 'NO_WRAP']
__A   :  Optional[Any]					=      ['BACKWARD_PRE', 'BACKWARD_POST', 'NO_PREFETCH']
__A   :  List[str]					=      ['FULL_STATE_DICT', 'LOCAL_STATE_DICT', 'SHARDED_STATE_DICT']
__A   :  Dict					=      '2.0.1'
__A   :  Dict					=      ['pdsh', 'standard', 'openmpi', 'mvapich']
__A   :  str					=      ['default', 'reduce-overhead', 'max-autotune']

__A   :  Tuple					=      {'>': op.gt, '>=': op.ge, '==': op.eq, '!=': op.ne, '<=': op.le, '<': op.lt}

# These are the args for `torch.distributed.launch` for pytorch < 1.9
__A   :  Union[str, Any]					=      [
    'nnodes',
    'nproc_per_node',
    'rdzv_backend',
    'rdzv_endpoint',
    'rdzv_id',
    'rdzv_conf',
    'standalone',
    'max_restarts',
    'monitor_interval',
    'start_method',
    'role',
    'module',
    'm',
    'no_python',
    'run_path',
    'log_dir',
    'r',
    'redirects',
    't',
    'tee',
    'node_rank',
    'master_addr',
    'master_port',
]

__A   :  int					=      ['DEEPSPEED', 'MULTI_GPU', 'FSDP', 'MEGATRON_LM']
__A   :  Dict					=      ['DEEPSPEED', 'MULTI_XPU', 'FSDP']






"""simple docstring"""







from collections import deque

def 						snake_case__       (					_lowerCamelCase				)			->Dict:






		"""simple docstring"""


		__lowercase				:		Any												=				len(_lowerCamelCase				)
		__lowercase				:		str												=				deque()
		__lowercase				:		Tuple												=				[False for _ in range(_lowerCamelCase				)]
		__lowercase				:		Optional[int]												=				[-1 for _ in range(_lowerCamelCase				)]
		__lowercase				:		Dict												=				index_of[:]

		def strong_connect(_lowerCamelCase,  _lowerCamelCase,  _lowerCamelCase				):
				__lowercase				:		List[str]												=				index  # the number when this node is seen
				__lowercase				:		List[str]												=				index  # lowest rank node reachable from here
				index += 1
				stack.append(_lowerCamelCase				)
				__lowercase				:		List[Any]												=				True

				for w in g[v]:
						if index_of[w] == -1:
								__lowercase				:		Optional[int]												=				strong_connect(_lowerCamelCase,  _lowerCamelCase,  _lowerCamelCase				)
								__lowercase				:		List[Any]												=				(
								    lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
								)
						elif on_stack[w]:
								__lowercase				:		List[Any]												=				(
								    lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
								)

				if lowlink_of[v] == index_of[v]:
						__lowercase				:		Any												=				[]
						__lowercase				:		List[Any]												=				stack.pop()
						__lowercase				:		Any												=				False
						component.append(_lowerCamelCase				)
						while w != v:
								__lowercase				:		List[str]												=				stack.pop()
								__lowercase				:		Dict												=				False
								component.append(_lowerCamelCase				)
						components.append(_lowerCamelCase				)
				return index

		__lowercase				:		Tuple												=				[]
		for v in range(_lowerCamelCase				):
				if index_of[v] == -1:
						strong_connect(_lowerCamelCase,  0,  _lowerCamelCase				)

		return components

def 						snake_case__       (					_lowerCamelCase,  _lowerCamelCase				)			->Tuple:






		"""simple docstring"""


		__lowercase				:		int												=				[[] for _ in range(_lowerCamelCase				)]
		for u, v in edges:
				g[u].append(_lowerCamelCase				)
		return g


if __name__ == "__main__":
						# Test
						__A   :  int					=      7
						__A   :  int					=      [0, 0, 1, 2, 3, 3, 4, 4, 6]
						__A   :  List[Any]					=      [1, 3, 2, 0, 1, 4, 5, 6, 5]
						__A   :  List[str]					=      [(u, v) for u, v in zip(source, target)]
						__A   :  List[str]					=      create_graph(n_vertices, edges)

						assert [[5], [6], [4], [3, 2, 1, 0]] == tarjan(g)
