


import os
from pickle import UnpicklingError
from typing import Dict, Tuple

import jax
import jax.numpy as jnp
import numpy as np
from flax.serialization import from_bytes
from flax.traverse_util import flatten_dict, unflatten_dict

import transformers

from .utils import logging


lowerCamelCase		   =			logging.get_logger(__name__)




def       a_ (       SCREAMING_SNAKE_CASE__   : int						,     SCREAMING_SNAKE_CASE__   : List[Any]						,     SCREAMING_SNAKE_CASE__   : List[str]						,     SCREAMING_SNAKE_CASE__   : Optional[Any]=False	):
       '''simple docstring'''





       try:
              import torch  # noqa: F401
       except ImportError:
              logger.error(
                  'Loading a PyTorch model in Flax, requires both PyTorch and Flax to be installed. Please see'
                  ' https://pytorch.org/ and https://flax.readthedocs.io/en/latest/installation.html for installation'
                  ' instructions.'	)
              raise

       if not is_sharded:
              _lowerCamelCase			:						List[str]            =os.path.abspath(SCREAMING_SNAKE_CASE__	)
              logger.info(F'''Loading PyTorch weights from {pt_path}'''	)

              _lowerCamelCase			:						Tuple            =torch.load(SCREAMING_SNAKE_CASE__						,     map_location='cpu'	)
              logger.info(F'''PyTorch checkpoint contains {sum(t.numel() for t in pt_state_dict.values()	):,} parameters.'''	)

              _lowerCamelCase			:						Dict            =convert_pytorch_state_dict_to_flax(SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__	)
       else:
              # model is sharded and pytorch_checkpoint_path already contains the list of .pt shard files
              _lowerCamelCase			:						Tuple            =convert_pytorch_sharded_state_dict_to_flax(SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__	)
       return flax_state_dict




def       a_ (       SCREAMING_SNAKE_CASE__   : Tuple[str]						,     SCREAMING_SNAKE_CASE__   : np.ndarray						,     SCREAMING_SNAKE_CASE__   : Dict[str, jnp.ndarray]						,     SCREAMING_SNAKE_CASE__   : str						,     ):
       '''simple docstring'''





       def is_key_or_prefix_key_in_dict(SCREAMING_SNAKE_CASE__   : Tuple[str]	) -> bool:
              return len(set(SCREAMING_SNAKE_CASE__	) & {key, (model_prefix,) + key}	) > 0

       # layer norm
       _lowerCamelCase			:						Optional[int]            =pt_tuple_key[:-1] + ('scale',)
       if pt_tuple_key[-1] in ["weight", "gamma"] and is_key_or_prefix_key_in_dict(SCREAMING_SNAKE_CASE__	):
              return renamed_pt_tuple_key, pt_tensor

       # batch norm layer mean
       _lowerCamelCase			:						Optional[Any]            =pt_tuple_key[:-1] + ('mean',)
       if pt_tuple_key[-1] == "running_mean" and not is_key_or_prefix_key_in_dict(SCREAMING_SNAKE_CASE__	):
              return renamed_pt_tuple_key, pt_tensor

       # batch norm layer var
       _lowerCamelCase			:						str            =pt_tuple_key[:-1] + ('var',)
       if pt_tuple_key[-1] == "running_var" and not is_key_or_prefix_key_in_dict(SCREAMING_SNAKE_CASE__	):
              return renamed_pt_tuple_key, pt_tensor

       # embedding
       _lowerCamelCase			:						List[Any]            =pt_tuple_key[:-1] + ('embedding',)
       if pt_tuple_key[-1] == "weight" and is_key_or_prefix_key_in_dict(SCREAMING_SNAKE_CASE__	):
              return renamed_pt_tuple_key, pt_tensor

       # conv layer
       _lowerCamelCase			:						str            =pt_tuple_key[:-1] + ('kernel',)
       if pt_tuple_key[-1] == "weight" and pt_tensor.ndim == 4 and not is_key_or_prefix_key_in_dict(SCREAMING_SNAKE_CASE__	):
              _lowerCamelCase			:						Tuple            =pt_tensor.transpose(2						,     3						,     1						,     0	)
              return renamed_pt_tuple_key, pt_tensor

       # linear layer
       _lowerCamelCase			:						int            =pt_tuple_key[:-1] + ('kernel',)
       if pt_tuple_key[-1] == "weight" and not is_key_or_prefix_key_in_dict(SCREAMING_SNAKE_CASE__	):
              _lowerCamelCase			:						Dict            =pt_tensor.T
              return renamed_pt_tuple_key, pt_tensor

       # old PyTorch layer norm weight
       _lowerCamelCase			:						Optional[Any]            =pt_tuple_key[:-1] + ('weight',)
       if pt_tuple_key[-1] == "gamma":
              return renamed_pt_tuple_key, pt_tensor

       # old PyTorch layer norm bias
       _lowerCamelCase			:						Union[str, Any]            =pt_tuple_key[:-1] + ('bias',)
       if pt_tuple_key[-1] == "beta":
              return renamed_pt_tuple_key, pt_tensor

       # New `weight_norm` from https://github.com/huggingface/transformers/pull/24030
       _lowerCamelCase			:						Dict            =None
       if pt_tuple_key[-3::2] == ("parametrizations", "original0"):
              _lowerCamelCase			:						Optional[int]            =pt_tuple_key[-2] + '_g'
       elif pt_tuple_key[-3::2] == ("parametrizations", "original1"):
              _lowerCamelCase			:						Optional[int]            =pt_tuple_key[-2] + '_v'
       if name is not None:
              _lowerCamelCase			:						Tuple            =pt_tuple_key[:-3] + (name,)
              return renamed_pt_tuple_key, pt_tensor

       return pt_tuple_key, pt_tensor




