code: def _compute_gradient_quantities(
      self,
      posterior: Union[Posterior, MultivariateNormal],
      Y_scale: float,
  ) -> None:
      if self.gp_sample_qmc:
          sampler = SobolQMCNormalSampler(
              sample_shape=torch.Size([self.num_gp_samples]), seed=0
          )
          samples = sampler(posterior)
      else:
          samples = posterior.rsample(torch.Size([self.num_gp_samples]))
      if self.derivative_gp:
          self.samples_gradients = samples * Y_scale
      else:
          samples_gradients = []
          for j in range(self.num_gp_samples):
              torch.sum(samples[j]).backward(retain_graph=True)
              samples_gradients.append(
                  deepcopy(self.input_mc_samples.grad).unsqueeze(0)
              )
              self.input_mc_samples.grad.data.zero_()
          self.samples_gradients = (
              torch.cat(samples_gradients, dim=0) * Y_scale
          )
      if self.bootstrap:
          subset_size = 2
          self.bootstrap_indices = torch.randint(
              0,
              self.num_mc_samples,
              (self.num_bootstrap_samples, subset_size),
          )
          self.samples_gradients_btsp = []
          for j in range(self.num_gp_samples):
              not_none(self.samples_gradients_btsp).append(
                  torch.cat(
                      [
                          torch.index_select(
                              not_none(self.samples_gradients)[j],
                              0,
                              indices,
                          ).unsqueeze(0)
                          for indices in not_none(
                              self.bootstrap_indices
                          )
                      ],
                      dim=0,
                  )
              )
  
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 2 for calling the GpDGSMGpSampling obj's underlying member method code with example usage: obj._compute_gradient_quantities(posterior, Y_scale) without return types