






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   UpperCamelCase  (       ):




     '''simple docstring'''






     __snake_case			:Union[str, Any]          =						[]

     for config_class in list(CONFIG_MAPPING.values()  ):
          __snake_case			:Optional[Any]          =						False

          # source code of `config_class`
          __snake_case			:Dict          =						inspect.getsource(snake_case__  )
          __snake_case			:int          =						_re_checkpoint.findall(snake_case__  )

          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')`
               __snake_case			:Union[str, Any]          =						checkpoint

               # verify the checkpoint name corresponds to the checkpoint link
               __snake_case			:Any          =						f'''https://huggingface.co/{ckpt_name}'''
               if ckpt_link == ckpt_link_from_name:
                    __snake_case			:Optional[int]          =						True
                    break

          __snake_case			:Tuple          =						config_class.__name__
          if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
               configs_without_checkpoint.append(snake_case__  )

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


if __name__ == "__main__":
     check_config_docstrings_have_checkpoints()










from __future__ import annotations

from collections import deque
from collections.abc import Iterator
from dataclasses import dataclass




@dataclass
class 			snake_case__   :

       '''simple docstring'''
       lowerCamelCase							:				int
       lowerCamelCase							:				int




class 			snake_case__   :

       '''simple docstring'''



       def __init__(							self			,						a__    ) ->      Any:






            '''simple docstring'''





            __snake_case			:list[list[Edge]]          =						[[] for _ in range(a__    )]
            __snake_case			:List[str]          =						size



       def __getitem__(							self			,						a__    ) ->      Iterator[Edge]:






            '''simple docstring'''





            return iter(self._graph[vertex]    )



       @property
       def 					__lowercase						(							self    ) ->      str:






            '''simple docstring'''





            return self._size



       def 					__lowercase						(							self			,						a__			,						a__			,						a__    ) ->      List[Any]:






            '''simple docstring'''





            if weight not in (0, 1):
                 raise ValueError("""Edge weight must be either 0 or 1."""    )

            if to_vertex < 0 or to_vertex >= self.size:
                 raise ValueError("""Vertex indexes must be in [0; size)."""    )

            self._graph[from_vertex].append(Edge(a__			,						a__    )    )



       def 					__lowercase						(							self			,						a__			,						a__    ) ->      int | None:






            '''simple docstring'''





            __snake_case			:Optional[Any]          =						deque([start_vertex]    )
            __snake_case			:list[int | None]          =						[None] * self.size
            __snake_case			:Tuple          =						0

            while queue:
                 __snake_case			:List[Any]          =						queue.popleft()
                 __snake_case			:Optional[Any]          =						distances[current_vertex]
                 if current_distance is None:
                      continue

                 for edge in self[current_vertex]:
                      __snake_case			:Optional[Any]          =						current_distance + edge.weight
                      __snake_case			:Dict          =						distances[edge.destination_vertex]
                      if (
                          isinstance(a__			,						a__    )
                          and new_distance >= dest_vertex_distance
                      ):
                           continue
                      __snake_case			:Dict          =						new_distance
                      if edge.weight == 0:
                           queue.appendleft(edge.destination_vertex    )
                      else:
                           queue.append(edge.destination_vertex    )

            if distances[finish_vertex] is None:
                 raise ValueError("""No path from start_vertex to finish_vertex."""    )

            return distances[finish_vertex]


if __name__ == "__main__":
     import doctest

     doctest.testmod()


