code: def test_hamming_diversity(self):
      vocab_size = 4
      num_beams = 2
      num_beam_groups = 2
  
      scores = self._get_uniform_logits(num_beams, vocab_size)
      # batch_idx = 0 -> index batch_idx * num_beam_groups -> idx = 0 * 2 = 0 -> penalises tokens 1
      # batch_idx = 1 -> index batch_idx * num_beam_groups -> idx = 1 * 2 = 2 -> penalises tokens 1
      current_tokens = torch.tensor(
          [0, 3, 1, 2], device=torch_device, dtype=torch.long
      )
  
      diversity_logits_processor = HammingDiversityLogitsProcessor(
          diversity_penalty=1.0,
          num_beams=num_beams,
          num_beam_groups=num_beam_groups,
      )
  
      processed_scores = diversity_logits_processor(
          None, scores, current_tokens, 1
      )
  
      self.assertTrue(
          torch.allclose(
              processed_scores[0],
              torch.tensor(
                  [-0.7500, 0.2500, 0.2500, 0.2500], device=torch_device
              ),
              atol=1e-3,
          )
      )
      self.assertTrue(
          torch.allclose(
              processed_scores[1],
              torch.tensor(
                  [0.2500, -0.7500, 0.2500, 0.2500], device=torch_device
              ),
              atol=1e-3,
          )
      )
  
imports: import unittest
  from typing import List, Union
  from parameterized import parameterized
  from transformers import is_torch_available
  from transformers.testing_utils import require_torch, torch_device
  from ..test_modeling_common import ids_tensor
label_desc: Use image node_id 18 for calling the LogitsProcessorTest obj's underlying member method code with example usage: obj.test_hamming_diversity() without return types