



'''simple docstring'''





from typing import Callable, Optional

from .. import Features
from ..packaged_modules.generator.generator import Generator
from .abc import AbstractDatasetInputStream






class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_					):
  '''simple docstring'''




  def __init__(   self  ,__UpperCAmelCase  ,__UpperCAmelCase = None  ,__UpperCAmelCase = None  ,__UpperCAmelCase = False  ,__UpperCAmelCase = False  ,__UpperCAmelCase = None  ,__UpperCAmelCase = None  ,**__UpperCAmelCase  ,)   ->		Optional[int]:
      super().__init__(
          features=__UpperCAmelCase  ,cache_dir=__UpperCAmelCase  ,keep_in_memory=__UpperCAmelCase  ,streaming=__UpperCAmelCase  ,num_proc=__UpperCAmelCase  ,**__UpperCAmelCase  ,)
      lowerCAmelCase__			:  List[Any]											= Generator(
          cache_dir=__UpperCAmelCase  ,features=__UpperCAmelCase  ,generator=__UpperCAmelCase  ,gen_kwargs=__UpperCAmelCase  ,**__UpperCAmelCase  ,)






  def 							UpperCAmelCase_     (   self				)   ->		Dict:
      # Build iterable dataset
      if self.streaming:
          lowerCAmelCase__			:  Optional[int]											= self.builder.as_streaming_dataset(split="""train"""				)
      # Build regular (map-style) dataset
      else:
          lowerCAmelCase__			:  Optional[int]											= None
          lowerCAmelCase__			:  Tuple											= None
          lowerCAmelCase__			:  int											= None
          lowerCAmelCase__			:  Optional[Any]											= None

          self.builder.download_and_prepare(
              download_config=__UpperCAmelCase  ,download_mode=__UpperCAmelCase  ,verification_mode=__UpperCAmelCase  ,base_path=__UpperCAmelCase  ,num_proc=self.num_proc  ,)
          lowerCAmelCase__			:  Optional[Any]											= self.builder.as_dataset(
              split="""train"""  ,verification_mode=__UpperCAmelCase  ,in_memory=self.keep_in_memory				)
      return dataset







'''simple docstring'''





from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


_lowerCAmelCase										=     logging.get_logger(__name__)

_lowerCAmelCase										=     {
    '''facebook/convnextv2-tiny-1k-224''': '''https://huggingface.co/facebook/convnextv2-tiny-1k-224/resolve/main/config.json''',
}






class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_						,			SCREAMING_SNAKE_CASE_					):
  '''simple docstring'''




  __lowercase							:				Tuple           =				'''convnextv2'''




  def __init__(   self  ,__UpperCAmelCase=3  ,__UpperCAmelCase=4  ,__UpperCAmelCase=4  ,__UpperCAmelCase=None  ,__UpperCAmelCase=None  ,__UpperCAmelCase="gelu"  ,__UpperCAmelCase=0.0_2  ,__UpperCAmelCase=1E-12  ,__UpperCAmelCase=0.0  ,__UpperCAmelCase=224  ,__UpperCAmelCase=None  ,__UpperCAmelCase=None  ,**__UpperCAmelCase  ,)   ->		Union[str, Any]:
      super().__init__(**__UpperCAmelCase				)

      lowerCAmelCase__			:  int											= num_channels
      lowerCAmelCase__			:  List[Any]											= patch_size
      lowerCAmelCase__			:  Union[str, Any]											= num_stages
      lowerCAmelCase__			:  Tuple											= [96, 192, 384, 768] if hidden_sizes is None else hidden_sizes
      lowerCAmelCase__			:  str											= [3, 3, 9, 3] if depths is None else depths
      lowerCAmelCase__			:  Optional[Any]											= hidden_act
      lowerCAmelCase__			:  str											= initializer_range
      lowerCAmelCase__			:  List[str]											= layer_norm_eps
      lowerCAmelCase__			:  Dict											= drop_path_rate
      lowerCAmelCase__			:  int											= image_size
      lowerCAmelCase__			:  int											= ["""stem"""] + [F"""stage{idx}""" for idx in range(1  ,len(self.depths				) + 1				)]
      lowerCAmelCase__				,       lowerCAmelCase__			:  Tuple											= get_aligned_output_features_output_indices(
          out_features=__UpperCAmelCase  ,out_indices=__UpperCAmelCase  ,stage_names=self.stage_names				)


