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.
      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 MonteCarlo grid samples
      input_qmc: If True, a qmc Sobol grid is use instead of uniformly random.
      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.
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",".","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","MonteCarlo","grid","samples","input_qmc",":","If","True",",","a","qmc","Sobol","grid","is","use","instead","of","uniformly","random",".","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","."]
code: def __init__(
      self,
      model: Model,
      bounds: torch.Tensor,
      derivative_gp: bool = False,
      kernel_type: Optional[str] = None,
      Y_scale: float = 1.0,
      num_mc_samples: int = 10**4,
      input_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.
          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 MonteCarlo grid samples
          input_qmc: If True, a qmc Sobol grid is use instead of uniformly random.
          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.
      """
      # pyre-fixme[4]: Attribute must be annotated.
      self.dim = checked_cast(tuple, model.train_inputs)[0].shape[-1]
      self.derivative_gp = derivative_gp
      self.kernel_type = kernel_type
      # pyre-fixme[4]: Attribute must be annotated.
      self.bootstrap = num_bootstrap_samples > 1
      # pyre-fixme[4]: Attribute must be annotated.
      self.num_bootstrap_samples = (
          num_bootstrap_samples - 1
      )  # deduct 1 because the first is meant to be the full grid
      if self.derivative_gp and (self.kernel_type is None):
          raise ValueError(
              "Kernel type has to be specified to use derivative GP"
          )
      self.num_mc_samples = num_mc_samples
      if input_qmc:
          # pyre-fixme[4]: Attribute must be annotated.
          self.input_mc_samples = (
              draw_sobol_samples(bounds=bounds, n=num_mc_samples, q=1)
              .squeeze(1)
              .to(dtype)
          )
      else:
          self.input_mc_samples = unnormalize(
              torch.rand(num_mc_samples, self.dim, dtype=dtype),
              bounds=bounds,
          )
      if self.derivative_gp:
          posterior = posterior_derivative(
              model, self.input_mc_samples, not_none(self.kernel_type)
          )
      else:
          self.input_mc_samples.requires_grad = True
          posterior = checked_cast(
              GPyTorchPosterior, model.posterior(self.input_mc_samples)
          )
      self._compute_gradient_quantities(posterior, Y_scale)
  
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 GpDGSMGpMean object from inherited base classes: object with example: obj = GpDGSMGpMean(model, bounds, derivative_gp, kernel_type, Y_scale, num_mc_samples, input_qmc, dtype, num_bootstrap_samples)