code: def _verify_nearliness(self, mask: torch.Tensor, nearliness: int):
      if nearliness <= 0:
          assert torch.all(
              mask == torch.zeros(mask.shape[0], mask.shape[1])
          )
      else:
          height, width = mask.shape
          dist_to_diagonal = nearliness // 2
          for row in range(0, height):
              for col in range(0, width):
                  if abs(row - col) <= dist_to_diagonal:
                      assert mask[row, col] == 1
                  else:
                      assert mask[row, col] == 0
  
imports: import itertools
  import logging
  import re
  import torch
  from torch import nn
  from torch.ao.pruning import BaseSparsifier, WeightNormSparsifier, FakeSparsity, NearlyDiagonalSparsifier
  from torch.nn.utils.parametrize import is_parametrized
  from torch.testing._internal.common_utils import TestCase
  from torch.testing._internal.common_pruning import SimpleLinear, MockSparseLinear, ImplementedSparsifier
label_desc: Use image node_id 6 for calling the TestNearlyDiagonalSparsifier obj's underlying member method code with example usage: obj._verify_nearliness(mask, nearliness) without return types