torch.func.functionalize
torch.func.functionalize(func, *, remove='mutations')
functionalize is a transform that can be used to remove
   (intermediate) mutations and aliasing from a function, while
   preserving the function's semantics.
"functionalize(func)" returns a new function with the same
   semantics as "func", but with all intermediate mutations removed.
   Every inplace operation performed on an intermediate tensor:
   "intermediate.foo_()" gets replaced by its out-of-place equivalent:
   "intermediate_updated = intermediate.foo()".
functionalize is useful for shipping a pytorch program off to
   backends or compilers that aren't able to easily represent
   mutations or aliasing operators.
Parameters:
      * func (Callable) -- A Python function that takes one or
        more arguments.
  * **remove** (*str*) -- An optional string argument, that takes
    on either the value 'mutations' or 'mutations_and_views'. If
