





"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


A			      =	{
    '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''],
    '''tokenization_xlm''': ['''XLMTokenizer'''],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		A			      =	[
		    '''XLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''XLMForMultipleChoice''',
		    '''XLMForQuestionAnswering''',
		    '''XLMForQuestionAnsweringSimple''',
		    '''XLMForSequenceClassification''',
		    '''XLMForTokenClassification''',
		    '''XLMModel''',
		    '''XLMPreTrainedModel''',
		    '''XLMWithLMHeadModel''',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		A			      =	[
		    '''TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''TFXLMForMultipleChoice''',
		    '''TFXLMForQuestionAnsweringSimple''',
		    '''TFXLMForSequenceClassification''',
		    '''TFXLMForTokenClassification''',
		    '''TFXLMMainLayer''',
		    '''TFXLMModel''',
		    '''TFXLMPreTrainedModel''',
		    '''TFXLMWithLMHeadModel''',
		]


if TYPE_CHECKING:
		from .configuration_xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig, XLMOnnxConfig
		from .tokenization_xlm import XLMTokenizer

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_xlm import (
				    XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
				    XLMForMultipleChoice,
				    XLMForQuestionAnswering,
				    XLMForQuestionAnsweringSimple,
				    XLMForSequenceClassification,
				    XLMForTokenClassification,
				    XLMModel,
				    XLMPreTrainedModel,
				    XLMWithLMHeadModel,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_xlm import (
				    TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFXLMForMultipleChoice,
				    TFXLMForQuestionAnsweringSimple,
				    TFXLMForSequenceClassification,
				    TFXLMForTokenClassification,
				    TFXLMMainLayer,
				    TFXLMModel,
				    TFXLMPreTrainedModel,
				    TFXLMWithLMHeadModel,
				)

else:
		import sys

		A			      =	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
from __future__ import annotations

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





@dataclass
class     lowerCAmelCase__     :


		'''simple docstring'''






		lowerCAmelCase_     =   42
		lowerCAmelCase_     =   42





class     lowerCAmelCase__     :


		'''simple docstring'''






		def __init__(       self     :     int     ,  snake_case__     :     int		)      ->	Any:
				_lowerCamelCase				   =  [[] for _ in range(snake_case__		)]
				_lowerCamelCase				   =  size
		def __getitem__(       self     :     Dict     ,  snake_case__     :     int		)      ->	Iterator[Edge]:
				return iter(self._graph[vertex]		)
		@property
		def   _snake_case       (       self     :     str		)      ->	int:
				return self._size
		def   _snake_case       (       self     :     List[Any]     ,  snake_case__     :     int     ,  snake_case__     :     int     ,  snake_case__     :     int		)      ->	Tuple:
				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(snake_case__     ,  snake_case__		)		)



		def   _snake_case       (       self     :     Dict     ,  snake_case__     :     int     ,  snake_case__     :     int		)      ->	int | None:
				_lowerCamelCase				   =  deque([start_vertex]		)
				_lowerCamelCase				   =  [None] * self.size
				_lowerCamelCase				   =  0

				while queue:
						_lowerCamelCase				   =  queue.popleft()
						_lowerCamelCase				   =  distances[current_vertex]
						if current_distance is None:
								continue

						for edge in self[current_vertex]:
								_lowerCamelCase				   =  current_distance + edge.weight
								_lowerCamelCase				   =  distances[edge.destination_vertex]
								if (
								    isinstance(snake_case__     ,  snake_case__		)
								    and new_distance >= dest_vertex_distance
								):
										continue
								_lowerCamelCase				   =  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()