Make from_dict
more flexible, and add from_pytree
#2291
Merged
from_dict
more flexible, and add from_pytree
#2291