





"""simple docstring"""



import pytest

from datasets.parallel import ParallelBackendConfig, parallel_backend
from datasets.utils.py_utils import map_nested

from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows







def 		__lowercase     (   snake_case_  :  Tuple						)   ->int:  # picklable for multiprocessing



    '''simple docstring'''







    return i + 1







@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 		__lowercase     (   )   ->List[Any]:



    '''simple docstring'''







    with parallel_backend('''spark'''						):
        assert ParallelBackendConfig.backend_name == "spark"

    __A    :						List[str]						 =     [1, 2, 3]
    with pytest.raises(snake_case_						):
        with parallel_backend('''unsupported backend'''						):
            map_nested(snake_case_				,snake_case_				,num_proc=2						)

    with pytest.raises(snake_case_						):
        with parallel_backend('''unsupported backend'''						):
            map_nested(snake_case_				,snake_case_				,num_proc=-1						)







@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('''num_proc'''				,[2, -1]						)
def 		__lowercase     (   snake_case_  :  Dict						)   ->List[Any]:



    '''simple docstring'''







    __A    :						str						 =     [1, 2]
    __A    :						Any						 =     {'''a''': 1, '''b''': 2}
    __A    :						Dict						 =     {'''a''': [1, 2], '''b''': [3, 4]}
    __A    :						int						 =     {'''a''': {'''1''': 1}, '''b''': 2}
    __A    :						Optional[Any]						 =     {'''a''': 1, '''b''': 2, '''c''': 3, '''d''': 4}
    __A    :						List[str]						 =     [2, 3]
    __A    :						List[str]						 =     {'''a''': 2, '''b''': 3}
    __A    :						List[str]						 =     {'''a''': [2, 3], '''b''': [4, 5]}
    __A    :						Optional[int]						 =     {'''a''': {'''1''': 2}, '''b''': 3}
    __A    :						List[str]						 =     {'''a''': 2, '''b''': 3, '''c''': 4, '''d''': 5}

    with parallel_backend('''spark'''						):
        assert map_nested(snake_case_				,snake_case_				,num_proc=snake_case_						) == expected_map_nested_sa
        assert map_nested(snake_case_				,snake_case_				,num_proc=snake_case_						) == expected_map_nested_sa
        assert map_nested(snake_case_				,snake_case_				,num_proc=snake_case_						) == expected_map_nested_sa
        assert map_nested(snake_case_				,snake_case_				,num_proc=snake_case_						) == expected_map_nested_sa
        assert map_nested(snake_case_				,snake_case_				,num_proc=snake_case_						) == expected_map_nested_sa











"""simple docstring"""



def 		__lowercase     (   snake_case_  :  dict						)   ->set:



    '''simple docstring'''







    __A    :						List[str]						 =     set()
    # edges = list of graph's edges
    __A    :						Optional[int]						 =     get_edges(snake_case_						)

    # While there are still elements in edges list, take an arbitrary edge
    # (from_node, to_node) and add his extremity to chosen_vertices and then
    # remove all arcs adjacent to the from_node and to_node
    while edges:
        __A ,       __A    :						str						 =     edges.pop()
        chosen_vertices.add(snake_case_						)
        chosen_vertices.add(snake_case_						)
        for edge in edges.copy():
            if from_node in edge or to_node in edge:
                edges.discard(snake_case_						)
    return chosen_vertices







def 		__lowercase     (   snake_case_  :  dict						)   ->set:



    '''simple docstring'''







    __A    :						Tuple						 =     set()
    for from_node, to_nodes in graph.items():
        for to_node in to_nodes:
            edges.add((from_node, to_node)						)
    return edges


if __name__ == "__main__":
       import doctest

       doctest.testmod()

       # graph = {0: [1, 3], 1: [0, 3], 2: [0, 3, 4], 3: [0, 1, 2], 4: [2, 3]}
       # print(f"Matching vertex cover:\n{matching_min_vertex_cover(graph)}")




