docstr: Computes three types of derivative based measures:
  the gradient, the gradient square and the gradient absolute measures.
  
  Args:
      model: A BoTorch model.
      bounds: Parameter bounds over which to evaluate model sensitivity.
      num_gp_samples: If method is "GP samples", the number of GP samples has
          to be set.
      derivative_gp: If true, the derivative of the GP is used to compute the
          gradient instead of backward.
      kernel_type: Takes "rbf" or "matern", set only if `derivative_gp` is true.
      Y_scale: Scale the derivatives by this amount, to undo scaling done on
          the training data.
      num_mc_samples: The number of Monte Carlo grid samples.
      input_qmc: If True, a qmc Sobol grid is used instead of uniformly random.
      gp_sample_qmc: If True, the posterior sampling is done using
          `SobolQMCNormalSampler`.
      dtype: Can be provided if the GP is fit to data of type `torch.float`.
      num_bootstrap_samples: If higher than 1, the method will compute the
          dgsm measure `num_bootstrap_samples` times by selecting subsamples
          from the `input_mc_samples` and return the variance and standard error
          across all computed measures.
  
  Returns values of gradient_measure, gradient_absolute_measure and
  gradients_square_measure change to the following:
      if `num_bootstrap_samples > 1`:
          Tensor: (values, var_gp, stderr_gp, var_mc, stderr_mc) x dim
      else
          Tensor: (values, var_gp, stderr_gp) x dim
docstr_tok: ["Computes","three","types","of","derivative","based","measures",":","the","gradient",",","the","gradient","square","and","the","gradient","absolute","measures",".","Args",":","model",":","A","BoTorch","model",".","bounds",":","Parameter","bounds","over","which","to","evaluate","model","sensitivity",".","num_gp_samples",":","If","method","is","``","GP","samples","''",",","the","number","of","GP","samples","has","to","be","set",".","derivative_gp",":","If","true",",","the","derivative","of","the","GP","is","used","to","compute","the","gradient","instead","of","backward",".","kernel_type",":","Takes","``","rbf","''","or","``","matern","''",",","set","only","if","`","derivative_gp","`","is","true",".","Y_scale",":","Scale","the","derivatives","by","this","amount",",","to","undo","scaling","done","on","the","training","data",".","num_mc_samples",":","The","number","of","Monte","Carlo","grid","samples",".","input_qmc",":","If","True",",","a","qmc","Sobol","grid","is","used","instead","of","uniformly","random",".","gp_sample_qmc",":","If","True",",","the","posterior","sampling","is","done","using","`","SobolQMCNormalSampler","`",".","dtype",":","Can","be","provided","if","the","GP","is","fit","to","data","of","type","`","torch.float","`",".","num_bootstrap_samples",":","If","higher","than","1",",","the","method","will","compute","the","dgsm","measure","`","num_bootstrap_samples","`","times","by","selecting","subsamples","from","the","`","input_mc_samples","`","and","return","the","variance","and","standard","error","across","all","computed","measures",".","Returns","values","of","gradient_measure",",","gradient_absolute_measure","and","gradients_square_measure","change","to","the","following",":","if","`","num_bootstrap_samples",">","1","`",":","Tensor",":","(","values",",","var_gp",",","stderr_gp",",","var_mc",",","stderr_mc",")","x","dim","else","Tensor",":","(","values",",","var_gp",",","stderr_gp",")","x","dim"]
code: def __init__(
      self,
      model: Model,
      bounds: torch.Tensor,
      num_gp_samples: int,
      derivative_gp: bool = False,
      kernel_type: Optional[str] = None,
      Y_scale: float = 1.0,
      num_mc_samples: int = 10**4,
      input_qmc: bool = False,
      gp_sample_qmc: bool = False,
      dtype: torch.dtype = torch.double,
      num_bootstrap_samples: int = 1,
  ) -> None:
      r"""Computes three types of derivative based measures:
      the gradient, the gradient square and the gradient absolute measures.
  
      Args:
          model: A BoTorch model.
          bounds: Parameter bounds over which to evaluate model sensitivity.
          num_gp_samples: If method is "GP samples", the number of GP samples has
              to be set.
          derivative_gp: If true, the derivative of the GP is used to compute the
              gradient instead of backward.
          kernel_type: Takes "rbf" or "matern", set only if `derivative_gp` is true.
          Y_scale: Scale the derivatives by this amount, to undo scaling done on
              the training data.
          num_mc_samples: The number of Monte Carlo grid samples.
          input_qmc: If True, a qmc Sobol grid is used instead of uniformly random.
          gp_sample_qmc: If True, the posterior sampling is done using
              `SobolQMCNormalSampler`.
          dtype: Can be provided if the GP is fit to data of type `torch.float`.
          num_bootstrap_samples: If higher than 1, the method will compute the
              dgsm measure `num_bootstrap_samples` times by selecting subsamples
              from the `input_mc_samples` and return the variance and standard error
              across all computed measures.
  
      Returns values of gradient_measure, gradient_absolute_measure and
      gradients_square_measure change to the following:
          if `num_bootstrap_samples > 1`:
              Tensor: (values, var_gp, stderr_gp, var_mc, stderr_mc) x dim
          else
              Tensor: (values, var_gp, stderr_gp) x dim
      """
      self.num_gp_samples = num_gp_samples
      self.gp_sample_qmc = gp_sample_qmc
      self.num_mc_samples = num_mc_samples
      super().__init__(
          model=model,
          bounds=bounds,
          derivative_gp=derivative_gp,
          kernel_type=kernel_type,
          Y_scale=Y_scale,
          num_mc_samples=num_mc_samples,
          input_qmc=input_qmc,
          dtype=dtype,
          num_bootstrap_samples=num_bootstrap_samples,
      )
  
imports: from copy import deepcopy
  from typing import Callable, List, Optional, Union
  import torch
  from ax.utils.common.typeutils import checked_cast, not_none
  from ax.utils.sensitivity.derivative_gp import posterior_derivative
  from botorch.models.model import Model
  from botorch.posteriors.gpytorch import GPyTorchPosterior
  from botorch.posteriors.posterior import Posterior
  from botorch.sampling.normal import SobolQMCNormalSampler
  from botorch.utils.sampling import draw_sobol_samples
  from botorch.utils.transforms import unnormalize
  from gpytorch.distributions import MultivariateNormal
label_desc: Use image node_id 1 to create a new GpDGSMGpSampling object from inherited base classes: GpDGSMGpMean with example: obj = GpDGSMGpSampling(model, bounds, num_gp_samples, derivative_gp, kernel_type, Y_scale, num_mc_samples, input_qmc, gp_sample_qmc, dtype, num_bootstrap_samples)