code: def test_top_eigen(self, dim: int, rank: int):
      # generate symmetric matrix of specific rank and check can recover it using
      # the eigenvalues / eigenvectors returned by `_top_eigen`
      R = torch.randn(dim, rank)
      H = torch.matmul(R, R.T)
      ls, vs = _top_eigen(H, rank, 1e-5, 1e-5)
      assertTensorAlmostEqual(
          self, vs @ torch.diag(ls) @ vs.T, H, 1e-2, "max"
      )
  
imports: import tempfile
  from typing import Callable, List, Tuple, Union
  import torch
  import torch.nn
  from captum.influence._core.arnoldi_influence_function import _parameter_arnoldi, _parameter_distill, ArnoldiInfluenceFunction
  from captum.influence._core.influence_function import NaiveInfluenceFunction
  from captum.influence._utils.common import _eig_helper, _flatten_params, _top_eigen, _unflatten_params_factory
  from parameterized import parameterized
  from tests.helpers.basic import assertTensorAlmostEqual, BaseTest
  from tests.influence._utils.common import _format_batch_into_tuple, build_test_name_func, DataInfluenceConstructor, ExplicitDataset, generate_assymetric_matrix_given_eigenvalues, generate_symmetric_matrix_given_eigenvalues, get_random_model_and_data, UnpackDataset, USE_GPU_LIST
  from torch import Tensor
  from torch.utils.data import DataLoader
label_desc: Use image node_id 1 for calling the TestArnoldiInfluence obj's underlying member method code with example usage: obj.test_top_eigen(dim, rank) without return types