class_docstr: Tests for various tree utilities.
class_docstr_tok: ["Tests","for","various","tree","utilities","."]
docstr: Tests that `stack_sequence_fields` behaves correctly on nested data.
docstr_tok: ["Tests","that","`","stack_sequence_fields","`","behaves","correctly","on","nested","data","."]
code: def test_stack_sequence_fields(self):
      """Tests that `stack_sequence_fields` behaves correctly on nested data."""
  
      stacked = tree_utils.stack_sequence_fields(TEST_SEQUENCE)
  
      # Check that the stacked output has the correct structure.
      tree.assert_same_structure(stacked, TEST_SEQUENCE[0])
  
      # Check that the leaves have the correct array shapes.
      self.assertEqual(stacked["action"].shape, (3, 1))
      self.assertEqual(stacked["observation"][0].shape, (3, 3))
      self.assertEqual(stacked["reward"].shape, (3,))
  
      # Check values.
      self.assertEqual(
          stacked["observation"][0].tolist(),
          [
              [0.0, 1.0, 2.0],
              [1.0, 2.0, 3.0],
              [2.0, 3.0, 4.0],
          ],
      )
      self.assertEqual(
          stacked["action"].tolist(), [[1.0], [0.5], [0.3]]
      )
      self.assertEqual(stacked["reward"].tolist(), [1.0, 0.0, 0.5])
  
file_path: acme/acme/utils/tree_utils_test.py
imports: import functools
  from typing import Sequence
  from acme.utils import tree_utils
  import numpy
  import tree
  from absl.testing import absltest
label_desc: Use image node_id 1 for calling the SequenceStackTest obj's underlying member method code with example usage: obj.test_stack_sequence_fields() without return types