class_docstr: Class implementing the Tree Traversal strategy in PyTorch for tree-base models.
docstr: Args:
      tree_parameters: The parameters defining the tree structure
      max_depth: The maximum tree-depth in the model
      n_features: The number of features input to the model
      classes: The classes used for classification. None if implementing a regression model
      n_classes: The total number of used classes
      extra_config: Extra configuration used to properly implement the source tree
docstr_tok: ["Args",":","tree_parameters",":","The","parameters","defining","the","tree","structure","max_depth",":","The","maximum","tree-depth","in","the","model","n_features",":","The","number","of","features","input","to","the","model","classes",":","The","classes","used","for","classification",".","None","if","implementing","a","regression","model","n_classes",":","The","total","number","of","used","classes","extra_config",":","Extra","configuration","used","to","properly","implement","the","source","tree"]
code: def __init__(
      self,
      logical_operator,
      tree_parameters,
      max_depth,
      n_features,
      classes,
      n_classes=None,
      extra_config={},
      **kwargs,
  ):
      """
      Args:
          tree_parameters: The parameters defining the tree structure
          max_depth: The maximum tree-depth in the model
          n_features: The number of features input to the model
          classes: The classes used for classification. None if implementing a regression model
          n_classes: The total number of used classes
          extra_config: Extra configuration used to properly implement the source tree
      """
      # If n_classes is not provided we induce it from tree parameters. Multioutput regression targets are also treated as separate classes.
      n_classes = (
          n_classes
          if n_classes is not None
          else tree_parameters[0][6].shape[1]
      )
      super(TreeTraversalTreeImpl, self).__init__(
          logical_operator,
          tree_parameters,
          n_features,
          classes,
          n_classes,
          extra_config=extra_config,
          **kwargs,
      )
  
      # Initialize the actual model.
      self.n_features = n_features
      self.max_tree_depth = max_depth
      self.num_trees = len(tree_parameters)
      self.num_nodes = max(
          [len(tree_parameter[1]) for tree_parameter in tree_parameters]
      )
  
      lefts = np.zeros((self.num_trees, self.num_nodes), dtype=np.int64)
      rights = np.zeros(
          (self.num_trees, self.num_nodes), dtype=np.int64
      )
  
      features = np.zeros(
          (self.num_trees, self.num_nodes), dtype=np.int64
      )
      thresholds = np.zeros(
          (self.num_trees, self.num_nodes), dtype=np.float64
      )
      values = np.zeros(
          (self.num_trees, self.num_nodes, self.n_classes),
          dtype=np.float64,
      )
  
      for i in range(self.num_trees):
          lefts[i][: len(tree_parameters[i][0])] = tree_parameters[i][2]
          rights[i][: len(tree_parameters[i][0])] = tree_parameters[i][
              3
          ]
          features[i][: len(tree_parameters[i][0])] = tree_parameters[
              i
          ][4]
          thresholds[i][: len(tree_parameters[i][0])] = tree_parameters[
              i
          ][5]
          values[i][: len(tree_parameters[i][0])][:] = tree_parameters[
              i
          ][6]
  
      self.lefts = torch.nn.Parameter(
          torch.from_numpy(lefts).view(-1).detach().clone(),
          requires_grad=False,
      )
      self.rights = torch.nn.Parameter(
          torch.from_numpy(rights).view(-1).detach().clone(),
          requires_grad=False,
      )
  
      self.features = torch.nn.Parameter(
          torch.from_numpy(features).view(-1).detach().clone(),
          requires_grad=False,
      )
      self.thresholds = torch.nn.Parameter(
          torch.from_numpy(
              thresholds.astype(self.tree_op_precision_dtype)
          )
          .view(-1)
          .detach()
          .clone()
      )
      self.values = torch.nn.Parameter(
          torch.from_numpy(values.astype(self.tree_op_precision_dtype))
          .view(-1, self.n_classes)
          .detach()
          .clone()
      )
  
      nodes_offset = [
          [i * self.num_nodes for i in range(self.num_trees)]
      ]
      self.nodes_offset = torch.nn.Parameter(
          torch.LongTensor(nodes_offset), requires_grad=False
      )
  
imports: from abc import abstractmethod
  from enum import Enum
  import numpy
  import torch
  from .None import constants
  from ._physical_operator import PhysicalOperator
  from .None import _tree_commons
label_desc: Use image node_id 2 to create a new TreeTraversalTreeImpl object from inherited base classes: AbstractPyTorchTreeImpl with example: obj = TreeTraversalTreeImpl(logical_operator, tree_parameters, max_depth, n_features, classes, n_classes, extra_config)