(inputs: Tuple[Any, ...])
| 4 | |
| 5 | |
| 6 | def detach_variable(inputs: Tuple[Any, ...]) -> Tuple[torch.Tensor, ...]: |
| 7 | if isinstance(inputs, tuple): |
| 8 | out = [] |
| 9 | for inp in inputs: |
| 10 | if not isinstance(inp, torch.Tensor): |
| 11 | out.append(inp) |
| 12 | continue |
| 13 | |
| 14 | x = inp.detach() |
| 15 | x.requires_grad = inp.requires_grad |
| 16 | out.append(x) |
| 17 | return tuple(out) |
| 18 | else: |
| 19 | raise RuntimeError( |
| 20 | "Only tuple of tensors is supported. Got Unsupported input type: ", type(inputs).__name__) |
| 21 | |
| 22 | |
| 23 | def check_backward_validity(inputs: Iterable[Any]) -> None: |