docstr: Computes the leaf index for one tree.
docstr_tok: ["Computes","the","leaf","index","for","one","tree","."]
code: def leaf_index_tree(self, X: np.ndarray, tree_id: int) -> int:
      """Computes the leaf index for one tree."""
      index = self.root_index[tree_id]
      while self.atts.nodes_modes[index] != "LEAF":  # type: ignore
          x = X[self.atts.nodes_featureids[index]]  # type: ignore
          if np.isnan(x):
              r = self.atts.nodes_missing_value_tracks_true[index] >= 1  # type: ignore
          else:
              rule = self.atts.nodes_modes[index]  # type: ignore
              th = self.atts.nodes_values[index]  # type: ignore
              if rule == "BRANCH_LEQ":
                  r = x <= th
              elif rule == "BRANCH_LT":
                  r = x < th
              elif rule == "BRANCH_GTE":
                  r = x >= th
              elif rule == "BRANCH_GT":
                  r = x > th
              elif rule == "BRANCH_EQ":
                  r = x == th
              elif rule == "BRANCH_NEQ":
                  r = x != th
              else:
                  raise ValueError(
                      f"Unexpected rule {rule!r} for node index {index}."
                  )
          nid = (
              self.atts.nodes_truenodeids[index]  # type: ignore
              if r
              else self.atts.nodes_falsenodeids[index]  # type: ignore
          )
          index = self.node_index[tree_id, nid]
      return index
  
file_path: onnx/onnx/reference/ops/aionnxml/op_tree_ensemble_helper.py
imports: import numpy
label_desc: Use image node_id 3 for calling the TreeEnsemble obj's underlying member method code with example usage: obj.leaf_index_tree(X, tree_id) and returns: index