# tensorplay.func.functionalize Source: https://www.tensorplay.cn/docs/generated/tensorplay.func.functionalize.html ```python tensorplay.func.functionalize(func: Callable, *, remove: str = 'mutations') → Callable ``` Returns a version of func that leaves its arguments untouched. func may write into its inputs in place; the wrapper hands it private copies instead, so the caller’s tensors – and any views onto them – come back exactly as they went in, while the returned value is unchanged. Parameters: - func (Callable) – the function to make side-effect free. - remove ([str](https://docs.python.org/3/builtins/stdtypes.html#str)) – "mutations" copies every tensor argument. "mutations_and_views" additionally detaches the copies from any aliasing they arrived with, so writes through a view of an argument cannot reach another argument either. Example ``` >>> def f(x): ... x.add_(1) ... return x >>> x = tensorplay.zeros(3) >>> out = functionalize(f)(x) >>> x # unchanged tensor([0., 0., 0.]) ```