
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 						__magic_name__			(   __a      :	List[str]						):



     '''simple docstring'''




     return EnvironmentCommand()




class      __A(    __lowerCamelCase			):

  """simple docstring"""







  @staticmethod
  def 	UpperCAmelCase_ (SCREAMING_SNAKE_CASE_						):
       UpperCamelCase__				=    parser.add_parser("""env"""						)
       download_parser.set_defaults(func=SCREAMING_SNAKE_CASE_						)







  def 	UpperCAmelCase_ (self						):
       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(SCREAMING_SNAKE_CASE_						)						)

       return info







  @staticmethod
  def 	UpperCAmelCase_ (SCREAMING_SNAKE_CASE_						):
       return "\n".join([F"- {prop}: {val}" for prop, val in d.items()]						) + "\n"







import importlib
import inspect
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
lowerCamelCase_						     =					'''src/transformers'''


# This is to make sure the transformers module imported is the one in the repo.
lowerCamelCase_						     =					importlib.util.spec_from_file_location(
    '''transformers''',
    os.path.join(PATH_TO_TRANSFORMERS, '''__init__.py'''),
    submodule_search_locations=[PATH_TO_TRANSFORMERS],
)
lowerCamelCase_						     =					spec.loader.load_module()

lowerCamelCase_						     =					transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
lowerCamelCase_						     =					re.compile('''\[(.+?)\]\((https://huggingface\.co/.+?)\)''')


lowerCamelCase_						     =					{
    '''CLIPConfigMixin''',
    '''DecisionTransformerConfigMixin''',
    '''EncoderDecoderConfigMixin''',
    '''RagConfigMixin''',
    '''SpeechEncoderDecoderConfigMixin''',
    '''VisionEncoderDecoderConfigMixin''',
    '''VisionTextDualEncoderConfigMixin''',
}






def 						__magic_name__			(   ):



     '''simple docstring'''




     UpperCamelCase__				=    []

     for config_class in list(CONFIG_MAPPING.values()						):
          UpperCamelCase__				=    False

          # source code of `config_class`
          UpperCamelCase__				=    inspect.getsource(__a						)
          UpperCamelCase__				=    _re_checkpoint.findall(__a						)

          for checkpoint in checkpoints:
               # Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
               # For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
               UpperCamelCase__		,	UpperCamelCase__				=    checkpoint

               # verify the checkpoint name corresponds to the checkpoint link
               UpperCamelCase__				=    f"https://huggingface.co/{ckpt_name}"
               if ckpt_link == ckpt_link_from_name:
                    UpperCamelCase__				=    True
                    break

          UpperCamelCase__				=    config_class.__name__
          if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
               configs_without_checkpoint.append(__a						)

     if len(__a						) > 0:
          UpperCamelCase__				=    """\n""".join(sorted(__a						)						)
          raise ValueError(f"The following configurations don't contain any valid checkpoint:\n{message}"						)


if __name__ == "__main__":
    check_config_docstrings_have_checkpoints()





