class_docstr: Test `FeaturesManager.determine_framework`
class_docstr_tok: ["Test","`","FeaturesManager.determine_framework","`"]
docstr: Ensure that the determined framework is the one available in the environment.
  
  For the functionality to execute, framework and local checkpoints are not provided.
docstr_tok: ["Ensure","that","the","determined","framework","is","the","one","available","in","the","environment",".","For","the","functionality","to","execute",",","framework","and","local","checkpoints","are","not","provided","."]
code: def test_from_environment(self):
      """
      Ensure that the determined framework is the one available in the environment.
  
      For the functionality to execute, framework and local checkpoints are not provided.
      """
      # Framework not provided, hub model is used (no local checkpoint directory)
      # TensorFlow not in environment -> use PyTorch
      mock_tf_available = MagicMock(return_value=False)
      with patch(
          "transformers.onnx.features.is_tf_available",
          mock_tf_available,
      ):
          result = FeaturesManager.determine_framework(self.test_model)
          self.assertEqual(result, self.framework_pt)
  
      # PyTorch not in environment -> use TensorFlow
      mock_torch_available = MagicMock(return_value=False)
      with patch(
          "transformers.onnx.features.is_torch_available",
          mock_torch_available,
      ):
          result = FeaturesManager.determine_framework(self.test_model)
          self.assertEqual(result, self.framework_tf)
  
      # Both in environment -> use PyTorch
      mock_tf_available = MagicMock(return_value=True)
      mock_torch_available = MagicMock(return_value=True)
      with patch(
          "transformers.onnx.features.is_tf_available",
          mock_tf_available,
      ), patch(
          "transformers.onnx.features.is_torch_available",
          mock_torch_available,
      ):
          result = FeaturesManager.determine_framework(self.test_model)
          self.assertEqual(result, self.framework_pt)
  
      # Both not in environment -> raise error
      mock_tf_available = MagicMock(return_value=False)
      mock_torch_available = MagicMock(return_value=False)
      with patch(
          "transformers.onnx.features.is_tf_available",
          mock_tf_available,
      ), patch(
          "transformers.onnx.features.is_torch_available",
          mock_torch_available,
      ):
          with self.assertRaises(EnvironmentError):
              result = FeaturesManager.determine_framework(
                  self.test_model
              )
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/tests/onnx/test_features.py
imports: 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
label_desc: Use image node_id 6 for calling the DetermineFrameworkTest obj's underlying member method code with example usage: obj.test_from_environment() without return types