class_docstr: Deep Isolation Forest (DIF) is an extension of iForest. It uses deep
  representation ensemble to achieve non-linear isolation on original data
  space. See :cite:`xu2023dif` for details.
  
  Parameters
  ----------
  batch_size : int, optional (default=1000)
          Number of samples per gradient update.
  
  representation_dim, int, optional (default=20)
          Dimensionality of the representation space.
  
  hidden_neurons, list, optional (default=[64, 32])
          The number of neurons per hidden layers. So the network has the
          structure as [n_features, hidden_neurons[0], hidden_neurons[1], ..., representation_dim]
  
  hidden_activation, str, optional (default='tanh')
          Activation function to use for hidden layers.
          All hidden layers are forced to use the same type of activation.
          See https://pytorch.org/docs/stable/nn.html for details.
          Currently only
          'relu': nn.ReLU()
          'sigmoid': nn.Sigmoid()
          'tanh': nn.Tanh()
          are supported. See pyod/utils/torch_utility.py for details.
  
  skip_connection, boolean, optional (default=False)
          If True, apply skip-connection in the neural network structure.
  
  n_ensemble, int, optional (default=50)
          The number of deep representation ensemble members.
  
  n_estimators, int, optional (default=6)
          The number of isolation forest of each representation.
  
  max_samples, int, optional (default=256)
          The number of samples to draw from X to train each base isolation tree.
  
  contamination : float in (0., 0.5), optional (default=0.1)
          The amount of contamination of the data set,
          i.e. the proportion of outliers in the data set. Used when fitting to
          define the threshold on the decision function.
  
  random_state : int or None, optional (default=None)
          If int, random_state is the seed used by the random
          number generator;
          If None, the random number generator is the
          RandomState instance used by `np.random`.
  
  device, 'cuda', 'cpu', or None, optional (default=None)
          if 'cuda', use GPU acceleration in torch
          if 'cpu', use cpu in torch
          if None, automatically determine whether GPU is available
  
  
  Attributes
  ----------
  net_lst : list of torch.Module
          The list of representation neural networks.
  
  iForest_lst : list of iForest
          The list of instantiated iForest model.
  
  x_reduced_lst: list of numpy array
          The list of training data representations
  
  decision_scores_ : numpy array of shape (n_samples,)
          The outlier scores of the training data.
          The higher, the more abnormal. Outliers tend to have higher
          scores. This value is available once the detector is fitted.
  
  threshold_ : float
          The threshold is based on ``contamination``. It is the
          ``n_samples * contamination`` most abnormal samples in
          ``decision_scores_``. The threshold is calculated for generating
          binary outlier labels.
  
  labels_ : int, either 0 or 1
          The binary labels of the training data. 0 stands for inliers
          and 1 for outliers/anomalies. It is generated by applying
          ``threshold_`` on ``decision_scores_``.
