# Path: tensorflow_decision_forests/tensorflow/ops/inference/api.py
# MISSING_NON_INTEGERIZED_CATEGORICAL_STORED_AS_INT = 0x7FFFFFFF - 2
# class Model(object):
# class ModelV2(tracking.AutoTrackable):
# class _InferenceArgsBuilder(tracking.AutoTrackable):
# class _AbstractModelLoader(six.with_metaclass(abc.ABCMeta, object)):
# class _CompiledSimpleMLModelResource(tracking.TrackableResource):
# class _DiskModelLoader(_AbstractModelLoader, tracking.AutoTrackable):
#   def __init__(self,
#                model_path: Text,
#                tensor_model_path: Optional[Tensor] = None,
#                verbose: Optional[bool] = True):
#   def init_op(self) -> InitOp:
#   def apply(self, features: Dict[Text, Tensor]) -> ModelOutput:
#   def __init__(self,
#                model_path: Text,
#                verbose: Optional[bool] = True,
#                output_types: Optional[List[str]] = []):
#   def apply_get_leaves(self, features: Dict[Text, Tensor]) -> Any:
#   def apply(self, features: Dict[Text, Tensor]) -> ModelOutput:
# def _create_model_identifier() -> Text:
#   def __init__(self, verbose: Optional[bool] = True):
#   def build_from_model_path(self, model_path: Text):
#   def build_from_dataspec_and_header(self,
#                                      dataspec: data_spec_pb2.DataSpecification,
#                                      header: abstract_model_pb2.AbstractModel):
#   def init_op(self) -> Tensor:
#   def build_inference_op_args(
#       self,
#       features: Dict[Text, Tensor],
#       output_leaves: Optional[bool] = False) -> Dict[Text, Any]:
#   def _register_input_feature(self, name: Text, value: Tensor,
#                               feature_maps: FeatureMaps) -> None:
#   def _create_str_to_int_tables(self):
#   def _dict_to_list_sorted_by_key(src: Dict[Any, Any]) -> List[Any]:
#   def _all_feature_idxs(feature_maps: FeatureMaps):
#   def _check_all_input_features_are_provided(self, feature_maps):
#   def _get_dense_output_dim(self):
#   def _prepare_and_check_numerical_feature(self, name: Text, value: Tensor):
#   def _prepare_and_check_boolean_feature(self, name: Text, value: Tensor):
#   def _prepare_and_check_categorical_feature(
#       self, name: Text, value: Tensor,
#       feature_spec: data_spec_pb2.Column) -> Tensor:
#   def _prepare_and_check_categorical_set_feature(
#       self, name: Text, value: Tensor,
#       feature_spec: data_spec_pb2.Column) -> Tensor:
#   def initialize(self, model: "_CompiledSimpleMLModelResource") -> tf.Operation:
#   def __init__(self, model_loader: _AbstractModelLoader):
#   def _create_resource(self):
#   def _initialize(self):
#   def __init__(self, model_path, output_types: List[str]):
#   def initialize(self, model: _CompiledSimpleMLModelResource) -> tf.Operation:
#   def get_model_path(self) -> Tensor:
# 
# Path: tensorflow_decision_forests/tensorflow/ops/inference/test_utils.py
# def build_toy_data_spec(add_boolean_features=False, has_catset=False):
# def build_toy_random_forest(path,
#                             winner_take_all_inference,
#                             add_boolean_features=False,
#                             has_catset=False,
#                             num_trees=2):
# def build_toy_gbdt(path, num_classes):
# def build_toy_input_features(use_rank_two=False, has_catset=False):
# def build_toy_input_feature_values(features,
#                                    use_rank_two=False,
#                                    has_catset=False):
#   def shape(x):
#       def __getitem__(self, key):
# def expected_toy_predictions_rf_weighted(add_boolean_features=False):
# def expected_toy_predictions_rf_wta(add_boolean_features=False,
#                                     has_catset=False):
# def expected_toy_predictions_gbdt_binary():
# def expected_toy_predictions_gbdt_multiclass():
#     class Identity:


import os
import tempfile
import tensorflow.compat.v1 as tf
from tensorflow_decision_forests.tensorflow.ops.inference import api as inference
from tensorflow_decision_forests.tensorflow.ops.inference import test_utils
from absl.testing import parameterized
from absl import flags
from absl import logging
from __future__ import print_function





def data_root_path() -> str:
  return ""


def test_data_path() -> str:
  return os.path.join(data_root_path(),
                      "external/ydf/yggdrasil_decision_forests/test_data")


class TfOpTest(parameterized.TestCase, tf.test.TestCase):

  @parameterized.named_parameters(
      ("base", False, False),
      ("boolean", True, False),
      ("catset", False, True),
  )
  def test_toy_rf_classification_winner_takes_all(self, add_boolean_features,
                                                  has_catset):

    with tf.Graph().as_default():

      # Create toy model.
      model_path = os.path.join(
          tempfile.mkdtemp(dir=self.get_temp_dir()), "test_basic_rf_wta")

