** (ArgumentError) cannot invoke to_binary/2 on Nx.Defn.Expr.
This typically means you are invoking an unsupported Nx function
inside `defn` or inside JIT compiled code
or in the separate example code during compile time
** (CompileError) #cell:24: Nx.to_flat_list/1 is not allowed inside defn
The answer is no because you can’t really traverse lists inside the native CPU/GPU, they are an Elixir construct. The idea is that everything inside the defn happens on the native device.
If that’s the last step of you computation, then you should invoke it outside of defn, once it is over. If it is part of the computation, then you want to write it in a way it doesn’t require to_flat_list.
I also realize this could work in defn as long as we return slices of the original tensor. It is something you could do by hand using while, but we should probably add conveniences.