code: def test_field_counts_vocab_items_correctly(self):
      field = ProductionRuleField("S -> [NP, VP]", is_global_rule=True)
      namespace_token_counts = defaultdict(lambda: defaultdict(int))
      field.count_vocab_items(namespace_token_counts)
      assert namespace_token_counts["rule_labels"]["S -> [NP, VP]"] == 1
  
      field = ProductionRuleField("S -> [NP, VP]", is_global_rule=False)
      namespace_token_counts = defaultdict(lambda: defaultdict(int))
      field.count_vocab_items(namespace_token_counts)
      assert namespace_token_counts["rule_labels"]["S -> [NP, VP]"] == 0
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/data/fields/production_rule_field_test.py
imports: from __future__ import absolute_import
  from collections import defaultdict
  from numpy.testing import assert_almost_equal
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data import Vocabulary
  from allennlp.data.fields import ListField, ProductionRuleField
label_desc: Use image node_id 2 for calling the TestProductionRuleField obj's underlying member method code with example usage: obj.test_field_counts_vocab_items_correctly() without return types