class_docstr: Abstract class definig the basic structure for tree-base models implemented in PyTorch.
docstr: Args:
      tree_parameters: The parameters defining the tree structure
      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
      decision_cond: The condition of the decision nodes in the x <cond> threshold order. Default '<='. Values can be <=, <, >=, >
docstr_tok: ["Args",":","tree_parameters",":","The","parameters","defining","the","tree","structure","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","decision_cond",":","The","condition","of","the","decision","nodes","in","the","x","<","cond",">","threshold","order",".","Default","'","<","=","'",".","Values","can","be","<","=",",","<",",",">","=",",",">"]
code: def __init__(
      self,
      logical_operator,
      tree_parameters,
      n_features,
      classes,
      n_classes,
      decision_cond="<=",
      extra_config={},
      **kwargs,
  ):
      """
      Args:
          tree_parameters: The parameters defining the tree structure
          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
          decision_cond: The condition of the decision nodes in the x <cond> threshold order. Default '<='. Values can be <=, <, >=, >
      """
      super(AbstractPyTorchTreeImpl, self).__init__(
          logical_operator, **kwargs
      )
  
      # Set up the variables for the subclasses.
      # Each subclass will trigger different behaviours by properly setting these.
      self.perform_class_select = False
      self.binary_classification = False
      self.classes = classes
      self.base_prediction = None
      # Are we doing anomaly detection, regression or classification?
      if self.anomaly_detection:
          self.n_classes = 1  # so that we follow the regression pattern and later do manual class selection
          self.classes = torch.nn.Parameter(
              torch.IntTensor(classes), requires_grad=False
          )
      elif classes is None:
          self.regression = True
          self.n_classes = 1 if n_classes is None else n_classes
      else:
          self.classification = True
          self.n_classes = (
              len(classes) if n_classes is None else n_classes
          )
          if min(classes) != 0 or max(classes) != len(classes) - 1:
              self.classes = torch.nn.Parameter(
                  torch.IntTensor(classes), requires_grad=False
              )
              self.perform_class_select = True
  
      # Set the decision condition.
      decision_cond_map = {
          "<=": torch.le,
          "<": torch.lt,
          ">=": torch.ge,
          ">": torch.gt,
          "=": torch.eq,
          "!=": torch.ne,
      }
      assert (
          decision_cond in decision_cond_map.keys()
      ), "decision_cond has to be one of:{}".format(
          ",".join(decision_cond_map.keys())
      )
      self.decision_cond = decision_cond_map[decision_cond]
  
      # In some cases float64 is required oterwise we will lose precision.
      tree_op_precision_dtype = None
      if constants.TREE_OP_PRECISION_DTYPE in extra_config:
          tree_op_precision_dtype = extra_config[
              constants.TREE_OP_PRECISION_DTYPE
          ]
          assert tree_op_precision_dtype in [
              "float32",
              "float64",
          ], "{} has to be of type float32 or float64".format(
              constants.TREE_OP_PRECISION_DTYPE
          )
      else:
          tree_op_precision_dtype = "float32"
      self.tree_op_precision_dtype = tree_op_precision_dtype
  
      # We register also base_prediction here so that tensor will be moved to the proper hardware with the model.
      # i.e., if cuda is selected, the parameter will be automatically moved on the GPU.
      if constants.BASE_PREDICTION in extra_config:
          self.base_prediction = extra_config[constants.BASE_PREDICTION]
  
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 1 to create a new AbstractPyTorchTreeImpl object from inherited base classes: AbstracTreeImpl, torch.nn with example: obj = AbstractPyTorchTreeImpl(logical_operator, tree_parameters, n_features, classes, n_classes, decision_cond, extra_config)