def       a_ (       SCREAMING_SNAKE_CASE__   : Optional[int]						,     SCREAMING_SNAKE_CASE__   : Optional[Any]	):
       '''simple docstring'''





       _lowerCamelCase			:						Any            ={k: v.numpy() for k, v in pt_state_dict.items()}

       _lowerCamelCase			:						str            =flax_model.base_model_prefix

       # use params dict if the model contains batch norm layers
       if "params" in flax_model.params:
              _lowerCamelCase			:						List[str]            =flax_model.params['params']
       else:
              _lowerCamelCase			:						List[Any]            =flax_model.params
       _lowerCamelCase			:						Dict            =flatten_dict(SCREAMING_SNAKE_CASE__	)

       # add batch_stats keys,values to dict
       if "batch_stats" in flax_model.params:
              _lowerCamelCase			:						Any            =flatten_dict(flax_model.params['batch_stats']	)
              random_flax_state_dict.update(SCREAMING_SNAKE_CASE__	)

       _lowerCamelCase			:						str            ={}

       _lowerCamelCase			:						List[Any]            =(model_prefix not in flax_model_params) and (
           model_prefix in {k.split('.'	)[0] for k in pt_state_dict.keys()}
       )
       _lowerCamelCase			:						str            =(model_prefix in flax_model_params) and (
           model_prefix not in {k.split('.'	)[0] for k in pt_state_dict.keys()}
       )

       # Need to change some parameters name to match Flax names
       for pt_key, pt_tensor in pt_state_dict.items():
              _lowerCamelCase			:						Optional[int]            =tuple(pt_key.split('.'	)	)

              # remove base model prefix if necessary
              _lowerCamelCase			:						List[Any]            =pt_tuple_key[0] == model_prefix
              if load_model_with_head_into_base_model and has_base_model_prefix:
                     _lowerCamelCase			:						Tuple            =pt_tuple_key[1:]

              # Correctly rename weight parameters
              _lowerCamelCase      ,	_lowerCamelCase			:						Any            =rename_key_and_reshape_tensor(
                  SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__	)

              # add model prefix if necessary
              _lowerCamelCase			:						Optional[int]            =(model_prefix,) + flax_key in random_flax_state_dict
              if load_base_model_into_model_with_head and require_base_model_prefix:
                     _lowerCamelCase			:						Optional[Any]            =(model_prefix,) + flax_key

              if flax_key in random_flax_state_dict:
                     if flax_tensor.shape != random_flax_state_dict[flax_key].shape:
                            raise ValueError(
                                F'''PyTorch checkpoint seems to be incorrect. Weight {pt_key} was expected to be of shape '''
                                F'''{random_flax_state_dict[flax_key].shape}, but is {flax_tensor.shape}.'''	)

        # add batch stats if the model contains batchnorm layers
              if "batch_stats" in flax_model.params:
                     if "mean" in flax_key[-1] or "var" in flax_key[-1]:
                            _lowerCamelCase			:						Optional[Any]            =jnp.asarray(SCREAMING_SNAKE_CASE__	)
                            continue
                     # remove num_batches_tracked key
                     if "num_batches_tracked" in flax_key[-1]:
                            flax_state_dict.pop(SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__	)
                            continue

                     # also add unexpected weight so that warning is thrown
                     _lowerCamelCase			:						Any            =jnp.asarray(SCREAMING_SNAKE_CASE__	)

              else:
                     # also add unexpected weight so that warning is thrown
                     _lowerCamelCase			:						Tuple            =jnp.asarray(SCREAMING_SNAKE_CASE__	)

       return unflatten_dict(SCREAMING_SNAKE_CASE__	)




