class_docstr: Class implementing the Perfect Tree Traversal strategy in PyTorch for tree-base models.
code: def forward(self, x):
      prev_indices = (
          self.decision_cond(
              torch.index_select(x, 1, self.root_nodes),
              self.root_biases,
          )
      ).long()
      prev_indices = prev_indices + self.tree_indices
      prev_indices = prev_indices.view(-1)
  
      factor = 2
      for nodes, biases in zip(self.nodes, self.biases):
          gather_indices = torch.index_select(
              nodes, 0, prev_indices
          ).view(-1, self.num_trees)
          features = torch.gather(x, 1, gather_indices).view(-1)
          prev_indices = (
              factor * prev_indices
              + self.decision_cond(
                  features, torch.index_select(biases, 0, prev_indices)
              ).long()
          )
  
      output = torch.index_select(
          self.leaf_nodes, 0, prev_indices
      ).view(-1, self.num_trees, self.n_classes)
  
      output = self.aggregation(output)
  
      if self.regression:
          return output
  
      if self.anomaly_detection:
          # Select the class (-1 if negative) and return the score.
          return (
              torch.where(
                  output.view(-1) < 0, self.classes[0], self.classes[1]
              ),
              output,
          )
  
      if self.perform_class_select:
          return (
              torch.index_select(
                  self.classes, 0, torch.argmax(output, dim=1)
              ),
              output,
          )
      else:
          return torch.argmax(output, dim=1), output
  
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 3 for calling the PerfectTreeTraversalTreeImpl obj's underlying member method code with example usage: obj.forward(x) and returns: output, torch,  output, torch,  output, torch,  output