code: def test_dirac_properties(self):
      for dims in [3, 4, 5]:
          for groups in [1, 2, 3]:
              # prepare random tensor with random sizes, but fits groups
              a, c, d, e = (random.randint(1, 5) for _ in range(4))
              b = random.randint(
                  1, 5 * groups
              )  # same range as a*groups but all range allowed
              # make sure first dim divides by groups
              input_tensor = torch.randn(
                  (a * groups, b, c, d, e)[:dims]
              )
  
              init.dirac_(input_tensor, groups)
  
              c_out, c_in = input_tensor.size(
                  0
              ) // groups, input_tensor.size(1)
              min_d = min(c_out, c_in)
              # Check number of nonzeros is equivalent to smallest dim (for each group)
              assert (
                  torch.nonzero(input_tensor).size(0) == min_d * groups
              )
              # Check sum of values (can have precision issues, hence assertEqual) is also equivalent
              self.assertEqual(input_tensor.sum(), min_d * groups)
  
imports: import random
  import unittest
  import math
  import string
  from functools import reduce
  from operator import mul
  from torch.testing._internal.common_utils import TestCase, TEST_SCIPY, skipIfNoLapack, skipIfTorchDynamo, run_tests
  import torch
  import torch.nn.init
  import torch.nn.functional
label_desc: Use image node_id 20 for calling the TestNNInit obj's underlying member method code with example usage: obj.test_dirac_properties() without return types