(self, func)
| 2127 | ) |
| 2128 | |
| 2129 | def apply(self, func): |
| 2130 | if not self.stop_gradient: |
| 2131 | raise RuntimeError( |
| 2132 | "Cannot apply function on a tensor that required gradient." |
| 2133 | ) |
| 2134 | try: |
| 2135 | return func(self) |
| 2136 | except: |
| 2137 | raise ValueError(f"The PyFunc {func.__name__} could not be applied") |
| 2138 | |
| 2139 | def __str__(self): |
| 2140 | return self._to_readable_code() |
no test coverage detected