class_docstr: Fast generalized subset scan based detector by McFowland, E., Speakman, S., and Neill, D. B. (2013).
  
  | Paper link: https://www.cs.cmu.edu/~neill/papers/mcfowland13a.pdf
class_docstr_tok: ["Fast","generalized","subset","scan","based","detector","by","McFowland",",","E.",",","Speakman",",","S.",",","and","Neill",",","D.","B",".","(","2013",")",".","|","Paper","link",":","https",":","\/\/www.cs.cmu.edu\/~neill\/papers\/mcfowland13a.pdf"]
docstr: Returns computed p-value ranges.
  
  :param x: Data being evaluated for anomalies.
  :return: p-value ranges.
docstr_tok: ["Returns","computed","p-value","ranges",".",":","param","x",":","Data","being","evaluated","for","anomalies",".",":","return",":","p-value","ranges","."]
code: def _calculate_pvalue_ranges(
      self, x: np.ndarray, batch_size: int = 128
  ) -> np.ndarray:
      """
      Returns computed p-value ranges.
  
      :param x: Data being evaluated for anomalies.
      :return: p-value ranges.
      """
      bgd_activations = self.sorted_bgd_activations
      eval_activations = self._get_activations(
          x, self._layer_name, batch_size
      )
  
      if len(eval_activations.shape) == 4:
          dim2 = (
              eval_activations.shape[1]
              * eval_activations.shape[2]
              * eval_activations.shape[3]
          )
          eval_activations = np.reshape(
              eval_activations, (eval_activations.shape[0], dim2)
          )
  
      bgrecords_n = bgd_activations.shape[0]
      records_n = eval_activations.shape[0]
      atrr_n = eval_activations.shape[1]
  
      pvalue_ranges = np.empty((records_n, atrr_n, 2))
  
      for j in range(atrr_n):
          pvalue_ranges[:, j, 0] = np.searchsorted(
              bgd_activations[:, j],
              eval_activations[:, j],
              side="right",
          )
          pvalue_ranges[:, j, 1] = np.searchsorted(
              bgd_activations[:, j], eval_activations[:, j], side="left"
          )
  
      pvalue_ranges = bgrecords_n - pvalue_ranges
  
      pvalue_ranges[:, :, 0] = np.divide(
          pvalue_ranges[:, :, 0], bgrecords_n + 1
      )
      pvalue_ranges[:, :, 1] = np.divide(
          pvalue_ranges[:, :, 1] + 1, bgrecords_n + 1
      )
  
      return pvalue_ranges
  
file_path: adversarial-robustness-toolbox/art/defences/detector/evasion/subsetscanning/detector.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import sys
  from typing import Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from sklearn import metrics
  from tqdm.auto import trange, tqdm
  from art.defences.detector.evasion.evasion_detector import EvasionDetector
  from art.defences.detector.evasion.subsetscanning.scanner import Scanner
  from art.defences.detector.evasion.subsetscanning.scoring_functions import ScoringFunctions
label_desc: Use image node_id 3 for calling the SubsetScanningDetector obj's underlying member method code with example usage: obj._calculate_pvalue_ranges(x, batch_size) and returns: pvalue_ranges