class_docstr: A perturbation based approach to compute attribution, based on the concept
  of Shapley Values from cooperative game theory. This method involves taking
  each permutation of the input features and adding them one-by-one to the
  given baseline. The output difference after adding each feature corresponds
  to its attribution, and these difference are averaged over all possible
  random permutations of the input features.
  
  By default, each scalar value within
  the input tensors are taken as a feature and added independently. Passing
  a feature mask, allows grouping features to be added together. This can
  be used in cases such as images, where an entire segment or region
  can be grouped together, measuring the importance of the segment
  (feature group). Each input scalar in the group will be given the same
  attribution value equal to the change in output as a result of adding back
  the entire feature group.
  
  More details regarding Shapley Values can be found in these papers:
  https://apps.dtic.mil/dtic/tr/fulltext/u2/604084.pdf
  https://www.sciencedirect.com/science/article/pii/S0305054808000804
  https://pdfs.semanticscholar.org/7715/bb1070691455d1fcfc6346ff458dbca77b2c.pdf
  
  NOTE: The method implemented here is very computationally intensive, and
  should only be used with a very small number of features (e.g. < 7).
  This implementation simply extends ShapleyValueSampling and
  evaluates all permutations, leading to a total of n * n! evaluations for n
  features. Shapley values can alternatively be computed with only 2^n
  evaluations, and we plan to add this approach in the future.
