





import inspect
import re

from transformers.utils import direct_transformers_import


# 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
lowercase :			List[str]     		=    """src/transformers"""


# This is to make sure the transformers module imported is the one in the repo.
lowercase :			List[Any]     		=    direct_transformers_import(PATH_TO_TRANSFORMERS)

lowercase :			Tuple     		=    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)`
lowercase :			int     		=    re.compile(r"""\[(.+?)\]\((https://huggingface\.co/.+?)\)""")


lowercase :			Any     		=    {
    """DecisionTransformerConfig""",
    """EncoderDecoderConfig""",
    """MusicgenConfig""",
    """RagConfig""",
    """SpeechEncoderDecoderConfig""",
    """TimmBackboneConfig""",
    """VisionEncoderDecoderConfig""",
    """VisionTextDualEncoderConfig""",
    """LlamaConfig""",
}



def A_      (						A__							)    ->						Optional[Any]:
       a__		:      Optional[Any]					=							None

       # source code of `config_class`
       a__		:      List[str]					=							inspect.getsource(__a							)
       a__		:      Optional[int]					=							_re_checkpoint.findall(__a							)

       # Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
       # For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
       for ckpt_name, ckpt_link in checkpoints:
              # allow the link to end with `/`
              if ckpt_link.endswith('/'							):
                     a__		:      List[str]					=							ckpt_link[:-1]

              # verify the checkpoint name corresponds to the checkpoint link
              a__		:      int					=							F'https://huggingface.co/{ckpt_name}'
              if ckpt_link == ckpt_link_from_name:
                     a__		:      str					=							ckpt_name
                     break

       return checkpoint



def A_      (						)    ->						str:
       a__		:      Optional[int]					=							[]

       for config_class in list(CONFIG_MAPPING.values()							):
              # Skip deprecated models
              if "models.deprecated" in config_class.__module__:
                     continue
              a__		:      Optional[Any]					=							get_checkpoint_from_config_class(__a							)

              a__		:      Union[str, Any]					=							config_class.__name__
              if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
                     configs_without_checkpoint.append(__a							)

       if len(__a							) > 0:
              a__		:      int					=							'\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()




"""simple docstring"""




from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow


if is_tf_available():
						import numpy as np
						import tensorflow as tf

						from transformers import TFCamembertModel





@require_tf
@require_sentencepiece
@require_tokenizers
class 			snake_case  (				unittest.TestCase ):

							@slow
							def _lowercase       (self     ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_    			=			TFCamembertModel.from_pretrained('''jplu/tf-camembert-base'''     )

									SCREAMING_SNAKE_CASE_    			=			tf.convert_to_tensor(
									    [[5, 1_21, 11, 6_60, 16, 7_30, 2_55_43, 1_10, 83, 6]]							,							dtype=tf.intaa							,							)  # J'aime le camembert !"

									SCREAMING_SNAKE_CASE_    			=			model(SCREAMING_SNAKE_CASE_     )['''last_hidden_state''']
									SCREAMING_SNAKE_CASE_    			=			tf.TensorShape((1, 10, 7_68)     )
									self.assertEqual(output.shape							,							SCREAMING_SNAKE_CASE_     )
									# compare the actual values for a slice.
									SCREAMING_SNAKE_CASE_    			=			tf.convert_to_tensor(
									    [[[-0.02_54, 0.02_35, 0.10_27], [0.06_06, -0.18_11, -0.04_18], [-0.15_61, -0.11_27, 0.26_87]]]							,							dtype=tf.floataa							,							)
									# camembert = torch.hub.load('pytorch/fairseq', 'camembert.v0')
									# camembert.eval()
									# expected_slice = roberta.model.forward(input_ids)[0][:, :3, :3].detach()

									self.assertTrue(np.allclose(output[:, :3, :3].numpy()							,							expected_slice.numpy()							,							atol=1e-4     )     )