code: def test_repeated_ngram_blocking_constraint_update_state(self):
      ngram_size = 3
      constraint = RepeatedNGramBlockingConstraint(ngram_size)
  
      # We will have [2, 3] -> {5, 6} from batch index 0 and [4, 5] -> {0} and [6, 7] -> {3}
      # from batch index
      state = [
          [
              {"current_prefix": [0, 1], "seen_ngrams": {}},
              {"current_prefix": [2, 3], "seen_ngrams": {(2, 3): [4]}},
          ],
          [
              {"current_prefix": [4, 5], "seen_ngrams": {(8, 9): []}},
              {
                  "current_prefix": [6, 7],
                  "seen_ngrams": {(6, 7): [0, 1, 2]},
              },
          ],
      ]
      predictions = torch.LongTensor([[5, 6], [0, 3]])
      backpointers = torch.LongTensor([[1, 1], [0, 1]])
  
      expected_state = [
          [
              {
                  "current_prefix": [3, 5],
                  "seen_ngrams": {(2, 3): [4, 5]},
              },
              {
                  "current_prefix": [3, 6],
                  "seen_ngrams": {(2, 3): [4, 6]},
              },
          ],
          [
              {
                  "current_prefix": [5, 0],
                  "seen_ngrams": {(8, 9): [], (4, 5): [0]},
              },
              {
                  "current_prefix": [7, 3],
                  "seen_ngrams": {(6, 7): [0, 1, 2, 3]},
              },
          ],
      ]
      updated_state = constraint.update_state(
          state, predictions, backpointers
      )
      assert updated_state == expected_state
  
imports: from typing import Dict, Tuple, Union
  import numpy
  import pytest
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.nn.beam_search import MultinomialSampler, BeamSearch, TopKSampler, TopPSampler, GumbelSampler, LengthNormalizedSequenceLogProbabilityScorer, RepeatedNGramBlockingConstraint, StepFunctionTypeWithTimestep, StepFunctionTypeNoTimestep
  from allennlp.common.params import Params
  from allennlp.nn.util import min_value_of_dtype
label_desc: Use image node_id 31 for calling the BeamSearchTest obj's underlying member method code with example usage: obj.test_repeated_ngram_blocking_constraint_update_state() without return types