






"""simple docstring"""


import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available
from . import BaseDiffusersCLICommand






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  return EnvironmentCommand()


class        a				(		lowerCAmelCase_   ):


    @staticmethod
    def      lowerCAmelCase_  (					__lowerCAmelCase	:  ArgumentParser					):
      _UpperCAmelCase						 =      parser.add_parser("""env"""					)
      download_parser.set_defaults(func=__lowerCAmelCase					)


    def      lowerCAmelCase_  (					self	:  Dict					):
      _UpperCAmelCase						 =      huggingface_hub.__version__

      _UpperCAmelCase						 =      """not installed"""
      _UpperCAmelCase						 =      """NA"""
      if is_torch_available():
        import torch

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

      _UpperCAmelCase						 =      """not installed"""
      if is_transformers_available():
        import transformers

        _UpperCAmelCase						 =      transformers.__version__

      _UpperCAmelCase						 =      """not installed"""
      if is_accelerate_available():
        import accelerate

        _UpperCAmelCase						 =      accelerate.__version__

      _UpperCAmelCase						 =      """not installed"""
      if is_xformers_available():
        import xformers

        _UpperCAmelCase						 =      xformers.__version__

      _UpperCAmelCase						 =      {
          """`diffusers` version""": version,
          """Platform""": platform.platform(),
          """Python version""": platform.python_version(),
          """PyTorch version (GPU?)""": f'''{pt_version} ({pt_cuda_available})''',
          """Huggingface_hub version""": hub_version,
          """Transformers version""": transformers_version,
          """Accelerate version""": accelerate_version,
          """xFormers version""": xformers_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(__lowerCAmelCase					)					)

      return info


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

"""simple docstring"""


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


UpperCAmelCase__  		=						logging.get_logger(__name__)

UpperCAmelCase__  		=						{
    """shi-labs/nat-mini-in1k-224""": """https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json""",
    # See all Nat models at https://huggingface.co/models?filter=nat
}


class        a				(		lowerCAmelCase_	,							lowerCAmelCase_   ):
    _snake_case     :  Union[str, Any]     							=							'nat'

    _snake_case     :  List[str]     							=							{
        'num_attention_heads': 'num_heads',
        'num_hidden_layers': 'num_layers',
    }


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

      _UpperCAmelCase						 =      patch_size
      _UpperCAmelCase						 =      num_channels
      _UpperCAmelCase						 =      embed_dim
      _UpperCAmelCase						 =      depths
      _UpperCAmelCase						 =      len(__lowerCAmelCase					)
      _UpperCAmelCase						 =      num_heads
      _UpperCAmelCase						 =      kernel_size
      _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 Nat work with VisionEncoderDecoderModel
      # this indicates the channel dimension after the last stage of the model
      _UpperCAmelCase						 =      int(embed_dim * 2 ** (len(__lowerCAmelCase					) - 1)					)
      _UpperCAmelCase						 =      layer_scale_init_value
      _UpperCAmelCase						 =      ["""stem"""] + [f'''stage{idx}''' for idx in range(1   ,				len(__lowerCAmelCase					) + 1					)]
      _UpperCAmelCase ,				_UpperCAmelCase						 =      get_aligned_output_features_output_indices(
          out_features=__lowerCAmelCase   ,				out_indices=__lowerCAmelCase   ,				stage_names=self.stage_names					)