def       a_ (       SCREAMING_SNAKE_CASE__   : Dict						,     SCREAMING_SNAKE_CASE__   : Union[str, Any]	):
       '''simple docstring'''





       import torch

       # Load the index
       _lowerCamelCase			:						Union[str, Any]            ={}
       for shard_file in shard_filenames:
              # load using msgpack utils
              _lowerCamelCase			:						Any            =torch.load(SCREAMING_SNAKE_CASE__	)
              _lowerCamelCase			:						Tuple            ={k: v.numpy() for k, v in pt_state_dict.items()}

              _lowerCamelCase			:						str            =flax_model.base_model_prefix

              # use params dict if the model contains batch norm layers and then add batch_stats keys,values to dict
              if "batch_stats" in flax_model.params:
                     _lowerCamelCase			:						List[str]            =flax_model.params['params']

                     _lowerCamelCase			:						Any            =flatten_dict(SCREAMING_SNAKE_CASE__	)
                     random_flax_state_dict.update(flatten_dict(flax_model.params['batch_stats']	)	)
              else:
                     _lowerCamelCase			:						str            =flax_model.params
                     _lowerCamelCase			:						List[Any]            =flatten_dict(SCREAMING_SNAKE_CASE__	)

              _lowerCamelCase			:						int            =(model_prefix not in flax_model_params) and (
                  model_prefix in {k.split('.'	)[0] for k in pt_state_dict.keys()}
              )
              _lowerCamelCase			:						Optional[Any]            =(model_prefix in flax_model_params) and (
                  model_prefix not in {k.split('.'	)[0] for k in pt_state_dict.keys()}
              )
              # Need to change some parameters name to match Flax names
              for pt_key, pt_tensor in pt_state_dict.items():
                     _lowerCamelCase			:						Dict            =tuple(pt_key.split('.'	)	)

                     # remove base model prefix if necessary
                     _lowerCamelCase			:						Union[str, Any]            =pt_tuple_key[0] == model_prefix
                     if load_model_with_head_into_base_model and has_base_model_prefix:
                            _lowerCamelCase			:						Any            =pt_tuple_key[1:]

                     # Correctly rename weight parameters
                     _lowerCamelCase      ,	_lowerCamelCase			:						Optional[Any]            =rename_key_and_reshape_tensor(
                         SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__	)
                     # add model prefix if necessary
                     _lowerCamelCase			:						Any            =(model_prefix,) + flax_key in random_flax_state_dict
                     if load_base_model_into_model_with_head and require_base_model_prefix:
                            _lowerCamelCase			:						Any            =(model_prefix,) + flax_key

                     if flax_key in random_flax_state_dict:
                            if flax_tensor.shape != random_flax_state_dict[flax_key].shape:
                                   raise ValueError(
                                       F'''PyTorch checkpoint seems to be incorrect. Weight {pt_key} was expected to be of shape '''
                                       F'''{random_flax_state_dict[flax_key].shape}, but is {flax_tensor.shape}.'''	)

            # add batch stats if the model contains batchnorm layers
                     if "batch_stats" in flax_model.params:
                            if "mean" in flax_key[-1]:
                                   _lowerCamelCase			:						int            =jnp.asarray(SCREAMING_SNAKE_CASE__	)
                                   continue
                            if "var" in flax_key[-1]:
                                   _lowerCamelCase			:						Optional[int]            =jnp.asarray(SCREAMING_SNAKE_CASE__	)
                                   continue
                            # remove num_batches_tracked key
                            if "num_batches_tracked" in flax_key[-1]:
                                   flax_state_dict.pop(SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__	)
                                   continue

                            # also add unexpected weight so that warning is thrown
                            _lowerCamelCase			:						Union[str, Any]            =jnp.asarray(SCREAMING_SNAKE_CASE__	)

                     else:
                            # also add unexpected weight so that warning is thrown
                            _lowerCamelCase			:						List[Any]            =jnp.asarray(SCREAMING_SNAKE_CASE__	)
       return unflatten_dict(SCREAMING_SNAKE_CASE__	)




