





'''simple docstring'''






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


snake_case_     =	logging.get_logger(__name__)

snake_case_     =	{
    '''shi-labs/dinat-mini-in1k-224''': '''https://huggingface.co/shi-labs/dinat-mini-in1k-224/resolve/main/config.json''',
    # See all Dinat models at https://huggingface.co/models?filter=dinat
}


class   _lowercase						(							snake_case__		,					snake_case__				):
   _UpperCamelCase       		=   '''dinat'''

   _UpperCamelCase       		=   {
       '''num_attention_heads''': '''num_heads''',
       '''num_hidden_layers''': '''num_layers''',
   }


   def __init__( self    ,   _UpperCAmelCase=4    ,   _UpperCAmelCase=3    ,   _UpperCAmelCase=64    ,   _UpperCAmelCase=[3, 4, 6, 5]    ,   _UpperCAmelCase=[2, 4, 8, 16]    ,   _UpperCAmelCase=7    ,   _UpperCAmelCase=[[1, 8, 1], [1, 4, 1, 4], [1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1]]    ,   _UpperCAmelCase=3.0    ,   _UpperCAmelCase=True    ,   _UpperCAmelCase=0.0    ,   _UpperCAmelCase=0.0    ,   _UpperCAmelCase=0.1    ,   _UpperCAmelCase="gelu"    ,   _UpperCAmelCase=0.02    ,   _UpperCAmelCase=1E-5    ,   _UpperCAmelCase=0.0    ,   _UpperCAmelCase=None    ,   _UpperCAmelCase=None    ,   **_UpperCAmelCase    ,   ):
       super().__init__(**_A					)

       A       :       Optional[int]							=						patch_size
       A       :       Dict							=						num_channels
       A       :       str							=						embed_dim
       A       :       str							=						depths
       A       :       Dict							=						len(_A					)
       A       :       Any							=						num_heads
       A       :       Any							=						kernel_size
       A       :       List[str]							=						dilations
       A       :       Union[str, Any]							=						mlp_ratio
       A       :       Optional[Any]							=						qkv_bias
       A       :       List[Any]							=						hidden_dropout_prob
       A       :       Dict							=						attention_probs_dropout_prob
       A       :       List[Any]							=						drop_path_rate
       A       :       Optional[Any]							=						hidden_act
       A       :       Union[str, Any]							=						layer_norm_eps
       A       :       List[Any]							=						initializer_range
       # we set the hidden_size attribute in order to make Dinat work with VisionEncoderDecoderModel
       # this indicates the channel dimension after the last stage of the model
       A       :       List[str]							=						int(embed_dim * 2 ** (len(_A					) - 1)					)
       A       :       Dict							=						layer_scale_init_value
       A       :       int							=						['stem'] + [f'''stage{idx}''' for idx in range(1    ,   len(_A					) + 1					)]
       A       :       Tuple							=						get_aligned_output_features_output_indices(
           out_features=_A    ,   out_indices=_A    ,   stage_names=self.stage_names					)










'''simple docstring'''






import importlib.util
import os
import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import (
    is_accelerate_available,
    is_flax_available,
    is_safetensors_available,
    is_tf_available,
    is_torch_available,
)
from . import BaseTransformersCLICommand
def 							_lowerCamelCase(  UpperCamelCase__    : Optional[int]		)		->  List[str]:
    return EnvironmentCommand()
def 							_lowerCamelCase(  UpperCamelCase__    : List[Any]		)		->  Tuple:
    return EnvironmentCommand(args.accelerate_config_file		)