class_docstr_tok: ["A","perturbation","based","approach","to","compute","attribution",",","based","on","the","concept","of","Shapley","Values","from","cooperative","game","theory",".","This","method","involves","taking","each","permutation","of","the","input","features","and","adding","them","one-by-one","to","the","given","baseline",".","The","output","difference","after","adding","each","feature","corresponds","to","its","attribution",",","and","these","difference","are","averaged","over","all","possible","random","permutations","of","the","input","features",".","By","default",",","each","scalar","value","within","the","input","tensors","are","taken","as","a","feature","and","added","independently",".","Passing","a","feature","mask",",","allows","grouping","features","to","be","added","together",".","This","can","be","used","in","cases","such","as","images",",","where","an","entire","segment","or","region","can","be","grouped","together",",","measuring","the","importance","of","the","segment","(","feature","group",")",".","Each","input","scalar","in","the","group","will","be","given","the","same","attribution","value","equal","to","the","change","in","output","as","a","result","of","adding","back","the","entire","feature","group",".","More","details","regarding","Shapley","Values","can","be","found","in","these","papers",":","https",":","\/\/apps.dtic.mil\/dtic\/tr\/fulltext\/u2\/604084.pdf","https",":","\/\/www.sciencedirect.com\/science\/article\/pii\/S0305054808000804","https",":","\/\/pdfs.semanticscholar.org\/7715\/bb1070691455d1fcfc6346ff458dbca77b2c.pdf","NOTE",":","The","method","implemented","here","is","very","computationally","intensive",",","and","should","only","be","used","with","a","very","small","number","of","features","(","e.g",".","<","7",")",".","This","implementation","simply","extends","ShapleyValueSampling","and","evaluates","all","permutations",",","leading","to","a","total","of","n","*","n","!","evaluations","for","n","features",".","Shapley","values","can","alternatively","be","computed","with","only","2^n","evaluations",",","and","we","plan","to","add","this","approach","in","the","future","."]
docstr: NOTE: The feature_mask argument differs from other perturbation based
  methods, since feature indices can overlap across tensors. See the
  description of the feature_mask argument below for more details.
  
  Args:
  
          inputs (Tensor or tuple[Tensor, ...]): Input for which Shapley value
                      sampling attributions are computed. If forward_func takes
                      a single tensor as input, a single input tensor should
                      be provided.
                      If forward_func takes multiple tensors as input, a tuple
                      of the input tensors should be provided. It is assumed
                      that for all given input tensors, dimension 0 corresponds
                      to the number of examples (aka batch size), and if
                      multiple input tensors are provided, the examples must
                      be aligned appropriately.
          baselines (scalar, Tensor, tuple of scalar, or Tensor, optional):
                      Baselines define reference value which replaces each
                      feature when ablated.
                      Baselines can be provided as:
  
                      - a single tensor, if inputs is a single tensor, with
                        exactly the same dimensions as inputs or the first
                        dimension is one and the remaining dimensions match
                        with inputs.
  
                      - a single scalar, if inputs is a single tensor, which will
                        be broadcasted for each input value in input tensor.
  
                      - a tuple of tensors or scalars, the baseline corresponding
                        to each tensor in the inputs' tuple can be:
  
                        - either a tensor with matching dimensions to
                          corresponding tensor in the inputs' tuple
                          or the first dimension is one and the remaining
                          dimensions match with the corresponding
                          input tensor.
  
                        - or a scalar, corresponding to a tensor in the
                          inputs' tuple. This scalar value is broadcasted
                          for corresponding input tensor.
  
                      In the cases when `baselines` is not provided, we internally
                      use zero scalar corresponding to each input tensor.
                      Default: None
          target (int, tuple, Tensor, or list, optional): Output indices for
                      which difference is computed (for classification cases,
                      this is usually the target class).
                      If the network returns a scalar value per example,
                      no target index is necessary.
                      For general 2D outputs, targets can be either:
  
                      - a single integer or a tensor containing a single
                        integer, which is applied to all input examples
  
                      - a list of integers or a 1D tensor, with length matching
                        the number of examples in inputs (dim 0). Each integer
                        is applied as the target for the corresponding example.
  
                      For outputs with > 2 dimensions, targets can be either:
  
                      - A single tuple, which contains #output_dims - 1
                        elements. This target index is applied to all examples.
  
                      - A list of tuples with length equal to the number of
                        examples in inputs (dim 0), and each tuple containing
                        #output_dims - 1 elements. Each tuple is applied as the
                        target for the corresponding example.
  
                      Default: None
          additional_forward_args (Any, optional): If the forward function
                      requires additional arguments other than the inputs for
                      which attributions should not be computed, this argument
                      can be provided. It must be either a single additional
                      argument of a Tensor or arbitrary (non-tuple) type or a
                      tuple containing multiple additional arguments including
                      tensors or any arbitrary python types. These arguments
                      are provided to forward_func in order following the
                      arguments in inputs.
                      For a tensor, the first dimension of the tensor must
                      correspond to the number of examples. For all other types,
                      the given argument is used for all forward evaluations.
                      Note that attributions are not computed with respect
                      to these arguments.
                      Default: None
          feature_mask (Tensor or tuple[Tensor, ...], optional):
                      feature_mask defines a mask for the input, grouping
                      features which should be added together. feature_mask
                      should contain the same number of tensors as inputs.
                      Each tensor should
                      be the same size as the corresponding input or
                      broadcastable to match the input tensor. Values across
                      all tensors should be integers in the range 0 to
                      num_features - 1, and indices corresponding to the same
                      feature should have the same value.
                      Note that features are grouped across tensors
                      (unlike feature ablation and occlusion), so
                      if the same index is used in different tensors, those
                      features are still grouped and added simultaneously.
                      If the forward function returns a single scalar per batch,
                      we enforce that the first dimension of each mask must be 1,
                      since attributions are returned batch-wise rather than per
                      example, so the attributions must correspond to the
                      same features (indices) in each input example.
                      If None, then a feature mask is constructed which assigns
                      each scalar within a tensor as a separate feature
                      Default: None
          perturbations_per_eval (int, optional): Allows multiple ablations
                      to be processed simultaneously in one call to forward_fn.
                      Each forward pass will contain a maximum of
                      perturbations_per_eval * #examples samples.
                      For DataParallel models, each batch is split among the
                      available devices, so evaluations on each available
                      device contain at most
                      (perturbations_per_eval * #examples) / num_devices
                      samples.
                      If the forward function returns a single scalar per batch,
                      perturbations_per_eval must be set to 1.
                      Default: 1
          show_progress (bool, optional): Displays the progress of computation.
                      It will try to use tqdm if available for advanced features
                      (e.g. time estimation). Otherwise, it will fallback to
                      a simple output of progress.
                      Default: False
  Returns:
          *Tensor* or *tuple[Tensor, ...]* of **attributions**:
          - **attributions** (*Tensor* or *tuple[Tensor, ...]*):
                      The attributions with respect to each input feature.
                      If the forward function returns
                      a scalar value per example, attributions will be
                      the same size as the provided inputs, with each value
                      providing the attribution of the corresponding input index.
                      If the forward function returns a scalar per batch, then
                      attribution tensor(s) will have first dimension 1 and
                      the remaining dimensions will match the input.
                      If a single tensor is provided as inputs, a single tensor is
                      returned. If a tuple is provided for inputs, a tuple of
                      corresponding sized tensors is returned.
  
  
  Examples::
  
      >>> # SimpleClassifier takes a single input tensor of size Nx4x4,
      >>> # and returns an Nx3 tensor of class probabilities.
      >>> net = SimpleClassifier()
      >>> # Generating random input with size 2 x 4 x 4
      >>> input = torch.randn(2, 4, 4)
  
      >>> # We may want to add features in groups, e.g.
      >>> # grouping each 2x2 square of the inputs and adding them together.
      >>> # This can be done by creating a feature mask as follows, which
      >>> # defines the feature groups, e.g.:
      >>> # +---+---+---+---+
      >>> # | 0 | 0 | 1 | 1 |
      >>> # +---+---+---+---+
      >>> # | 0 | 0 | 1 | 1 |
      >>> # +---+---+---+---+
      >>> # | 2 | 2 | 3 | 3 |
      >>> # +---+---+---+---+
      >>> # | 2 | 2 | 3 | 3 |
      >>> # +---+---+---+---+
      >>> # With this mask, all inputs with the same value are added
      >>> # together, and the attribution for each input in the same
      >>> # group (0, 1, 2, and 3) per example are the same.
      >>> # The attributions can be calculated as follows:
      >>> # feature mask has dimensions 1 x 4 x 4
      >>> feature_mask = torch.tensor([[[0,0,1,1],[0,0,1,1],
      >>>                             [2,2,3,3],[2,2,3,3]]])
  
      >>> # With only 4 features, it is feasible to compute exact
      >>> # Shapley Values. These can be computed as follows:
      >>> sv = ShapleyValues(net)
      >>> attr = sv.attribute(input, target=1, feature_mask=feature_mask)
docstr_tok: ["NOTE",":","The","feature_mask","argument","differs","from","other","perturbation","based","methods",",","since","feature","indices","can","overlap","across","tensors",".","See","the","description","of","the","feature_mask","argument","below","for","more","details",".","Args",":","inputs","(","Tensor","or","tuple","[","Tensor",",","...","]",")",":","Input","for","which","Shapley","value","sampling","attributions","are","computed",".","If","forward_func","takes","a","single","tensor","as","input",",","a","single","input","tensor","should","be","provided",".","If","forward_func","takes","multiple","tensors","as","input",",","a","tuple","of","the","input","tensors","should","be","provided",".","It","is","assumed","that","for","all","given","input","tensors",",","dimension","0","corresponds","to","the","number","of","examples","(","aka","batch","size",")",",","and","if","multiple","input","tensors","are","provided",",","the","examples","must","be","aligned","appropriately",".","baselines","(","scalar",",","Tensor",",","tuple","of","scalar",",","or","Tensor",",","optional",")",":","Baselines","define","reference","value","which","replaces","each","feature","when","ablated",".","Baselines","can","be","provided","as",":","-","a","single","tensor",",","if","inputs","is","a","single","tensor",",","with","exactly","the","same","dimensions","as","inputs","or","the","first","dimension","is","one","and","the","remaining","dimensions","match","with","inputs",".","-","a","single","scalar",",","if","inputs","is","a","single","tensor",",","which","will","be","broadcasted","for","each","input","value","in","input","tensor",".","-","a","tuple","of","tensors","or","scalars",",","the","baseline","corresponding","to","each","tensor","in","the","inputs","'","tuple","can","be",":","-","either","a","tensor","with","matching","dimensions","to","corresponding","tensor","in","the","inputs","'","tuple","or","the","first","dimension","is","one","and","the","remaining","dimensions","match","with","the","corresponding","input","tensor",".","-","or","a","scalar",",","corresponding","to","a","tensor","in","the","inputs","'","tuple",".","This","scalar","value","is","broadcasted","for","corresponding","input","tensor",".","In","the","cases","when","`","baselines","`","is","not","provided",",","we","internally","use","zero","scalar","corresponding","to","each","input","tensor",".","Default",":","None","target","(","int",",","tuple",",","Tensor",",","or","list",",","optional",")",":","Output","indices","for","which","difference","is","computed","(","for","classification","cases",",","this","is","usually","the","target","class",")",".","If","the","network","returns","a","scalar","value","per","example",",","no","target","index","is","necessary",".","For","general","2D","outputs",",","targets","can","be","either",":","-","a","single","integer","or","a","tensor","containing","a","single","integer",",","which","is","applied","to","all","input","examples","-","a","list","of","integers","or","a","1D","tensor",",","with","length","matching","the","number","of","examples","in","inputs","(","dim","0",")",".","Each","integer","is","applied","as","the","target","for","the","corresponding","example",".","For","outputs","with",">","2","dimensions",",","targets","can","be","either",":","-","A","single","tuple",",","which","contains","#","output_dims","-","1","elements",".","This","target","index","is","applied","to","all","examples",".","-","A","list","of","tuples","with","length","equal","to","the","number","of","examples","in","inputs","(","dim","0",")",",","and","each","tuple","containing","#","output_dims","-","1","elements",".","Each","tuple","is","applied","as","the","target","for","the","corresponding","example",".","Default",":","None","additional_forward_args","(","Any",",","optional",")",":","If","the","forward","function","requires","additional","arguments","other","than","the","inputs","for","which","attributions","should","not","be","computed",",","this","argument","can","be","provided",".","It","must","be","either","a","single","additional","argument","of","a","Tensor","or","arbitrary","(","non-tuple",")","type","or","a","tuple","containing","multiple","additional","arguments","including","tensors","or","any","arbitrary","python","types",".","These","arguments","are","provided","to","forward_func","in","order","following","the","arguments","in","inputs",".","For","a","tensor",",","the","first","dimension","of","the","tensor","must","correspond","to","the","number","of","examples",".","For","all","other","types",",","the","given","argument","is","used","for","all","forward","evaluations",".","Note","that","attributions","are","not","computed","with","respect","to","these","arguments",".","Default",":","None","feature_mask","(","Tensor","or","tuple","[","Tensor",",","...","]",",","optional",")",":","feature_mask","defines","a","mask","for","the","input",",","grouping","features","which","should","be","added","together",".","feature_mask","should","contain","the","same","number","of","tensors","as","inputs",".","Each","tensor","should","be","the","same","size","as","the","corresponding","input","or","broadcastable","to","match","the","input","tensor",".","Values","across","all","tensors","should","be","integers","in","the","range","0","to","num_features","-","1",",","and","indices","corresponding","to","the","same","feature","should","have","the","same","value",".","Note","that","features","are","grouped","across","tensors","(","unlike","feature","ablation","and","occlusion",")",",","so","if","the","same","index","is","used","in","different","tensors",",","those","features","are","still","grouped","and","added","simultaneously",".","If","the","forward","function","returns","a","single","scalar","per","batch",",","we","enforce","that","the","first","dimension","of","each","mask","must","be","1",",","since","attributions","are","returned","batch-wise","rather","than","per","example",",","so","the","attributions","must","correspond","to","the","same","features","(","indices",")","in","each","input","example",".","If","None",",","then","a","feature","mask","is","constructed","which","assigns","each","scalar","within","a","tensor","as","a","separate","feature","Default",":","None","perturbations_per_eval","(","int",",","optional",")",":","Allows","multiple","ablations","to","be","processed","simultaneously","in","one","call","to","forward_fn",".","Each","forward","pass","will","contain","a","maximum","of","perturbations_per_eval","*","#","examples","samples",".","For","DataParallel","models",",","each","batch","is","split","among","the","available","devices",",","so","evaluations","on","each","available","device","contain","at","most","(","perturbations_per_eval","*","#","examples",")","\/","num_devices","samples",".","If","the","forward","function","returns","a","single","scalar","per","batch",",","perturbations_per_eval","must","be","set","to","1",".","Default",":","1","show_progress","(","bool",",","optional",")",":","Displays","the","progress","of","computation",".","It","will","try","to","use","tqdm","if","available","for","advanced","features","(","e.g",".","time","estimation",")",".","Otherwise",",","it","will","fallback","to","a","simple","output","of","progress",".","Default",":","False","Returns",":","*","Tensor","*","or","*","tuple","[","Tensor",",","...","]","*","of","*","*","attributions","*","*",":","-","*","*","attributions","*","*","(","*","Tensor","*","or","*","tuple","[","Tensor",",","...","]","*",")",":","The","attributions","with","respect","to","each","input","feature",".","If","the","forward","function","returns","a","scalar","value","per","example",",","attributions","will","be","the","same","size","as","the","provided","inputs",",","with","each","value","providing","the","attribution","of","the","corresponding","input","index",".","If","the","forward","function","returns","a","scalar","per","batch",",","then","attribution","tensor","(","s",")","will","have","first","dimension","1","and","the","remaining","dimensions","will","match","the","input",".","If","a","single","tensor","is","provided","as","inputs",",","a","single","tensor","is","returned",".","If","a","tuple","is","provided","for","inputs",",","a","tuple","of","corresponding","sized","tensors","is","returned",".","Examples",":",":",">",">",">","#","SimpleClassifier","takes","a","single","input","tensor","of","size","Nx4x4",",",">",">",">","#","and","returns","an","Nx3","tensor","of","class","probabilities",".",">",">",">","net","=","SimpleClassifier","(",")",">",">",">","#","Generating","random","input","with","size","2","x","4","x","4",">",">",">","input","=","torch.randn","(","2",",","4",",","4",")",">",">",">","#","We","may","want","to","add","features","in","groups",",","e.g",".",">",">",">","#","grouping","each","2x2","square","of","the","inputs","and","adding","them","together",".",">",">",">","#","This","can","be","done","by","creating","a","feature","mask","as","follows",",","which",">",">",">","#","defines","the","feature","groups",",","e.g",".",":",">",">",">","#","+","--","-+","--","-+","--","-+","--","-+",">",">",">","#","|","0","|","0","|","1","|","1","|",">",">",">","#","+","--","-+","--","-+","--","-+","--","-+",">",">",">","#","|","0","|","0","|","1","|","1","|",">",">",">","#","+","--","-+","--","-+","--","-+","--","-+",">",">",">","#","|","2","|","2","|","3","|","3","|",">",">",">","#","+","--","-+","--","-+","--","-+","--","-+",">",">",">","#","|","2","|","2","|","3","|","3","|",">",">",">","#","+","--","-+","--","-+","--","-+","--","-+",">",">",">","#","With","this","mask",",","all","inputs","with","the","same","value","are","added",">",">",">","#","together",",","and","the","attribution","for","each","input","in","the","same",">",">",">","#","group","(","0",",","1",",","2",",","and","3",")","per","example","are","the","same",".",">",">",">","#","The","attributions","can","be","calculated","as","follows",":",">",">",">","#","feature","mask","has","dimensions","1","x","4","x","4",">",">",">","feature_mask","=","torch.tensor","(","[","[","[","0,0,1,1","]",",","[","0,0,1,1","]",",",">",">",">","[","2,2,3,3","]",",","[","2,2,3,3","]","]","]",")",">",">",">","#","With","only","4","features",",","it","is","feasible","to","compute","exact",">",">",">","#","Shapley","Values",".","These","can","be","computed","as","follows",":",">",">",">","sv","=","ShapleyValues","(","net",")",">",">",">","attr","=","sv.attribute","(","input",",","target=1",",","feature_mask=feature_mask",")"]
code: def attribute(
      self,
      inputs: TensorOrTupleOfTensorsGeneric,
      baselines: BaselineType = None,
      target: TargetType = None,
      additional_forward_args: Any = None,
      feature_mask: Union[None, TensorOrTupleOfTensorsGeneric] = None,
      perturbations_per_eval: int = 1,
      show_progress: bool = False,
  ) -> TensorOrTupleOfTensorsGeneric:
      r"""
      NOTE: The feature_mask argument differs from other perturbation based
      methods, since feature indices can overlap across tensors. See the
      description of the feature_mask argument below for more details.
  
      Args:
  
              inputs (Tensor or tuple[Tensor, ...]): Input for which Shapley value
                          sampling attributions are computed. If forward_func takes
                          a single tensor as input, a single input tensor should
                          be provided.
                          If forward_func takes multiple tensors as input, a tuple
                          of the input tensors should be provided. It is assumed
                          that for all given input tensors, dimension 0 corresponds
                          to the number of examples (aka batch size), and if
                          multiple input tensors are provided, the examples must
                          be aligned appropriately.
              baselines (scalar, Tensor, tuple of scalar, or Tensor, optional):
                          Baselines define reference value which replaces each
                          feature when ablated.
                          Baselines can be provided as:
  
                          - a single tensor, if inputs is a single tensor, with
                            exactly the same dimensions as inputs or the first
                            dimension is one and the remaining dimensions match
                            with inputs.
  
                          - a single scalar, if inputs is a single tensor, which will
                            be broadcasted for each input value in input tensor.
  
                          - a tuple of tensors or scalars, the baseline corresponding
                            to each tensor in the inputs' tuple can be:
  
                            - either a tensor with matching dimensions to
                              corresponding tensor in the inputs' tuple
                              or the first dimension is one and the remaining
                              dimensions match with the corresponding
                              input tensor.
  
                            - or a scalar, corresponding to a tensor in the
                              inputs' tuple. This scalar value is broadcasted
                              for corresponding input tensor.
  
                          In the cases when `baselines` is not provided, we internally
                          use zero scalar corresponding to each input tensor.
                          Default: None
              target (int, tuple, Tensor, or list, optional): Output indices for
                          which difference is computed (for classification cases,
                          this is usually the target class).
                          If the network returns a scalar value per example,
                          no target index is necessary.
                          For general 2D outputs, targets can be either:
  
                          - a single integer or a tensor containing a single
                            integer, which is applied to all input examples
  
                          - a list of integers or a 1D tensor, with length matching
                            the number of examples in inputs (dim 0). Each integer
                            is applied as the target for the corresponding example.
  
                          For outputs with > 2 dimensions, targets can be either:
  
                          - A single tuple, which contains #output_dims - 1
                            elements. This target index is applied to all examples.
  
                          - A list of tuples with length equal to the number of
                            examples in inputs (dim 0), and each tuple containing
                            #output_dims - 1 elements. Each tuple is applied as the
                            target for the corresponding example.
  
                          Default: None
              additional_forward_args (Any, optional): If the forward function
                          requires additional arguments other than the inputs for
                          which attributions should not be computed, this argument
                          can be provided. It must be either a single additional
                          argument of a Tensor or arbitrary (non-tuple) type or a
                          tuple containing multiple additional arguments including
                          tensors or any arbitrary python types. These arguments
                          are provided to forward_func in order following the
                          arguments in inputs.
                          For a tensor, the first dimension of the tensor must
                          correspond to the number of examples. For all other types,
                          the given argument is used for all forward evaluations.
                          Note that attributions are not computed with respect
                          to these arguments.
                          Default: None
              feature_mask (Tensor or tuple[Tensor, ...], optional):
                          feature_mask defines a mask for the input, grouping
                          features which should be added together. feature_mask
                          should contain the same number of tensors as inputs.
                          Each tensor should
                          be the same size as the corresponding input or
                          broadcastable to match the input tensor. Values across
                          all tensors should be integers in the range 0 to
                          num_features - 1, and indices corresponding to the same
                          feature should have the same value.
                          Note that features are grouped across tensors
                          (unlike feature ablation and occlusion), so
                          if the same index is used in different tensors, those
                          features are still grouped and added simultaneously.
                          If the forward function returns a single scalar per batch,
                          we enforce that the first dimension of each mask must be 1,
                          since attributions are returned batch-wise rather than per
                          example, so the attributions must correspond to the
                          same features (indices) in each input example.
                          If None, then a feature mask is constructed which assigns
                          each scalar within a tensor as a separate feature
                          Default: None
              perturbations_per_eval (int, optional): Allows multiple ablations
                          to be processed simultaneously in one call to forward_fn.
                          Each forward pass will contain a maximum of
                          perturbations_per_eval * #examples samples.
                          For DataParallel models, each batch is split among the
                          available devices, so evaluations on each available
                          device contain at most
                          (perturbations_per_eval * #examples) / num_devices
                          samples.
                          If the forward function returns a single scalar per batch,
                          perturbations_per_eval must be set to 1.
                          Default: 1
              show_progress (bool, optional): Displays the progress of computation.
                          It will try to use tqdm if available for advanced features
                          (e.g. time estimation). Otherwise, it will fallback to
                          a simple output of progress.
                          Default: False
      Returns:
              *Tensor* or *tuple[Tensor, ...]* of **attributions**:
              - **attributions** (*Tensor* or *tuple[Tensor, ...]*):
                          The attributions with respect to each input feature.
                          If the forward function returns
                          a scalar value per example, attributions will be
                          the same size as the provided inputs, with each value
                          providing the attribution of the corresponding input index.
                          If the forward function returns a scalar per batch, then
                          attribution tensor(s) will have first dimension 1 and
                          the remaining dimensions will match the input.
                          If a single tensor is provided as inputs, a single tensor is
                          returned. If a tuple is provided for inputs, a tuple of
                          corresponding sized tensors is returned.
  
  
      Examples::
  
          >>> # SimpleClassifier takes a single input tensor of size Nx4x4,
          >>> # and returns an Nx3 tensor of class probabilities.
          >>> net = SimpleClassifier()
          >>> # Generating random input with size 2 x 4 x 4
          >>> input = torch.randn(2, 4, 4)
  
          >>> # We may want to add features in groups, e.g.
          >>> # grouping each 2x2 square of the inputs and adding them together.
          >>> # This can be done by creating a feature mask as follows, which
          >>> # defines the feature groups, e.g.:
          >>> # +---+---+---+---+
          >>> # | 0 | 0 | 1 | 1 |
          >>> # +---+---+---+---+
          >>> # | 0 | 0 | 1 | 1 |
          >>> # +---+---+---+---+
          >>> # | 2 | 2 | 3 | 3 |
          >>> # +---+---+---+---+
          >>> # | 2 | 2 | 3 | 3 |
          >>> # +---+---+---+---+
          >>> # With this mask, all inputs with the same value are added
          >>> # together, and the attribution for each input in the same
          >>> # group (0, 1, 2, and 3) per example are the same.
          >>> # The attributions can be calculated as follows:
          >>> # feature mask has dimensions 1 x 4 x 4
          >>> feature_mask = torch.tensor([[[0,0,1,1],[0,0,1,1],
          >>>                             [2,2,3,3],[2,2,3,3]]])
  
          >>> # With only 4 features, it is feasible to compute exact
          >>> # Shapley Values. These can be computed as follows:
          >>> sv = ShapleyValues(net)
          >>> attr = sv.attribute(input, target=1, feature_mask=feature_mask)
      """
      if feature_mask is None:
          total_features = sum(
              torch.numel(inp[0])
              for inp in _format_tensor_into_tuples(inputs)
          )
      else:
          total_features = (
              int(
                  max(
                      torch.max(single_mask).item()
                      for single_mask in feature_mask
                  )
              )
              + 1
          )
  
      if total_features >= 10:
          warnings.warn(
              "You are attempting to compute Shapley Values with at least 10 "
              "features, which will likely be very computationally expensive."
              "Consider using Shapley Value Sampling instead."
          )
  
      return super().attribute.__wrapped__(
          self,
          inputs=inputs,
          baselines=baselines,
          target=target,
          additional_forward_args=additional_forward_args,
          feature_mask=feature_mask,
          perturbations_per_eval=perturbations_per_eval,
          show_progress=show_progress,
      )
  
imports: import itertools
  import math
  import warnings
  from typing import Any, Callable, Iterable, Sequence, Tuple, Union
  import torch
  from captum._utils.common import _expand_additional_forward_args, _expand_target, _format_additional_forward_args, _format_feature_mask, _format_output, _format_tensor_into_tuples, _get_max_feature_index, _is_mask_valid, _is_tuple, _run_forward
  from captum._utils.progress import progress
  from captum._utils.typing import BaselineType, TargetType, TensorOrTupleOfTensorsGeneric
  from captum.attr._utils.attribution import PerturbationAttribution
  from captum.attr._utils.common import _find_output_mode_and_verify, _format_input_baseline, _tensorize_baseline
  from captum.log import log_usage
  from torch import Tensor
label_desc: Use image node_id 2 for calling the ShapleyValues obj's underlying member method code with example usage: obj.attribute(inputs, baselines, target, additional_forward_args, feature_mask, perturbations_per_eval, show_progress) and returns: super