def       a_ (       SCREAMING_SNAKE_CASE__   : int						,     SCREAMING_SNAKE_CASE__   : Union[str, Any]	):
       '''simple docstring'''





       _lowerCamelCase			:						int            =os.path.abspath(SCREAMING_SNAKE_CASE__	)
       logger.info(F'''Loading Flax weights from {flax_checkpoint_path}'''	)

       # import correct flax class
       _lowerCamelCase			:						str            =getattr(SCREAMING_SNAKE_CASE__						,     'Flax' + model.__class__.__name__	)

       # load flax weight dict
       with open(SCREAMING_SNAKE_CASE__						,     'rb'	) as state_f:
              try:
                     _lowerCamelCase			:						int            =from_bytes(SCREAMING_SNAKE_CASE__						,     state_f.read()	)
              except UnpicklingError:
                     raise EnvironmentError(F'''Unable to convert {flax_checkpoint_path} to Flax deserializable object. '''	)

       return load_flax_weights_in_pytorch_model(SCREAMING_SNAKE_CASE__						,     SCREAMING_SNAKE_CASE__	)




def       a_ (       SCREAMING_SNAKE_CASE__   : Tuple						,     SCREAMING_SNAKE_CASE__   : Dict	):
       '''simple docstring'''





       try:
              import torch  # noqa: F401
       except ImportError:
              logger.error(
                  'Loading a Flax weights in PyTorch, requires both PyTorch and Flax to be installed. Please see'
                  ' https://pytorch.org/ and https://flax.readthedocs.io/en/latest/installation.html for installation'
                  ' instructions.'	)
              raise

       # check if we have bf16 weights
       _lowerCamelCase			:						List[str]            =flatten_dict(jax.tree_util.tree_map(lambda SCREAMING_SNAKE_CASE__	: x.dtype == jnp.bfloataa						,     SCREAMING_SNAKE_CASE__	)	).values()
       if any(SCREAMING_SNAKE_CASE__	):
              # convert all weights to fp32 if the are bf16 since torch.from_numpy can-not handle bf16
              # and bf16 is not fully supported in PT yet.
              logger.warning(
                  'Found ``bfloat16`` weights in Flax model. Casting all ``bfloat16`` weights to ``float32`` '
                  'before loading those in PyTorch model.'	)
              _lowerCamelCase			:						Optional[Any]            =jax.tree_util.tree_map(
                  lambda SCREAMING_SNAKE_CASE__	: params.astype(np.floataa	) if params.dtype == jnp.bfloataa else params						,     SCREAMING_SNAKE_CASE__	)

       _lowerCamelCase			:						Optional[int]            =flatten_dict(SCREAMING_SNAKE_CASE__	)
       _lowerCamelCase			:						Optional[int]            =pt_model.state_dict()

       _lowerCamelCase			:						str            =(pt_model.base_model_prefix in flax_state) and (
           pt_model.base_model_prefix not in {k.split('.'	)[0] for k in pt_model_dict.keys()}
       )
       _lowerCamelCase			:						Optional[Any]            =(pt_model.base_model_prefix not in flax_state) and (
           pt_model.base_model_prefix in {k.split('.'	)[0] for k in pt_model_dict.keys()}
       )

       # keep track of unexpected & missing keys
       _lowerCamelCase			:						Optional[int]            =[]
       _lowerCamelCase			:						Union[str, Any]            =set(pt_model_dict.keys()	)

       for flax_key_tuple, flax_tensor in flax_state_dict.items():
              _lowerCamelCase			:						Optional[int]            =flax_key_tuple[0] == pt_model.base_model_prefix
              _lowerCamelCase			:						Optional[Any]            ='.'.join((pt_model.base_model_prefix,) + flax_key_tuple	) in pt_model_dict

              # adapt flax_key to prepare for loading from/to base model only
              if load_model_with_head_into_base_model and has_base_model_prefix:
                     _lowerCamelCase			:						str            =flax_key_tuple[1:]
              elif load_base_model_into_model_with_head and require_base_model_prefix:
                     _lowerCamelCase			:						Any            =(pt_model.base_model_prefix,) + flax_key_tuple

              # rename flax weights to PyTorch format
              if flax_key_tuple[-1] == "kernel" and flax_tensor.ndim == 4 and ".".join(SCREAMING_SNAKE_CASE__	) not in pt_model_dict:
                     # conv layer
                     _lowerCamelCase			:						Optional[Any]            =flax_key_tuple[:-1] + ('weight',)
                     _lowerCamelCase			:						Tuple            =jnp.transpose(SCREAMING_SNAKE_CASE__						,     (3, 2, 0, 1)	)
              elif flax_key_tuple[-1] == "kernel" and ".".join(SCREAMING_SNAKE_CASE__	) not in pt_model_dict:
                     # linear layer
                     _lowerCamelCase			:						Union[str, Any]            =flax_key_tuple[:-1] + ('weight',)
                     _lowerCamelCase			:						Optional[Any]            =flax_tensor.T
              elif flax_key_tuple[-1] in ["scale", "embedding"]:
                     _lowerCamelCase			:						Union[str, Any]            =flax_key_tuple[:-1] + ('weight',)

              # adding batch stats from flax batch norm to pt
              elif "mean" in flax_key_tuple[-1]:
                     _lowerCamelCase			:						Tuple            =flax_key_tuple[:-1] + ('running_mean',)
              elif "var" in flax_key_tuple[-1]:
                     _lowerCamelCase			:						Dict            =flax_key_tuple[:-1] + ('running_var',)

              if "batch_stats" in flax_state:
                     _lowerCamelCase			:						int            ='.'.join(flax_key_tuple[1:]	)  # Remove the params/batch_stats header
              else:
                     _lowerCamelCase			:						Tuple            ='.'.join(SCREAMING_SNAKE_CASE__	)

              # We also need to look at `pt_model_dict` and see if there are keys requiring further transformation.
              _lowerCamelCase			:						int            ={}
              # New `weight_norm` from https://github.com/huggingface/transformers/pull/24030
              for key in pt_model_dict:
                     _lowerCamelCase			:						List[str]            =key.split('.'	)
                     _lowerCamelCase			:						List[Any]            =None
                     if key_components[-3::2] == ["parametrizations", "original0"]:
                            _lowerCamelCase			:						Optional[Any]            =key_components[-2] + '_g'
                     elif key_components[-3::2] == ["parametrizations", "original1"]:
                            _lowerCamelCase			:						List[str]            =key_components[-2] + '_v'
                     if name is not None:
                            _lowerCamelCase			:						int            =key_components[:-3] + [name]
                            _lowerCamelCase			:						str            ='.'.join(SCREAMING_SNAKE_CASE__	)
                            _lowerCamelCase			:						Optional[Any]            =key

              if flax_key in special_pt_names:
                     _lowerCamelCase			:						Optional[int]            =special_pt_names[flax_key]

              if flax_key in pt_model_dict:
                     if flax_tensor.shape != pt_model_dict[flax_key].shape:
                            raise ValueError(
                                F'''Flax checkpoint seems to be incorrect. Weight {flax_key_tuple} was expected '''
                                F'''to be of shape {pt_model_dict[flax_key].shape}, but is {flax_tensor.shape}.'''	)
                     else:
                            # add weight to pytorch dict
                            _lowerCamelCase			:						List[str]            =np.asarray(SCREAMING_SNAKE_CASE__	) if not isinstance(SCREAMING_SNAKE_CASE__						,     np.ndarray	) else flax_tensor
                            _lowerCamelCase			:						Dict            =torch.from_numpy(SCREAMING_SNAKE_CASE__	)
                            # remove from missing keys
                            missing_keys.remove(SCREAMING_SNAKE_CASE__	)
              else:
                     # weight is not expected by PyTorch model
                     unexpected_keys.append(SCREAMING_SNAKE_CASE__	)

       pt_model.load_state_dict(SCREAMING_SNAKE_CASE__	)

       # re-transform missing_keys to list
       _lowerCamelCase			:						int            =list(SCREAMING_SNAKE_CASE__	)

       if len(SCREAMING_SNAKE_CASE__	) > 0:
              logger.warning(
                  'Some weights of the Flax model were not used when initializing the PyTorch model'
                  F''' {pt_model.__class__.__name__}: {unexpected_keys}\n- This IS expected if you are initializing'''
                  F''' {pt_model.__class__.__name__} from a Flax model trained on another task or with another architecture'''
                  ' (e.g. initializing a BertForSequenceClassification model from a FlaxBertForPreTraining model).\n- This'
                  F''' IS NOT expected if you are initializing {pt_model.__class__.__name__} from a Flax model that you expect'''
                  ' to be exactly identical (e.g. initializing a BertForSequenceClassification model from a'
                  ' FlaxBertForSequenceClassification model).'	)
       else:
              logger.warning(F'''All Flax model weights were used when initializing {pt_model.__class__.__name__}.\n'''	)
       if len(SCREAMING_SNAKE_CASE__	) > 0:
              logger.warning(
                  F'''Some weights of {pt_model.__class__.__name__} were not initialized from the Flax model and are newly'''
                  F''' initialized: {missing_keys}\nYou should probably TRAIN this model on a down-stream task to be able to'''
                  ' use it for predictions and inference.'	)
       else:
              logger.warning(
                  F'''All the weights of {pt_model.__class__.__name__} were initialized from the Flax model.\n'''
                  'If your task is similar to the task the model of the checkpoint was trained on, '
                  F'''you can already use {pt_model.__class__.__name__} for predictions without further training.'''	)

       return pt_model






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		   =			{
    'microsoft/focalnet-tiny': 'https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json',
}