# Path: tensorflow_decision_forests/tensorflow/ops/inference/api.py
# MISSING_NON_INTEGERIZED_CATEGORICAL_STORED_AS_INT = 0x7FFFFFFF - 2
# class Model(object):
# class ModelV2(tracking.AutoTrackable):
# class _InferenceArgsBuilder(tracking.AutoTrackable):
# class _AbstractModelLoader(six.with_metaclass(abc.ABCMeta, object)):
# class _CompiledSimpleMLModelResource(tracking.TrackableResource):
# class _DiskModelLoader(_AbstractModelLoader, tracking.AutoTrackable):
#   def __init__(self,
#                model_path: Text,
#                tensor_model_path: Optional[Tensor] = None,
#                verbose: Optional[bool] = True):
#   def init_op(self) -> InitOp:
#   def apply(self, features: Dict[Text, Tensor]) -> ModelOutput:
#   def __init__(self,
#                model_path: Text,
#                verbose: Optional[bool] = True,
#                output_types: Optional[List[str]] = []):
#   def apply_get_leaves(self, features: Dict[Text, Tensor]) -> Any:
#   def apply(self, features: Dict[Text, Tensor]) -> ModelOutput:
# def _create_model_identifier() -> Text:
#   def __init__(self, verbose: Optional[bool] = True):
#   def build_from_model_path(self, model_path: Text):
#   def build_from_dataspec_and_header(self,
#                                      dataspec: data_spec_pb2.DataSpecification,
#                                      header: abstract_model_pb2.AbstractModel):
#   def init_op(self) -> Tensor:
#   def build_inference_op_args(
#       self,
#       features: Dict[Text, Tensor],
#       output_leaves: Optional[bool] = False) -> Dict[Text, Any]:
#   def _register_input_feature(self, name: Text, value: Tensor,
#                               feature_maps: FeatureMaps) -> None:
#   def _create_str_to_int_tables(self):
#   def _dict_to_list_sorted_by_key(src: Dict[Any, Any]) -> List[Any]:
#   def _all_feature_idxs(feature_maps: FeatureMaps):
#   def _check_all_input_features_are_provided(self, feature_maps):
#   def _get_dense_output_dim(self):
#   def _prepare_and_check_numerical_feature(self, name: Text, value: Tensor):
#   def _prepare_and_check_boolean_feature(self, name: Text, value: Tensor):
#   def _prepare_and_check_categorical_feature(
#       self, name: Text, value: Tensor,
#       feature_spec: data_spec_pb2.Column) -> Tensor:
#   def _prepare_and_check_categorical_set_feature(
#       self, name: Text, value: Tensor,
#       feature_spec: data_spec_pb2.Column) -> Tensor:
#   def initialize(self, model: "_CompiledSimpleMLModelResource") -> tf.Operation:
#   def __init__(self, model_loader: _AbstractModelLoader):
#   def _create_resource(self):
#   def _initialize(self):
#   def __init__(self, model_path, output_types: List[str]):
#   def initialize(self, model: _CompiledSimpleMLModelResource) -> tf.Operation:
#   def get_model_path(self) -> Tensor:
# 
# Path: tensorflow_decision_forests/tensorflow/ops/inference/test_utils.py
# def build_toy_data_spec(add_boolean_features=False, has_catset=False):
# def build_toy_random_forest(path,
#                             winner_take_all_inference,
#                             add_boolean_features=False,
#                             has_catset=False,
#                             num_trees=2):
# def build_toy_gbdt(path, num_classes):
# def build_toy_input_features(use_rank_two=False, has_catset=False):
# def build_toy_input_feature_values(features,
#                                    use_rank_two=False,
#                                    has_catset=False):
#   def shape(x):
#       def __getitem__(self, key):
# def expected_toy_predictions_rf_weighted(add_boolean_features=False):
# def expected_toy_predictions_rf_wta(add_boolean_features=False,
#                                     has_catset=False):
# def expected_toy_predictions_gbdt_binary():
# def expected_toy_predictions_gbdt_multiclass():
#     class Identity:


# Path: tensorflow_decision_forests/tensorflow/ops/inference/tf1_test.py
import os
import tempfile
import tensorflow.compat.v1 as tf
from tensorflow_decision_forests.tensorflow.ops.inference import api as inference
from tensorflow_decision_forests.tensorflow.ops.inference import test_utils
from absl.testing import parameterized
from absl import flags
from absl import logging

from __future__ import print_function





def data_root_path() -> str:
  return ""


def test_data_path() -> str:
  return os.path.join(data_root_path(),
                      "external/ydf/yggdrasil_decision_forests/test_data")


class TfOpTest(parameterized.TestCase, tf.test.TestCase):

  @parameterized.named_parameters(
      ("base", False, False),
      ("boolean", True, False),
      ("catset", False, True),
  )
  def test_toy_rf_classification_winner_takes_all(self, add_boolean_features,
                                                  has_catset):

    with tf.Graph().as_default():

      # Create toy model.
      model_path = os.path.join(
          tempfile.mkdtemp(dir=self.get_temp_dir()), "test_basic_rf_wta")

      test_utils.build_toy_random_forest(