class   _lowercase						(							a				):


   @staticmethod
   def 					snake_case				( _UpperCAmelCase					):
       A       :       Optional[Any]							=						parser.add_parser('''env'''					)
       download_parser.set_defaults(func=_UpperCAmelCase					)
       download_parser.add_argument(
           '''--accelerate-config_file'''    ,   default=_UpperCAmelCase    ,   help='''The accelerate config file to use for the default values in the launching script.'''    ,   )
       download_parser.set_defaults(func=_UpperCAmelCase					)


   def __init__( self    ,   _UpperCAmelCase    ,   *_UpperCAmelCase					):
       A       :       Any							=						accelerate_config_file


   def 					snake_case				( self					):
       A       :       Any							=						'''not installed'''
       if is_safetensors_available():
           import safetensors

           A       :       Dict							=						safetensors.__version__
       elif importlib.util.find_spec('''safetensors'''					) is not None:
           import safetensors

           A       :       int							=						f'''{safetensors.__version__} but is ignored because of PyTorch version too old.'''

       A       :       Tuple							=						'''not installed'''
       A       :       Tuple							=						'''not found'''
       if is_accelerate_available():
           import accelerate
           from accelerate.commands.config import default_config_file, load_config_from_file

           A       :       Any							=						accelerate.__version__
           # Get the default from the config file.
           if self._accelerate_config_file is not None or os.path.isfile(_UpperCAmelCase					):
               A       :       int							=						load_config_from_file(self._accelerate_config_file					).to_dict()

           A       :       Tuple							=						(
               '''\n'''.join([f'''\t- {prop}: {val}''' for prop, val in accelerate_config.items()]					)
               if isinstance(_UpperCAmelCase    ,   _UpperCAmelCase					)
               else f'''\t{accelerate_config}'''
           )

       A       :       str							=						'''not installed'''
       A       :       Optional[Any]							=						'''NA'''
       if is_torch_available():
           import torch

           A       :       Optional[int]							=						torch.__version__
           A       :       List[Any]							=						torch.cuda.is_available()

       A       :       Dict							=						'''not installed'''
       A       :       Any							=						'''NA'''
       if is_tf_available():
           import tensorflow as tf

           A       :       Optional[int]							=						tf.__version__
           try:
               # deprecated in v2.1
               A       :       int							=						tf.test.is_gpu_available()
           except AttributeError:
               # returns list of devices, convert to bool
               A       :       Optional[int]							=						bool(tf.config.list_physical_devices('''GPU'''					)					)

       A       :       str							=						'''not installed'''
       A       :       Dict							=						'''not installed'''
       A       :       int							=						'''not installed'''
       A       :       Tuple							=						'''NA'''
       if is_flax_available():
           import flax
           import jax
           import jaxlib

           A       :       Any							=						flax.__version__
           A       :       Tuple							=						jax.__version__
           A       :       int							=						jaxlib.__version__
           A       :       List[Any]							=						jax.lib.xla_bridge.get_backend().platform

       A       :       Union[str, Any]							=						{
           '''`transformers` version''': version,
           '''Platform''': platform.platform(),
           '''Python version''': platform.python_version(),
           '''Huggingface_hub version''': huggingface_hub.__version__,
           '''Safetensors version''': f'''{safetensors_version}''',
           '''Accelerate version''': f'''{accelerate_version}''',
           '''Accelerate config''': f'''{accelerate_config_str}''',
           '''PyTorch version (GPU?)''': f'''{pt_version} ({pt_cuda_available})''',
           '''Tensorflow version (GPU?)''': f'''{tf_version} ({tf_cuda_available})''',
           '''Flax version (CPU?/GPU?/TPU?)''': f'''{flax_version} ({jax_backend})''',
           '''Jax version''': f'''{jax_version}''',
           '''JaxLib version''': f'''{jaxlib_version}''',
           '''Using GPU in script?''': '''<fill in>''',
           '''Using distributed or parallel set-up in script?''': '''<fill in>''',
       }

       print('''\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n'''					)
       print(self.format_dict(_UpperCAmelCase					)					)

       return info


   @staticmethod
   def 					snake_case				( _UpperCAmelCase					):
       return "\n".join([f'''- {prop}: {val}''' for prop, val in d.items()]					) + "\n"
