





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


SCREAMING_SNAKE_CASE_						   =       logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_						   =       {
    """microsoft/focalnet-tiny""": """https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json""",
}

class 		UpperCamelCase__ (      lowerCAmelCase_							,      lowerCAmelCase_   ):



     '''simple docstring'''

     __snake_case    :	Tuple			=			"focalnet"






     def __init__(							self						:    Union[str, Any]						,lowerCamelCase__						:    Union[str, Any]=224						,lowerCamelCase__						:    Optional[int]=4						,lowerCamelCase__						:    str=3						,lowerCamelCase__						:    Any=96						,lowerCamelCase__						:    Dict=False						,lowerCamelCase__						:    Optional[int]=[192, 384, 768, 768]						,lowerCamelCase__						:    Optional[Any]=[2, 2, 6, 2]						,lowerCamelCase__						:    Optional[Any]=[2, 2, 2, 2]						,lowerCamelCase__						:    Optional[Any]=[3, 3, 3, 3]						,lowerCamelCase__						:    int="gelu"						,lowerCamelCase__						:    List[Any]=4.0						,lowerCamelCase__						:    List[Any]=0.0						,lowerCamelCase__						:    int=0.1						,lowerCamelCase__						:    str=False						,lowerCamelCase__						:    int=1e-4						,lowerCamelCase__						:    Dict=False						,lowerCamelCase__						:    int=False						,lowerCamelCase__						:    List[str]=False						,lowerCamelCase__						:    List[str]=0.02						,lowerCamelCase__						:    Any=1e-5						,lowerCamelCase__						:    List[Any]=32						,lowerCamelCase__						:    List[str]=None						,lowerCamelCase__						:    Any=None						,**lowerCamelCase__						:    Any						,)     ->		Any:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__       )

           SCREAMING_SNAKE_CASE		=						image_size
           SCREAMING_SNAKE_CASE		=						patch_size
           SCREAMING_SNAKE_CASE		=						num_channels
           SCREAMING_SNAKE_CASE		=						embed_dim
           SCREAMING_SNAKE_CASE		=						use_conv_embed
           SCREAMING_SNAKE_CASE		=						hidden_sizes
           SCREAMING_SNAKE_CASE		=						depths
           SCREAMING_SNAKE_CASE		=						focal_levels
           SCREAMING_SNAKE_CASE		=						focal_windows
           SCREAMING_SNAKE_CASE		=						hidden_act
           SCREAMING_SNAKE_CASE		=						mlp_ratio
           SCREAMING_SNAKE_CASE		=						hidden_dropout_prob
           SCREAMING_SNAKE_CASE		=						drop_path_rate
           SCREAMING_SNAKE_CASE		=						use_layerscale
           SCREAMING_SNAKE_CASE		=						layerscale_value
           SCREAMING_SNAKE_CASE		=						use_post_layernorm
           SCREAMING_SNAKE_CASE		=						use_post_layernorm_in_modulation
           SCREAMING_SNAKE_CASE		=						normalize_modulator
           SCREAMING_SNAKE_CASE		=						initializer_range
           SCREAMING_SNAKE_CASE		=						layer_norm_eps
           SCREAMING_SNAKE_CASE		=						encoder_stride
           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=lowerCamelCase__						,out_indices=lowerCamelCase__						,stage_names=self.stage_names       )









from typing import Callable, Optional

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

class 		UpperCamelCase__ (      lowerCAmelCase_   ):



     '''simple docstring'''

     def __init__(							self						:    Union[str, Any]						,lowerCamelCase__						:    Callable						,lowerCamelCase__						:    Optional[Features] = None						,lowerCamelCase__						:    str = None						,lowerCamelCase__						:    bool = False						,lowerCamelCase__						:    bool = False						,lowerCamelCase__						:    Optional[dict] = None						,lowerCamelCase__						:    Optional[int] = None						,**lowerCamelCase__						:    Optional[Any]						,)     ->		List[str]:




           '''simple docstring'''


           super().__init__(
               features=lowerCamelCase__						,cache_dir=lowerCamelCase__						,keep_in_memory=lowerCamelCase__						,streaming=lowerCamelCase__						,num_proc=lowerCamelCase__						,**lowerCamelCase__						,)
           SCREAMING_SNAKE_CASE		=						Generator(
               cache_dir=lowerCamelCase__						,features=lowerCamelCase__						,generator=lowerCamelCase__						,gen_kwargs=lowerCamelCase__						,**lowerCamelCase__						,)






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Union[str, Any]       )     ->		Optional[Any]:




           '''simple docstring'''


           if self.streaming:
                 SCREAMING_SNAKE_CASE		=						self.builder.as_streaming_dataset(split="""train"""       )
           # Build regular (map-style) dataset
           else:
                 SCREAMING_SNAKE_CASE		=						None
                 SCREAMING_SNAKE_CASE		=						None
                 SCREAMING_SNAKE_CASE		=						None
                 SCREAMING_SNAKE_CASE		=						None

                 self.builder.download_and_prepare(
                     download_config=lowerCamelCase__						,download_mode=lowerCamelCase__						,verification_mode=lowerCamelCase__						,base_path=lowerCamelCase__						,num_proc=self.num_proc						,)
                 SCREAMING_SNAKE_CASE		=						self.builder.as_dataset(
                     split="""train"""						,verification_mode=lowerCamelCase__						,in_memory=self.keep_in_memory       )
           return dataset


