






"""simple docstring"""





import os
import shutil
import unittest
from unittest.mock import patch

from transformers.testing_utils import CaptureStd, is_pt_tf_cross_test, require_torch







class 						_a  (		unittest.TestCase       ):





   '''simple docstring'''






   @patch("sys.argv"					, ["fakeprogrampath", "env"])
   def __lowercase							(       self)			->   List[Any]:




          '''simple docstring'''




          import transformers.commands.transformers_cli

          with CaptureStd() as cs:
                 transformers.commands.transformers_cli.main()
          self.assertIn("Python version"					, cs.out)
          self.assertIn("Platform"					, cs.out)
          self.assertIn("Using distributed or parallel set-up in script?"					, cs.out)





   @is_pt_tf_cross_test
   @patch(
       "sys.argv"					, ["fakeprogrampath", "pt-to-tf", "--model-name", "hf-internal-testing/tiny-random-gptj", "--no-pr"])
   def __lowercase							(       self)			->   Optional[Any]:




          '''simple docstring'''




          import transformers.commands.transformers_cli

          shutil.rmtree("/tmp/hf-internal-testing/tiny-random-gptj"					, ignore_errors=UpperCAmelCase_)  # cleans potential past runs
          transformers.commands.transformers_cli.main()

          # The original repo has no TF weights -- if they exist, they were created by the CLI
          self.assertTrue(os.path.exists("/tmp/hf-internal-testing/tiny-random-gptj/tf_model.h5"))





   @require_torch
   @patch("sys.argv"					, ["fakeprogrampath", "download", "hf-internal-testing/tiny-random-gptj", "--cache-dir", "/tmp"])
   def __lowercase							(       self)			->   Tuple:




          '''simple docstring'''




          import transformers.commands.transformers_cli

          # # remove any previously downloaded model to start clean
          shutil.rmtree("/tmp/models--hf-internal-testing--tiny-random-gptj"					, ignore_errors=UpperCAmelCase_)

          # run the command
          transformers.commands.transformers_cli.main()

          # check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--tiny-random-gptj
          self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/blobs"))
          self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/refs"))
          self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/snapshots"))





   @require_torch
   @patch(
       "sys.argv"					, [
           "fakeprogrampath",
           "download",
           "hf-internal-testing/test_dynamic_model_with_tokenizer",
           "--trust-remote-code",
           "--cache-dir",
           "/tmp",
       ]					, )
   def __lowercase							(       self)			->   List[str]:




          '''simple docstring'''




          import transformers.commands.transformers_cli

          # # remove any previously downloaded model to start clean
          shutil.rmtree("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer"					, ignore_errors=UpperCAmelCase_)

          # run the command
          transformers.commands.transformers_cli.main()

          # check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer
          self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/blobs"))
          self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/refs"))
          self.assertTrue(
              os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/snapshots"))














"""simple docstring"""





UpperCamelCase					=     float("""inf""")







class 						_a  :





   '''simple docstring'''






   def __init__(       self					, UpperCAmelCase_)			->   List[str]:




          '''simple docstring'''




          lowercase__:							Optional[Any]         =     [0] * n
          lowercase__:							Dict         =     [0] * n
          lowercase__:							List[Any]         =     [0] * n
          lowercase__:							str         =     [[] for _ in range(UpperCAmelCase_)]





   def __lowercase							(       self					, UpperCAmelCase_					, UpperCAmelCase_					, UpperCAmelCase_					, UpperCAmelCase_=0)			->   Optional[int]:




          '''simple docstring'''




          self.adj[a].append([b, len(self.adj[b]), c, 0])
          self.adj[b].append([a, len(self.adj[a]) - 1, rcap, 0])





   def __lowercase							(       self					, UpperCAmelCase_					, UpperCAmelCase_					, UpperCAmelCase_)			->   Union[str, Any]:




          '''simple docstring'''




          if vertex == sink or not flow:
                 return flow

          for i in range(self.ptr[vertex]					, len(self.adj[vertex])):
                 lowercase__:							Optional[Any]         =     self.adj[vertex][i]
                 if self.lvl[e[0]] == self.lvl[vertex] + 1:
                        lowercase__:							Optional[int]         =     self.depth_first_search(e[0]					, UpperCAmelCase_					, min(UpperCAmelCase_					, e[2] - e[3]))
                        if p:
                               self.adj[vertex][i][3] += p
                               self.adj[e[0]][e[1]][3] -= p
                               return p
                 lowercase__:							int         =     self.ptr[vertex] + 1
          return 0





   def __lowercase							(       self					, UpperCAmelCase_					, UpperCAmelCase_)			->   str:




          '''simple docstring'''




          lowercase__    ,      lowercase__:							Union[str, Any]         =     0, source
          for l in range(31):  # noqa: E741  l = 30 maybe faster for random data
                 while True:
                        lowercase__    ,      lowercase__:							Union[str, Any]         =     [0] * len(self.q), [0] * len(self.q)
                        lowercase__    ,      lowercase__    ,      lowercase__:							str         =     0, 1, 1
                        while qi < qe and not self.lvl[sink]:
                               lowercase__:							Tuple         =     self.q[qi]
                               qi += 1
                               for e in self.adj[v]:
                                      if not self.lvl[e[0]] and (e[2] - e[3]) >> (30 - l):
                                             lowercase__:							Optional[int]         =     e[0]
                                             qe += 1
                                             lowercase__:							str         =     self.lvl[v] + 1

                        lowercase__:							List[str]         =     self.depth_first_search(UpperCAmelCase_					, UpperCAmelCase_					, UpperCAmelCase_)
                        while p:
                               flow += p
                               lowercase__:							Any         =     self.depth_first_search(UpperCAmelCase_					, UpperCAmelCase_					, UpperCAmelCase_)

                        if not self.lvl[sink]:
                               break

          return flow
UpperCamelCase					=     Dinic(10)
UpperCamelCase					=     0
UpperCamelCase					=     9
for vertex in range(1, 5):
  graph.add_edge(source, vertex, 1)
for vertex in range(5, 9):
  graph.add_edge(vertex, sink, 1)
for vertex in range(1, 5):
  graph.add_edge(vertex, vertex + 4, 1)

# Now we can know that is the maximum flow(source -> sink)
print(graph.max_flow(source, sink))






