code: def create_outlier_batch(
      data: np.ndarray,
      target: np.ndarray,
      n_samples: int,
      perc_outlier: int,
  ) -> Union[Bunch, Tuple[np.ndarray, np.ndarray]]:
      """Create a batch with a defined percentage of outliers."""
  
      # create df
      data = pd.DataFrame(data=data)
      data["target"] = target
  
      # separate inlier and outlier data
      normal = data[data["target"] == 0]
      outlier = data[data["target"] == 1]
  
      if n_samples == 1:
          n_outlier = np.random.binomial(1, 0.01 * perc_outlier)
          n_normal = 1 - n_outlier
      else:
          n_outlier = int(perc_outlier * 0.01 * n_samples)
          n_normal = int((100 - perc_outlier) * 0.01 * n_samples)
  
      # draw samples
      batch_normal = sample_df(normal, n_normal)
      batch_outlier = sample_df(outlier, n_outlier)
  
      batch = pd.concat([batch_normal, batch_outlier])
      batch = batch.sample(frac=1).reset_index(drop=True)
  
      is_outlier = batch["target"].values
      batch.drop(columns=["target"], inplace=True)
  
      return Bunch(
          data=batch.values,
          target=is_outlier,
          target_names=["normal", "outlier"],
      )
  
file_path: alibi-detect/alibi_detect/utils/data.py
imports: import numpy
  import pandas
  from typing import Tuple, Union
label_desc: Use image node_id 2 for calling a global function with example usage: create_outlier_batch(data, target, n_samples, perc_outlier) and returns: Bunch