(output_grads, variables=None)
| 602 | original_vars = set(tape.watched_variables()) |
| 603 | |
| 604 | def _grad_fn(output_grads, variables=None): |
| 605 | # Validate that custom_gradient passes the right variables into grad_fn. |
| 606 | if original_vars: |
| 607 | assert variables, ("Fn created variables but the variables were not " |
| 608 | "passed to the gradient fn.") |
| 609 | if set(variables) != original_vars: |
| 610 | raise ValueError(_WRONG_VARS_ERR) |
| 611 | |
| 612 | return _recomputing_grad_fn( |
| 613 | compute_fn=fn, |
| 614 | original_args=args, |
| 615 | original_vars=original_vars, |
| 616 | output_grads=output_grads, |
| 617 | grad_fn_variables=variables, |
| 618 | use_data_dep=use_data_dep_, |
| 619 | tupleize_grads=tupleize_grads, |
| 620 | arg_scope=arg_scope, |
| 621 | var_scope=vs, |
| 622 | has_is_recompute_kwarg=has_is_recompute_kwarg) |
| 623 | |
| 624 | # custom_gradient inspects the signature of the function to determine |
| 625 | # whether the user expects variables passed in the grad_fn. If the function |
no test coverage detected