code: def test_repeated_ngram_blocking_constraint_apply(self):
      ngram_size = 3
      batch_size = 2
      beam_size = 2
      num_classes = 10
      constraint = RepeatedNGramBlockingConstraint(ngram_size)
  
      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]},
              },
          ],
      ]
      log_probabilities = torch.rand(batch_size, beam_size, num_classes)
      constraint.apply(state, log_probabilities)
  
      disallowed_locations = torch.nonzero(
          log_probabilities
          == min_value_of_dtype(log_probabilities.dtype)
      ).tolist()
      assert len(disallowed_locations) == 4
      assert [0, 1, 4] in disallowed_locations
      assert [1, 1, 0] in disallowed_locations
      assert [1, 1, 1] in disallowed_locations
      assert [1, 1, 2] in disallowed_locations
  
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 30 for calling the BeamSearchTest obj's underlying member method code with example usage: obj.test_repeated_ngram_blocking_constraint_apply() without return types