



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(      A       :    Optional[Any]       )		->       Optional[int]:  # picklable for multiprocessing
					"""simple docstring"""





					return i + 1






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def     a(      )		->       Union[str, Any]:
					"""simple docstring"""





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

					a					     =   [1, 2, 3]
					with pytest.raises(A       ):
										with parallel_backend("unsupported backend"       ):
															map_nested(A ,     A ,     num_proc=2       )

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







@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize("num_proc" ,     [2, -1]       )
def     a(      A       :    Dict       )		->       List[str]:
					"""simple docstring"""





					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(A ,     A ,     num_proc=A       ) == expected_map_nested_sa
										assert map_nested(A ,     A ,     num_proc=A       ) == expected_map_nested_sa
										assert map_nested(A ,     A ,     num_proc=A       ) == expected_map_nested_sa
										assert map_nested(A ,     A ,     num_proc=A       ) == expected_map_nested_sa
										assert map_nested(A ,     A ,     num_proc=A       ) == expected_map_nested_sa





from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowercase: str      			=		logging.get_logger(__name__)

_lowercase: List[str]      			=		{
    "microsoft/trocr-base-handwritten": (
        "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json"
    ),
    # See all TrOCR models at https://huggingface.co/models?filter=trocr
}



class 	_lowercase							(   lowerCAmelCase	):





	"""simple docstring"""
	__A							=							"trocr"
	__A							=							["past_key_values"]
	__A							=							{
	    "num_attention_heads": "decoder_attention_heads",
	    "hidden_size": "d_model",
	    "num_hidden_layers": "decoder_layers",
	}




	def __init__(self		,       lowerCamelCase_=50265		,       lowerCamelCase_=1024		,       lowerCamelCase_=12		,       lowerCamelCase_=16		,       lowerCamelCase_=4096		,       lowerCamelCase_="gelu"		,       lowerCamelCase_=512		,       lowerCamelCase_=0.1		,       lowerCamelCase_=0.0		,       lowerCamelCase_=0.0		,       lowerCamelCase_=2		,       lowerCamelCase_=0.02		,       lowerCamelCase_=0.0		,       lowerCamelCase_=True		,       lowerCamelCase_=False		,       lowerCamelCase_=True		,       lowerCamelCase_=True		,       lowerCamelCase_=1		,       lowerCamelCase_=0		,       lowerCamelCase_=2		,       **lowerCamelCase_		,       ):
						"""simple docstring"""

						a					     =   vocab_size
						a					     =   d_model
						a					     =   decoder_layers
						a					     =   decoder_attention_heads
						a					     =   decoder_ffn_dim
						a					     =   activation_function
						a					     =   max_position_embeddings
						a					     =   dropout
						a					     =   attention_dropout
						a					     =   activation_dropout
						a					     =   init_std
						a					     =   decoder_layerdrop
						a					     =   use_cache
						a					     =   scale_embedding
						a					     =   use_learned_position_embeddings
						a					     =   layernorm_embedding

						super().__init__(
						    pad_token_id=lowerCamelCase_		,       bos_token_id=lowerCamelCase_		,       eos_token_id=lowerCamelCase_		,       decoder_start_token_id=lowerCamelCase_		,       **lowerCamelCase_		,       )
