code: def test_length_limit():
      """
      Test that the length limit drops nodes as the length limit is exceeded
      """
      ts = TransformerTreeStack(4, 5, 0.0, length_limit=2)
      initial = ts.initial_state()
      assert len(initial) == 1
      assert initial.value.output.shape == torch.Size([5])
      assert initial.value.key_stack.shape == torch.Size([1, 5])
      assert initial.value.value_stack.shape == torch.Size([1, 5])
  
      data = torch.tensor([[0.1, 0.2, 0.3, 0.4]])
      stacks = ts.push_states([initial], ["A"], data)
  
      stacks = ts.push_states(stacks, ["B"], data)
      assert len(stacks) == 1
      assert len(stacks[0]) == 3
      assert stacks[0].value.key_stack.shape[0] == 3
      assert stacks[0].value.value_stack.shape[0] == 3
  
      stacks = ts.push_states(stacks, ["C"], data)
      assert len(stacks) == 1
      assert len(stacks[0]) == 4
      assert stacks[0].value.key_stack.shape[0] == 3
      assert stacks[0].value.value_stack.shape[0] == 3
  
      stacks = ts.push_states(stacks, ["D"], data)
      assert len(stacks) == 1
      assert len(stacks[0]) == 5
      assert stacks[0].value.key_stack.shape[0] == 3
      assert stacks[0].value.value_stack.shape[0] == 3
  
file_path: stanza/stanza/tests/constituency/test_transformer_tree_stack.py
imports: import pytest
  import torch
  from stanza.models.constituency.transformer_tree_stack import TransformerTreeStack
label_desc: Use image node_id 8 for calling a global function with example usage: test_length_limit() without return types