code: def transpose_first_axis_to_last(
      tree: chex.ArrayTree,
  ) -> chex.ArrayTree:
      """Function to transpose the first axis to be last for all leaves in a pytree.
  
      This function will transpose the first axis to the last dim of all leaves in a
      pytree; each leaf with shape [D_1, D_2, ..., D_n] will have shape
      [D_2, ..., D_n, D_1].
  
      Args:
        tree: the pytree of Arrays to be transposed.
  
      Returns:
        tree: the transposed output tree.
      """
  
      def _transpose(tree):
          return jnp.transpose(tree, list(range(1, tree.ndim)) + [0])
  
      return tree_fn(_transpose)(tree)
  
file_path: rlax/rlax/_src/tree_util.py
imports: import functools
  from typing import Any, Callable, Sequence
  import chex
  import jax
  import jax.numpy
  import numpy
  from rlax._src import base
label_desc: Use image node_id 8 for calling a global function with example usage: transpose_first_axis_to_last(tree) and returns: tree_fn, jnp