docstr: Calculate expected gradients approximation of Shapley values for the 
  sample ``input_tensor``.
  
  Args:
      model (torch.nn.Module): Pytorch neural network model for which the
          output should be explained.
      input_tensor (torch.Tensor): Pytorch tensor representing the input
          to be explained.
      sparse_labels (optional, default=None): 
docstr_tok: ["Calculate","expected","gradients","approximation","of","Shapley","values","for","the","sample","``","input_tensor","``",".","Args",":","model","(","torch.nn.Module",")",":","Pytorch","neural","network","model","for","which","the","output","should","be","explained",".","input_tensor","(","torch.Tensor",")",":","Pytorch","tensor","representing","the","input","to","be","explained",".","sparse_labels","(","optional",",","default=None",")",":"]
code: def shap_values(self, model, input_tensor, sparse_labels=None):
      """
      Calculate expected gradients approximation of Shapley values for the
      sample ``input_tensor``.
  
      Args:
          model (torch.nn.Module): Pytorch neural network model for which the
              output should be explained.
          input_tensor (torch.Tensor): Pytorch tensor representing the input
              to be explained.
          sparse_labels (optional, default=None):
      """
      reference_tensor = self._get_ref_batch()
      shape = reference_tensor.shape
      reference_tensor = reference_tensor.view(
          self.batch_size, self.k, *(shape[1:])
      ).to(DEFAULT_DEVICE)
      samples_input = self._get_samples_input(
          input_tensor, reference_tensor
      )
      samples_delta = self._get_samples_delta(
          input_tensor, reference_tensor
      )
      grad_tensor = self._get_grads(samples_input, model, sparse_labels)
      mult_grads = (
          samples_delta * grad_tensor
          if self.scale_by_inputs
          else grad_tensor
      )
      expected_grads = mult_grads.mean(1)
      return expected_grads
  
imports: import functools
  import operator
  import torch
  from torch.autograd import grad
  from torch.utils.data import DataLoader
label_desc: Use image node_id 6 for calling the AttributionPriorExplainer obj's underlying member method code with example usage: obj.shap_values(model, input_tensor, sparse_labels) and returns: expected_grads