

'''simple docstring'''







# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# or u belongs to V and v to U. We can also say that there is no edge that connects
# vertices of same set.
def  UpperCAmelCase__      ( UpperCAmelCase__			)     ->     Tuple:
       A_		   = [False] * len(UpperCAmelCase__			)
       A_		   = [-1] * len(UpperCAmelCase__			)

       def dfs(UpperCAmelCase__,    UpperCAmelCase__			):
              A_		   = True
              A_		   = c
              for u in graph[v]:
                     if not visited[u]:
                            dfs(UpperCAmelCase__,    1 - c			)

       for i in range(len(UpperCAmelCase__			)			):
              if not visited[i]:
                     dfs(UpperCAmelCase__,    0			)

       for i in range(len(UpperCAmelCase__			)			):
              for j in graph[i]:
                     if color[i] == color[j]:
                            return False

       return True


# Adjacency list of graph
__lowerCamelCase						    =      {0: [1, 3], 1: [0, 2], 2: [1, 3], 3: [0, 2], 4: []}







print(check_bipartite_dfs(graph))



'''simple docstring'''







from tempfile import TemporaryDirectory
from unittest import TestCase
from unittest.mock import MagicMock, patch

from transformers import AutoModel, TFAutoModel
from transformers.onnx import FeaturesManager
from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch


@require_torch
@require_tf
class    A__ ( _snake_case     ):



    def    snake_case_     (   self    )  -> Dict:





           '''simple docstring'''
           A_		   = SMALL_MODEL_IDENTIFIER
           A_		   = """pt"""
           A_		   = """tf"""



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> Tuple:





           '''simple docstring'''
           A_		   = AutoModel.from_pretrained(self.test_model    )
           model_pt.save_pretrained(UpperCamelCase__    )



    def    snake_case_     (   self						,			UpperCamelCase__    )  -> List[str]:





           '''simple docstring'''
           A_		   = TFAutoModel.from_pretrained(self.test_model						,			from_pt=UpperCamelCase__    )
           model_tf.save_pretrained(UpperCamelCase__    )



    def    snake_case_     (   self    )  -> Dict:





           '''simple docstring'''
           A_		   = """mock_framework"""

           # Framework provided - return whatever the user provides
           A_		   = FeaturesManager.determine_framework(self.test_model						,			UpperCamelCase__    )
           self.assertEqual(UpperCamelCase__						,			UpperCamelCase__    )

           # Local checkpoint and framework provided - return provided framework
           # PyTorch checkpoint
           with TemporaryDirectory() as local_pt_ckpt:
                  self._setup_pt_ckpt(UpperCamelCase__    )
                  A_		   = FeaturesManager.determine_framework(UpperCamelCase__						,			UpperCamelCase__    )
                  self.assertEqual(UpperCamelCase__						,			UpperCamelCase__    )

           # TensorFlow checkpoint
           with TemporaryDirectory() as local_tf_ckpt:
                  self._setup_tf_ckpt(UpperCamelCase__    )
                  A_		   = FeaturesManager.determine_framework(UpperCamelCase__						,			UpperCamelCase__    )
                  self.assertEqual(UpperCamelCase__						,			UpperCamelCase__    )



    def    snake_case_     (   self    )  -> int:





           '''simple docstring'''
           # PyTorch checkpoint
           with TemporaryDirectory() as local_pt_ckpt:
                  self._setup_pt_ckpt(UpperCamelCase__    )
                  A_		   = FeaturesManager.determine_framework(UpperCamelCase__    )
                  self.assertEqual(UpperCamelCase__						,			self.framework_pt    )

           # TensorFlow checkpoint
           with TemporaryDirectory() as local_tf_ckpt:
                  self._setup_tf_ckpt(UpperCamelCase__    )
                  A_		   = FeaturesManager.determine_framework(UpperCamelCase__    )
                  self.assertEqual(UpperCamelCase__						,			self.framework_tf    )

           # Invalid local checkpoint
           with TemporaryDirectory() as local_invalid_ckpt:
                  with self.assertRaises(UpperCamelCase__    ):
                         A_		   = FeaturesManager.determine_framework(UpperCamelCase__    )







    def    snake_case_     (   self    )  -> List[Any]:





           '''simple docstring'''
           A_		   = MagicMock(return_value=UpperCamelCase__    )
           with patch("""transformers.onnx.features.is_tf_available"""						,			UpperCamelCase__    ):
                  A_		   = FeaturesManager.determine_framework(self.test_model    )
                  self.assertEqual(UpperCamelCase__						,			self.framework_pt    )

           # PyTorch not in environment -> use TensorFlow
           A_		   = MagicMock(return_value=UpperCamelCase__    )
           with patch("""transformers.onnx.features.is_torch_available"""						,			UpperCamelCase__    ):
                  A_		   = FeaturesManager.determine_framework(self.test_model    )
                  self.assertEqual(UpperCamelCase__						,			self.framework_tf    )

           # Both in environment -> use PyTorch
           A_		   = MagicMock(return_value=UpperCamelCase__    )
           A_		   = MagicMock(return_value=UpperCamelCase__    )
           with patch("""transformers.onnx.features.is_tf_available"""						,			UpperCamelCase__    ), patch(
               """transformers.onnx.features.is_torch_available"""						,			UpperCamelCase__    ):
                  A_		   = FeaturesManager.determine_framework(self.test_model    )
                  self.assertEqual(UpperCamelCase__						,			self.framework_pt    )

           # Both not in environment -> raise error
           A_		   = MagicMock(return_value=UpperCamelCase__    )
           A_		   = MagicMock(return_value=UpperCamelCase__    )
           with patch("""transformers.onnx.features.is_tf_available"""						,			UpperCamelCase__    ), patch(
               """transformers.onnx.features.is_torch_available"""						,			UpperCamelCase__    ):
                  with self.assertRaises(UpperCamelCase__    ):
                         A_		   = FeaturesManager.determine_framework(self.test_model    )
