code: def test_copy_loss_ignore_index_is_ignored(self):
      for params, init_case in itertools.product(
          self.PARAMS, self.INIT_CASES
      ):
          loss = CopyGeneratorLoss(**init_case)
          scores, align, target = self.dummy_inputs(params, init_case)
          res = loss(scores, align, target)
          should_be_ignored = (
              target == init_case["ignore_index"]
          ).nonzero(as_tuple=False)
          assert (
              len(should_be_ignored) > 0
          )  # otherwise not testing anything
          self.assertTrue(
              res[should_be_ignored].allclose(torch.tensor(0.0))
          )
  
imports: import unittest
  from onmt.modules.copy_generator import CopyGenerator, CopyGeneratorLoss
  import itertools
  from copy import deepcopy
  import torch
  from torch.nn.functional import softmax
  from onmt.tests.utils_for_tests import product_dict
label_desc: Use image node_id 4 for calling the TestCopyGeneratorLoss obj's underlying member method code with example usage: obj.test_copy_loss_ignore_index_is_ignored() without return types