





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__A     =    {
    "configuration_funnel": ["FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP", "FunnelConfig"],
    "convert_funnel_original_tf_checkpoint_to_pytorch": [],
    "tokenization_funnel": ["FunnelTokenizer"],
}

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __A     =    ["FunnelTokenizerFast"]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __A     =    [
         "FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST",
         "FunnelBaseModel",
         "FunnelForMaskedLM",
         "FunnelForMultipleChoice",
         "FunnelForPreTraining",
         "FunnelForQuestionAnswering",
         "FunnelForSequenceClassification",
         "FunnelForTokenClassification",
         "FunnelModel",
         "FunnelPreTrainedModel",
         "load_tf_weights_in_funnel",
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __A     =    [
         "TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST",
         "TFFunnelBaseModel",
         "TFFunnelForMaskedLM",
         "TFFunnelForMultipleChoice",
         "TFFunnelForPreTraining",
         "TFFunnelForQuestionAnswering",
         "TFFunnelForSequenceClassification",
         "TFFunnelForTokenClassification",
         "TFFunnelModel",
         "TFFunnelPreTrainedModel",
     ]


if TYPE_CHECKING:
     from .configuration_funnel import FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP, FunnelConfig
     from .tokenization_funnel import FunnelTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_funnel_fast import FunnelTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_funnel import (
              FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST,
              FunnelBaseModel,
              FunnelForMaskedLM,
              FunnelForMultipleChoice,
              FunnelForPreTraining,
              FunnelForQuestionAnswering,
              FunnelForSequenceClassification,
              FunnelForTokenClassification,
              FunnelModel,
              FunnelPreTrainedModel,
              load_tf_weights_in_funnel,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_funnel import (
              TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFFunnelBaseModel,
              TFFunnelForMaskedLM,
              TFFunnelForMultipleChoice,
              TFFunnelForPreTraining,
              TFFunnelForQuestionAnswering,
              TFFunnelForSequenceClassification,
              TFFunnelForTokenClassification,
              TFFunnelModel,
              TFFunnelPreTrainedModel,
          )

else:
     import sys

     __A     =    _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)








from __future__ import annotations





def 					lowerCAmelCase_			(	__a     ,   __a		)					->		List[Any]:







  """simple docstring"""





  print(F"""Vertex\tShortest Distance from vertex {src}"""		)
  for i, d in enumerate(__a		):
    print(F"""{i}\t\t{d}"""		)





def 					lowerCAmelCase_			(	__a     ,   __a     ,   __a		)					->		Tuple:







  """simple docstring"""





  for j in range(__a		):
    lowerCamelCase__  , lowerCamelCase__  , lowerCamelCase__:				str        =(graph[j][k] for k in ["src", "dst", "weight"])
    if distance[u] != float("inf"		) and distance[u] + w < distance[v]:
      return True
  return False





def 					lowerCAmelCase_			(	__a     ,   __a     ,   __a     ,   __a		)					->		list[float]:







  """simple docstring"""





  lowerCamelCase__:				List[str]        =[float("inf"		)] * vertex_count
  lowerCamelCase__:				List[str]        =0.0

  for _ in range(vertex_count - 1		):
    for j in range(__a		):
      lowerCamelCase__  , lowerCamelCase__  , lowerCamelCase__:				Union[str, Any]        =(graph[j][k] for k in ["src", "dst", "weight"])

      if distance[u] != float("inf"		) and distance[u] + w < distance[v]:
        lowerCamelCase__:				int        =distance[u] + w

  lowerCamelCase__:				Tuple        =check_negative_cycle(__a     ,   __a     ,   __a		)
  if negative_cycle_exists:
    raise Exception("Negative cycle found"		)

  return distance


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     __A     =    int(input("Enter number of vertices: ").strip())
     __A     =    int(input("Enter number of edges: ").strip())

     __A     =    [{} for _ in range(E)]

     for i in range(E):
          print("Edge ", i + 1)
          __A ,     __A ,     __A     =    (
              int(x)
              for x in input("Enter source, destination, weight: ").strip().split(" ")
          )
          __A     =    {"src": src, "dst": dest, "weight": weight}

     __A     =    int(input("\nEnter shortest path source:").strip())
     __A     =    bellman_ford(graph, V, E, source)
     print_distance(shortest_distance, 0)

