@@ -130,10 +130,6 @@ def attribute(
130130 show_progress : bool = False ,
131131 ) -> TensorOrTupleOfTensorsGeneric :
132132 r"""
133- NOTE: The feature_mask argument differs from other perturbation based
134- methods, since feature indices can overlap across tensors. See the
135- description of the feature_mask argument below for more details.
136-
137133 Args:
138134
139135 inputs (Tensor or tuple[Tensor, ...]): Input for which Shapley value
@@ -225,8 +221,7 @@ def attribute(
225221 all tensors should be integers in the range 0 to
226222 num_features - 1, and indices corresponding to the same
227223 feature should have the same value.
228- Note that features are grouped across tensors
229- (unlike feature ablation and occlusion), so
224+ Note that features are grouped across tensors, so
230225 if the same index is used in different tensors, those
231226 features are still grouped and added simultaneously.
232227 If the forward function returns a single scalar per batch,
@@ -521,7 +516,7 @@ def attribute_future(
521516 prev_result_tuple : Future [
522517 Tuple [Tensor , Tensor , Size , List [Tensor ], bool ]
523518 ] = initial_eval .then (
524- lambda inp = initial_eval : self ._initialEvalToPrevResultsTuple ( # type: ignore # noqa: E501 line too long
519+ lambda inp = initial_eval : self ._initial_eval_to_prev_results_tuple ( # type: ignore # noqa: E501 line too long
525520 inp ,
526521 num_examples ,
527522 perturbations_per_eval ,
@@ -537,7 +532,7 @@ def attribute_future(
537532 total_features , n_samples
538533 ):
539534 prev_result_tuple = prev_result_tuple .then (
540- lambda inp = prev_result_tuple : self ._setPrevResultsToInitialEval (inp ) # type: ignore # noqa: E501 line too long
535+ lambda inp = prev_result_tuple : self ._set_prev_results_to_initial_eval (inp ) # type: ignore # noqa: E501 line too long
541536 )
542537
543538 iter_count += 1
@@ -590,7 +585,7 @@ def attribute_future(
590585 ] = collect_all ([prev_result_tuple , modified_eval ])
591586
592587 prev_result_tuple = eval_futs .then (
593- lambda evals = eval_futs , masks = current_masks : self ._evalFutToPrevResultsTuple ( # type: ignore # noqa: E501 line too long
588+ lambda evals = eval_futs , masks = current_masks : self ._eval_fut_to_prev_results_tuple ( # type: ignore # noqa: E501 line too long
594589 evals , num_examples , inputs_tuple , masks
595590 )
596591 )
@@ -602,14 +597,14 @@ def attribute_future(
602597 # formatted attributions.
603598 formatted_attr : Future [Union [Tensor , tuple [Tensor , ...]]] = (
604599 prev_result_tuple .then (
605- lambda inp = prev_result_tuple : self ._prevResultTupleToFormattedAttr ( # type: ignore # noqa: E501 line too long
600+ lambda inp = prev_result_tuple : self ._prev_result_tuple_to_formatted_attr ( # type: ignore # noqa: E501 line too long
606601 inp , iter_count , is_inputs_tuple
607602 )
608603 )
609604 )
610605 return cast (Future [TensorOrTupleOfTensorsGeneric ], formatted_attr )
611606
612- def _initialEvalToPrevResultsTuple (
607+ def _initial_eval_to_prev_results_tuple (
613608 self ,
614609 initial_eval : Future [Tensor ],
615610 num_examples : int ,
@@ -657,7 +652,7 @@ def _initialEvalToPrevResultsTuple(
657652 ) from e
658653 return result
659654
660- def _setPrevResultsToInitialEval (
655+ def _set_prev_results_to_initial_eval (
661656 self ,
662657 processed_initial_eval : Future [Tuple [Tensor , Tensor , Size , List [Tensor ], bool ]],
663658 ) -> Tuple [Tensor , Tensor , Size , List [Tensor ], bool ]:
@@ -669,7 +664,7 @@ def _setPrevResultsToInitialEval(
669664 prev_results = initial_eval
670665 return (initial_eval , prev_results , output_shape , total_attrib , agg_output_mode )
671666
672- def _evalFutToPrevResultsTuple (
667+ def _eval_fut_to_prev_results_tuple (
673668 self ,
674669 eval_futs : Future [
675670 List [
@@ -755,7 +750,7 @@ def _evalFutToPrevResultsTuple(
755750 )
756751 return result
757752
758- def _prevResultTupleToFormattedAttr (
753+ def _prev_result_tuple_to_formatted_attr (
759754 self ,
760755 prev_result_tuple : Future [
761756 Tuple [Tensor , Tensor , Tuple [int ], List [Tensor ], bool ]
0 commit comments