
'''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        A_     (						__SCREAMING_SNAKE_CASE						:  Optional[Any] )				->       Optional[int]:  # picklable for multiprocessing
  return i + 1







@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def        A_     (						)				->       Any:
  with parallel_backend("""spark""" ):
    assert ParallelBackendConfig.backend_name == "spark"

  __A		:     Union[str, Any]												=		[1, 2, 3]
  with pytest.raises(__UpperCamelCase ):
    with parallel_backend("""unsupported backend""" ):
      map_nested(__UpperCamelCase			,     __UpperCamelCase			,     num_proc=2 )

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







@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize("""num_proc"""			,     [2, -1] )
def        A_     (						__SCREAMING_SNAKE_CASE						:  Tuple )				->       List[Any]:
  __A		:     Dict												=		[1, 2]
  __A		:     Dict												=		{"""a""": 1, """b""": 2}
  __A		:     Union[str, Any]												=		{"""a""": [1, 2], """b""": [3, 4]}
  __A		:     int												=		{"""a""": {"""1""": 1}, """b""": 2}
  __A		:     Tuple												=		{"""a""": 1, """b""": 2, """c""": 3, """d""": 4}
  __A		:     List[str]												=		[2, 3]
  __A		:     Dict												=		{"""a""": 2, """b""": 3}
  __A		:     Union[str, Any]												=		{"""a""": [2, 3], """b""": [4, 5]}
  __A		:     Tuple												=		{"""a""": {"""1""": 2}, """b""": 3}
  __A		:     Dict												=		{"""a""": 2, """b""": 3, """c""": 4, """d""": 5}

  with parallel_backend("""spark""" ):
    assert map_nested(__UpperCamelCase			,     __UpperCamelCase			,     num_proc=__UpperCamelCase ) == expected_map_nested_sa
    assert map_nested(__UpperCamelCase			,     __UpperCamelCase			,     num_proc=__UpperCamelCase ) == expected_map_nested_sa
    assert map_nested(__UpperCamelCase			,     __UpperCamelCase			,     num_proc=__UpperCamelCase ) == expected_map_nested_sa
    assert map_nested(__UpperCamelCase			,     __UpperCamelCase			,     num_proc=__UpperCamelCase ) == expected_map_nested_sa
    assert map_nested(__UpperCamelCase			,     __UpperCamelCase			,     num_proc=__UpperCamelCase ) == expected_map_nested_sa





'''simple docstring'''
from __future__ import annotations







def        A_     (						__SCREAMING_SNAKE_CASE						:  list[int] )				->       int:





  """simple docstring"""

  if not nums:
    return 0
  __A		:     List[Any]												=		nums[0]
  __A		:     Union[str, Any]												=		0
  for num in nums[1:]:
    __A							,					__A		:     Union[str, Any]												=		(
        max_excluding + num,
        max(__SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE ),
    )
  return max(__SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE )


if __name__ == "__main__":
     import doctest

     doctest.testmod()



