



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


@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def A    (							)    ->   Tuple:
			with parallel_backend('spark'       ):
						assert ParallelBackendConfig.backend_name == "spark"

			A__	  =     [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    (							__UpperCamelCase       )    ->   Optional[Any]:
			A__	  =     [1, 2]
			A__	  =     {'a': 1, 'b': 2}
			A__	  =     {'a': [1, 2], 'b': [3, 4]}
			A__	  =     {'a': {'1': 1}, 'b': 2}
			A__	  =     {'a': 1, 'b': 2, 'c': 3, 'd': 4}
			A__	  =     [2, 3]
			A__	  =     {'a': 2, 'b': 3}
			A__	  =     {'a': [2, 3], 'b': [4, 5]}
			A__	  =     {'a': {'1': 2}, 'b': 3}
			A__	  =     {'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









from __future__ import annotations


def A    (							__UpperCamelCase = 4       )    ->   list[list[int]]:
			A__	  =     abs(__UpperCamelCase       ) or 4
			return [[1 + x + y * row_size for x in range(__UpperCamelCase       )] for y in range(__UpperCamelCase       )]


def A    (							__UpperCamelCase       )    ->   list[list[int]]:
			return reverse_row(transpose(__UpperCamelCase       )       )
			# OR.. transpose(reverse_column(matrix))


def A    (							__UpperCamelCase       )    ->   list[list[int]]:
			return reverse_row(reverse_column(__UpperCamelCase       )       )
			# OR.. reverse_column(reverse_row(matrix))


def A    (							__UpperCamelCase       )    ->   list[list[int]]:
			return reverse_column(transpose(__UpperCamelCase       )       )
			# OR.. transpose(reverse_row(matrix))


def A    (							__UpperCamelCase       )    ->   list[list[int]]:
			A__	  =     [list(__UpperCamelCase       ) for x in zip(*__UpperCamelCase       )]
			return matrix


def A    (							__UpperCamelCase       )    ->   list[list[int]]:
			A__	  =     matrix[::-1]
			return matrix


def A    (							__UpperCamelCase       )    ->   list[list[int]]:
			A__	  =     [x[::-1] for x in matrix]
			return matrix


def A    (							__UpperCamelCase       )    ->   None:
			for i in matrix:
						print(*__UpperCamelCase       )


if __name__ == "__main__":
							SCREAMING_SNAKE_CASE__   			=   make_matrix()
							print('''\norigin:\n''')
							print_matrix(matrix)
							print('''\nrotate 90 counterclockwise:\n''')
							print_matrix(rotate_aa(matrix))

							SCREAMING_SNAKE_CASE__   			=   make_matrix()
							print('''\norigin:\n''')
							print_matrix(matrix)
							print('''\nrotate 180:\n''')
							print_matrix(rotate_aaa(matrix))

							SCREAMING_SNAKE_CASE__   			=   make_matrix()
							print('''\norigin:\n''')
							print_matrix(matrix)
							print('''\nrotate 270 counterclockwise:\n''')
							print_matrix(rotate_aaa(matrix))




