code: def generate_negative_samples(x, sample_type, proportion, epsilon):
      n_samples = int(proportion * (len(x)))
      n_dim = x.shape[-1]
  
      # uniform samples in range [x.min(),x.max()]
      rand_unif = x.min() + (x.max() - x.min()) * np.random.rand(
          n_samples, n_dim
      ).astype("float32")
      # subspace perturbation samples
      x_temp = x[np.random.choice(np.arange(len(x)), size=n_samples)]
      randmat = np.random.rand(n_samples, n_dim) < 0.3
      rand_sub = x_temp + randmat * (
          epsilon * np.random.randn(n_samples, n_dim)
      ).astype("float32")
  
      if sample_type == "UNIFORM":
          neg_x = rand_unif
      if sample_type == "SUBSPACE":
          neg_x = rand_sub
      if sample_type == "MIXED":
          # randomly sample from uniform and gaussian negative samples
          neg_x = np.concatenate((rand_unif, rand_sub), 0)
          neg_x = neg_x[
              np.random.choice(np.arange(len(neg_x)), size=n_samples)
          ]
  
      neg_y = np.ones(len(neg_x))
  
      return neg_x.astype("float32"), neg_y.astype("float32")
  
imports: from copy import deepcopy
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from sklearn.metrics import roc_auc_score
  from sklearn.model_selection import train_test_split
  from sklearn.neighbors import NearestNeighbors
  from sklearn.preprocessing import MinMaxScaler
  from sklearn.utils.validation import check_is_fitted
  from .base import BaseDetector
label_desc: Use image node_id 1 for calling a global function with example usage: generate_negative_samples(x, sample_type, proportion, epsilon) and returns: neg_x,  neg_y