class_docstr_tok: ["Deep","Isolation","Forest","(","DIF",")","is","an","extension","of","iForest",".","It","uses","deep","representation","ensemble","to","achieve","non-linear","isolation","on","original","data","space",".","See",":","cite",":","`","xu2023dif","`","for","details",".","Parameters","--","--","--","--","--","batch_size",":","int",",","optional","(","default=1000",")","Number","of","samples","per","gradient","update",".","representation_dim",",","int",",","optional","(","default=20",")","Dimensionality","of","the","representation","space",".","hidden_neurons",",","list",",","optional","(","default=","[","64",",","32","]",")","The","number","of","neurons","per","hidden","layers",".","So","the","network","has","the","structure","as","[","n_features",",","hidden_neurons","[","0","]",",","hidden_neurons","[","1","]",",","...",",","representation_dim","]","hidden_activation",",","str",",","optional","(","default='tanh","'",")","Activation","function","to","use","for","hidden","layers",".","All","hidden","layers","are","forced","to","use","the","same","type","of","activation",".","See","https",":","\/\/pytorch.org\/docs\/stable\/nn.html","for","details",".","Currently","only","'relu","'",":","nn.ReLU","(",")","'sigmoid","'",":","nn.Sigmoid","(",")","'tanh","'",":","nn.Tanh","(",")","are","supported",".","See","pyod\/utils\/torch_utility.py","for","details",".","skip_connection",",","boolean",",","optional","(","default=False",")","If","True",",","apply","skip-connection","in","the","neural","network","structure",".","n_ensemble",",","int",",","optional","(","default=50",")","The","number","of","deep","representation","ensemble","members",".","n_estimators",",","int",",","optional","(","default=6",")","The","number","of","isolation","forest","of","each","representation",".","max_samples",",","int",",","optional","(","default=256",")","The","number","of","samples","to","draw","from","X","to","train","each","base","isolation","tree",".","contamination",":","float","in","(","0.",",","0.5",")",",","optional","(","default=0.1",")","The","amount","of","contamination","of","the","data","set",",","i.e",".","the","proportion","of","outliers","in","the","data","set",".","Used","when","fitting","to","define","the","threshold","on","the","decision","function",".","random_state",":","int","or","None",",","optional","(","default=None",")","If","int",",","random_state","is","the","seed","used","by","the","random","number","generator",";","If","None",",","the","random","number","generator","is","the","RandomState","instance","used","by","`","np.random","`",".","device",",","'cuda","'",",","'cpu","'",",","or","None",",","optional","(","default=None",")","if","'cuda","'",",","use","GPU","acceleration","in","torch","if","'cpu","'",",","use","cpu","in","torch","if","None",",","automatically","determine","whether","GPU","is","available","Attributes","--","--","--","--","--","net_lst",":","list","of","torch.Module","The","list","of","representation","neural","networks",".","iForest_lst",":","list","of","iForest","The","list","of","instantiated","iForest","model",".","x_reduced_lst",":","list","of","numpy","array","The","list","of","training","data","representations","decision_scores_",":","numpy","array","of","shape","(","n_samples",",",")","The","outlier","scores","of","the","training","data",".","The","higher",",","the","more","abnormal",".","Outliers","tend","to","have","higher","scores",".","This","value","is","available","once","the","detector","is","fitted",".","threshold_",":","float","The","threshold","is","based","on","``","contamination","``",".","It","is","the","``","n_samples","*","contamination","``","most","abnormal","samples","in","``","decision_scores_","``",".","The","threshold","is","calculated","for","generating","binary","outlier","labels",".","labels_",":","int",",","either","0","or","1","The","binary","labels","of","the","training","data",".","0","stands","for","inliers","and","1","for","outliers\/anomalies",".","It","is","generated","by","applying","``","threshold_","``","on","``","decision_scores_","``","."]
code: def __init__(
      self,
      batch_size=1000,
      representation_dim=20,
      hidden_neurons=None,
      hidden_activation="tanh",
      skip_connection=False,
      n_ensemble=50,
      n_estimators=6,
      max_samples=256,
      contamination=0.1,
      random_state=None,
      device=None,
  ):
      super(DIF, self).__init__(contamination=contamination)
      self.batch_size = batch_size
      self.representation_dim = representation_dim
      self.hidden_activation = hidden_activation
      self.skip_connection = skip_connection
      self.hidden_neurons = hidden_neurons
  
      self.n_ensemble = n_ensemble
      self.n_estimators = n_estimators
      self.max_samples = max_samples
  
      self.random_state = random_state
      self.device = device
  
      self.minmax_scaler = None
  
      # create default calculation device (support GPU if available)
      if self.device is None:
          self.device = torch.device(
              "cuda:0" if torch.cuda.is_available() else "cpu"
          )
  
      # set random seed
      if self.random_state is not None:
          torch.manual_seed(self.random_state)
          torch.cuda.manual_seed(self.random_state)
          torch.cuda.manual_seed_all(self.random_state)
          np.random.seed(self.random_state)
  
      # default values for the amount of hidden neurons
      if self.hidden_neurons is None:
          self.hidden_neurons = [500, 100]
  
imports: from __future__ import division
  from __future__ import print_function
  import numpy
  import torch
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from sklearn.ensemble import IsolationForest
  from sklearn.preprocessing import StandardScaler, MinMaxScaler
  from torch.utils.data import DataLoader
  from .base import BaseDetector
  from ..utils.torch_utility import get_activation_by_name
label_desc: Use image node_id 1 to create a new DIF object from inherited base classes: BaseDetector with example: obj = DIF(batch_size, representation_dim, hidden_neurons, hidden_activation, skip_connection, n_ensemble, n_estimators, max_samples, contamination, random_state, device)