

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     ):  # picklable for multiprocessing

      """simple docstring"""



      return i + 1

@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def       A_     (							):

      """simple docstring"""



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

      SCREAMING_SNAKE_CASE_ :     Tuple							=   [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_     (							a     ):

      """simple docstring"""



      SCREAMING_SNAKE_CASE_ :     Any							=   [1, 2]
      SCREAMING_SNAKE_CASE_ :     str							=   {'a': 1, 'b': 2}
      SCREAMING_SNAKE_CASE_ :     str							=   {'a': [1, 2], 'b': [3, 4]}
      SCREAMING_SNAKE_CASE_ :     Union[str, Any]							=   {'a': {'1': 1}, 'b': 2}
      SCREAMING_SNAKE_CASE_ :     Tuple							=   {'a': 1, 'b': 2, 'c': 3, 'd': 4}
      SCREAMING_SNAKE_CASE_ :     Optional[int]							=   [2, 3]
      SCREAMING_SNAKE_CASE_ :     Any							=   {'a': 2, 'b': 3}
      SCREAMING_SNAKE_CASE_ :     Optional[Any]							=   {'a': [2, 3], 'b': [4, 5]}
      SCREAMING_SNAKE_CASE_ :     List[Any]							=   {'a': {'1': 2}, 'b': 3}
      SCREAMING_SNAKE_CASE_ :     Union[str, Any]							=   {'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 ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


lowerCamelCase :      List[str]					 =     logging.get_logger(__name__)

lowerCamelCase :      List[Any]					 =     {
    "facebook/convnextv2-tiny-1k-224": "https://huggingface.co/facebook/convnextv2-tiny-1k-224/resolve/main/config.json",
}







class 							A__    (       A__     ,   A__  ):
  A__		 =				'convnextv2'





  def __init__(		self      :	Tuple							,					_a      :	Optional[int]=3							,					_a      :	Any=4							,					_a      :	int=4							,					_a      :	Union[str, Any]=None							,					_a      :	List[str]=None							,					_a      :	Optional[Any]="gelu"							,					_a      :	Any=0.02							,					_a      :	Any=1e-12							,					_a      :	Tuple=0.0							,					_a      :	int=224							,					_a      :	Any=None							,					_a      :	Optional[int]=None							,					**_a      :	List[str]							,					)	->    Optional[Any]:





       '''simple docstring'''






       super().__init__(**_a )

       _SCREAMING_SNAKE_CASE							    =num_channels
       _SCREAMING_SNAKE_CASE							    =patch_size
       _SCREAMING_SNAKE_CASE							    =num_stages
       _SCREAMING_SNAKE_CASE							    =[96, 192, 384, 768] if hidden_sizes is None else hidden_sizes
       _SCREAMING_SNAKE_CASE							    =[3, 3, 9, 3] if depths is None else depths
       _SCREAMING_SNAKE_CASE							    =hidden_act
       _SCREAMING_SNAKE_CASE							    =initializer_range
       _SCREAMING_SNAKE_CASE							    =layer_norm_eps
       _SCREAMING_SNAKE_CASE							    =drop_path_rate
       _SCREAMING_SNAKE_CASE							    =image_size
       _SCREAMING_SNAKE_CASE							    =['stem'] + [f"stage{idx}" for idx in range(1							,					len(self.depths ) + 1 )]
       _SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE							    =get_aligned_output_features_output_indices(
           out_features=_a							,					out_indices=_a							,					stage_names=self.stage_names )
