@@ -145,7 +145,7 @@ def attribute( # type: ignore
145145 ) -> Union [
146146 TensorOrTupleOfTensorsGeneric , Tuple [TensorOrTupleOfTensorsGeneric , Tensor ]
147147 ]:
148- r""""
148+ r"""
149149 Args:
150150
151151 inputs (tensor or tuple of tensors): Input for which
@@ -165,23 +165,25 @@ def attribute( # type: ignore
165165 Baselines can be provided as:
166166
167167 - a single tensor, if inputs is a single tensor, with
168- exactly the same dimensions as inputs or the first
169- dimension is one and the remaining dimensions match
170- with inputs.
168+ exactly the same dimensions as inputs or the first
169+ dimension is one and the remaining dimensions match
170+ with inputs.
171171
172172 - a single scalar, if inputs is a single tensor, which will
173- be broadcasted for each input value in input tensor.
173+ be broadcasted for each input value in input tensor.
174174
175175 - a tuple of tensors or scalars, the baseline corresponding
176- to each tensor in the inputs' tuple can be:
177- - either a tensor with matching dimensions to
178- corresponding tensor in the inputs' tuple
179- or the first dimension is one and the remaining
180- dimensions match with the corresponding
181- input tensor.
182- - or a scalar, corresponding to a tensor in the
183- inputs' tuple. This scalar value is broadcasted
184- for corresponding input tensor.
176+ to each tensor in the inputs' tuple can be:
177+
178+ - either a tensor with matching dimensions to
179+ corresponding tensor in the inputs' tuple
180+ or the first dimension is one and the remaining
181+ dimensions match with the corresponding
182+ input tensor.
183+
184+ - or a scalar, corresponding to a tensor in the
185+ inputs' tuple. This scalar value is broadcasted
186+ for corresponding input tensor.
185187
186188 In the cases when `baselines` is not provided, we internally
187189 use zero scalar corresponding to each input tensor.
@@ -195,21 +197,21 @@ def attribute( # type: ignore
195197 For general 2D outputs, targets can be either:
196198
197199 - a single integer or a tensor containing a single
198- integer, which is applied to all input examples
200+ integer, which is applied to all input examples
199201
200202 - a list of integers or a 1D tensor, with length matching
201- the number of examples in inputs (dim 0). Each integer
202- is applied as the target for the corresponding example.
203+ the number of examples in inputs (dim 0). Each integer
204+ is applied as the target for the corresponding example.
203205
204206 For outputs with > 2 dimensions, targets can be either:
205207
206208 - A single tuple, which contains #output_dims - 1
207- elements. This target index is applied to all examples.
209+ elements. This target index is applied to all examples.
208210
209211 - A list of tuples with length equal to the number of
210- examples in inputs (dim 0), and each tuple containing
211- #output_dims - 1 elements. Each tuple is applied as the
212- target for the corresponding example.
212+ examples in inputs (dim 0), and each tuple containing
213+ #output_dims - 1 elements. Each tuple is applied as the
214+ target for the corresponding example.
213215
214216 Default: None
215217 additional_forward_args (any, optional): If the forward function
@@ -232,9 +234,11 @@ def attribute( # type: ignore
232234 computing final attribution scores. This function can take
233235 at least one and at most three arguments with the
234236 following signature:
235- - custom_attribution_func(multipliers)
236- - custom_attribution_func(multipliers, inputs)
237- - custom_attribution_func(multipliers, inputs, baselines)
237+
238+ - custom_attribution_func(multipliers)
239+ - custom_attribution_func(multipliers, inputs)
240+ - custom_attribution_func(multipliers, inputs, baselines)
241+
238242 In case this function is not provided, we use the default
239243 logic defined as: multipliers * (inputs - baselines)
240244 It is assumed that all input arguments, `multipliers`,
@@ -608,21 +612,21 @@ def attribute( # type: ignore
608612 corresponding references. Baselines can be provided as:
609613
610614 - a single tensor, if inputs is a single tensor, with
611- the first dimension equal to the number of examples
612- in the baselines' distribution. The remaining dimensions
613- must match with input tensor's dimension starting from
614- the second dimension.
615+ the first dimension equal to the number of examples
616+ in the baselines' distribution. The remaining dimensions
617+ must match with input tensor's dimension starting from
618+ the second dimension.
615619
616620 - a tuple of tensors, if inputs is a tuple of tensors,
617- with the first dimension of any tensor inside the tuple
618- equal to the number of examples in the baseline's
619- distribution. The remaining dimensions must match
620- the dimensions of the corresponding input tensor
621- starting from the second dimension.
621+ with the first dimension of any tensor inside the tuple
622+ equal to the number of examples in the baseline's
623+ distribution. The remaining dimensions must match
624+ the dimensions of the corresponding input tensor
625+ starting from the second dimension.
622626
623627 - callable function, optionally takes `inputs` as an
624- argument and either returns a single tensor
625- or a tuple of those.
628+ argument and either returns a single tensor
629+ or a tuple of those.
626630
627631 It is recommended that the number of samples in the baselines'
628632 tensors is larger than one.
@@ -634,21 +638,21 @@ def attribute( # type: ignore
634638 For general 2D outputs, targets can be either:
635639
636640 - a single integer or a tensor containing a single
637- integer, which is applied to all input examples
641+ integer, which is applied to all input examples
638642
639643 - a list of integers or a 1D tensor, with length matching
640- the number of examples in inputs (dim 0). Each integer
641- is applied as the target for the corresponding example.
644+ the number of examples in inputs (dim 0). Each integer
645+ is applied as the target for the corresponding example.
642646
643647 For outputs with > 2 dimensions, targets can be either:
644648
645649 - A single tuple, which contains #output_dims - 1
646- elements. This target index is applied to all examples.
650+ elements. This target index is applied to all examples.
647651
648652 - A list of tuples with length equal to the number of
649- examples in inputs (dim 0), and each tuple containing
650- #output_dims - 1 elements. Each tuple is applied as the
651- target for the corresponding example.
653+ examples in inputs (dim 0), and each tuple containing
654+ #output_dims - 1 elements. Each tuple is applied as the
655+ target for the corresponding example.
652656
653657 Default: None
654658 additional_forward_args (any, optional): If the forward function
@@ -671,9 +675,11 @@ def attribute( # type: ignore
671675 computing final attribution scores. This function can take
672676 at least one and at most three arguments with the
673677 following signature:
674- - custom_attribution_func(multipliers)
675- - custom_attribution_func(multipliers, inputs)
676- - custom_attribution_func(multipliers, inputs, baselines)
678+
679+ - custom_attribution_func(multipliers)
680+ - custom_attribution_func(multipliers, inputs)
681+ - custom_attribution_func(multipliers, inputs, baselines)
682+
677683 In case this function is not provided we use the default
678684 logic defined as: multipliers * (inputs - baselines)
679685 It is assumed that all input arguments, `multipliers`,
0 commit comments