code: def batch_to_sequence(data: types.NestedTensor) -> types.NestedTensor:
      """Converts data between sequence-major and batch-major format."""
      return tree.map_structure(
          lambda t: tf.transpose(
              t, [1, 0] + list(range(2, t.shape.rank))
          ),
          data,
      )
  
imports: import functools
  from typing import List, Optional, Union
  from acme import types
  from acme.utils import tree_utils
  import sonnet
  import tensorflow
  import tree
label_desc: Use image node_id 4 for calling a global function with example usage: batch_to_sequence(data) and returns: tree