class A    (  UpperCamelCase_       ,				UpperCamelCase_	):
      UpperCamelCase__				:    str ='focalnet'






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




             super().__init__(**lowercase_					)

             _lowerCamelCase			:						Union[str, Any]            =image_size
             _lowerCamelCase			:						str            =patch_size
             _lowerCamelCase			:						str            =num_channels
             _lowerCamelCase			:						Tuple            =embed_dim
             _lowerCamelCase			:						Dict            =use_conv_embed
             _lowerCamelCase			:						int            =hidden_sizes
             _lowerCamelCase			:						str            =depths
             _lowerCamelCase			:						int            =focal_levels
             _lowerCamelCase			:						List[Any]            =focal_windows
             _lowerCamelCase			:						List[Any]            =hidden_act
             _lowerCamelCase			:						int            =mlp_ratio
             _lowerCamelCase			:						Any            =hidden_dropout_prob
             _lowerCamelCase			:						Optional[Any]            =drop_path_rate
             _lowerCamelCase			:						int            =use_layerscale
             _lowerCamelCase			:						str            =layerscale_value
             _lowerCamelCase			:						Dict            =use_post_layernorm
             _lowerCamelCase			:						str            =use_post_layernorm_in_modulation
             _lowerCamelCase			:						List[Any]            =normalize_modulator
             _lowerCamelCase			:						Optional[Any]            =initializer_range
             _lowerCamelCase			:						List[str]            =layer_norm_eps
             _lowerCamelCase			:						Optional[int]            =encoder_stride
             _lowerCamelCase			:						List[str]            =['stem'] + [F'''stage{idx}''' for idx in range(1     ,  len(self.depths					) + 1					)]
             _lowerCamelCase      ,	_lowerCamelCase			:						Union[str, Any]            =get_aligned_output_features_output_indices(
                 out_features=lowercase_     ,  out_indices=lowercase_     ,  stage_names=self.stage_names					)


