





'''simple docstring'''






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


__lowerCamelCase						: int		=   logging.get_logger(__name__)

__lowerCamelCase						: List[str]		=   {
    '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 		UpperCAmelCase   (				lowercase_   ,     lowercase_):


		"""simple docstring"""







		lowerCAmelCase_					=				"""dinat"""

		lowerCAmelCase_					=				{
		    """num_attention_heads""": """num_heads""",
		    """num_hidden_layers""": """num_layers""",
		}


		def __init__(				self    :					Any							,	UpperCamelCase__    :					List[Any]=4							,	UpperCamelCase__    :					Any=3							,	UpperCamelCase__    :					Any=64							,	UpperCamelCase__    :					Dict=[3, 4, 6, 5]							,	UpperCamelCase__    :					str=[2, 4, 8, 16]							,	UpperCamelCase__    :					List[Any]=7							,	UpperCamelCase__    :					Dict=[[1, 8, 1], [1, 4, 1, 4], [1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1]]							,	UpperCamelCase__    :					Optional[int]=3.0							,	UpperCamelCase__    :					Optional[Any]=True							,	UpperCamelCase__    :					Tuple=0.0							,	UpperCamelCase__    :					Tuple=0.0							,	UpperCamelCase__    :					Dict=0.1							,	UpperCamelCase__    :					Any="gelu"							,	UpperCamelCase__    :					Any=0.02							,	UpperCamelCase__    :					Dict=1E-5							,	UpperCamelCase__    :					str=0.0							,	UpperCamelCase__    :					Tuple=None							,	UpperCamelCase__    :					str=None							,	**UpperCamelCase__    :					List[str]							,	)     ->						Any:
				super().__init__(**UpperCamelCase__  )

				_UpperCamelCase       			=patch_size
				_UpperCamelCase       			=num_channels
				_UpperCamelCase       			=embed_dim
				_UpperCamelCase       			=depths
				_UpperCamelCase       			=len(UpperCamelCase__  )
				_UpperCamelCase       			=num_heads
				_UpperCamelCase       			=kernel_size
				_UpperCamelCase       			=dilations
				_UpperCamelCase       			=mlp_ratio
				_UpperCamelCase       			=qkv_bias
				_UpperCamelCase       			=hidden_dropout_prob
				_UpperCamelCase       			=attention_probs_dropout_prob
				_UpperCamelCase       			=drop_path_rate
				_UpperCamelCase       			=hidden_act
				_UpperCamelCase       			=layer_norm_eps
				_UpperCamelCase       			=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
				_UpperCamelCase       			=int(embed_dim * 2 ** (len(UpperCamelCase__  ) - 1)  )
				_UpperCamelCase       			=layer_scale_init_value
				_UpperCamelCase       			=['''stem'''] + [F'''stage{idx}''' for idx in range(1							,	len(UpperCamelCase__  ) + 1  )]
				_UpperCamelCase			,     _UpperCamelCase       			=get_aligned_output_features_output_indices(
				    out_features=UpperCamelCase__							,	out_indices=UpperCamelCase__							,	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 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  return EnvironmentCommand()


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  return EnvironmentCommand(args.accelerate_config_file   )







class 		UpperCAmelCase   (				lowercase_):


  """simple docstring"""







  @staticmethod
  def   UpperCamelCase__      (				UpperCamelCase__    :					ArgumentParser  )     ->						Union[str, Any]:
    _UpperCamelCase       			=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    :					Tuple							,	UpperCamelCase__    :					Dict							,	*UpperCamelCase__    :					str  )     ->						None:
    _UpperCamelCase       			=accelerate_config_file


  def   UpperCamelCase__      (				self    :					str  )     ->						int:
    _UpperCamelCase       			='''not installed'''
    if is_safetensors_available():
      import safetensors

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

      _UpperCamelCase       			=F'''{safetensors.__version__} but is ignored because of PyTorch version too old.'''

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

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

      _UpperCamelCase       			=(
          '''\n'''.join([F'''\t- {prop}: {val}''' for prop, val in accelerate_config.items()]  )
          if isinstance(UpperCamelCase__							,	UpperCamelCase__  )
          else F'''\t{accelerate_config}'''
      )

    _UpperCamelCase       			='''not installed'''
    _UpperCamelCase       			='''NA'''
    if is_torch_available():
      import torch

      _UpperCamelCase       			=torch.__version__
      _UpperCamelCase       			=torch.cuda.is_available()

    _UpperCamelCase       			='''not installed'''
    _UpperCamelCase       			='''NA'''
    if is_tf_available():
      import tensorflow as tf

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

    _UpperCamelCase       			='''not installed'''
    _UpperCamelCase       			='''not installed'''
    _UpperCamelCase       			='''not installed'''
    _UpperCamelCase       			='''NA'''
    if is_flax_available():
      import flax
      import jax
      import jaxlib

      _UpperCamelCase       			=flax.__version__
      _UpperCamelCase       			=jax.__version__
      _UpperCamelCase       			=jaxlib.__version__
      _UpperCamelCase       			=jax.lib.xla_bridge.get_backend().platform

    _UpperCamelCase       			={
        '''`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   UpperCamelCase__      (				UpperCamelCase__    :					Optional[Any]  )     ->						Dict:
    return "\n".join([F'''- {prop}: {val}''' for prop, val in d.items()]  ) + "\n"






