code: def test_top_n_pytorch(self):
      data = np.array([-10, -0.1, 0.0, 0, 3.4, 1.5])
      data = torch.tensor(data, dtype=torch.float)
  
      # ============== Without replace value, deascending
      # Top 1
      modified_data, idxes = filtering.filter_top_k(data, 1)
      modified_data = modified_data.data.numpy()
      idxes = idxes.data.numpy()
      np.testing.assert_equal(
          modified_data, np.array([3.4], dtype=np.float32)
      )
      np.testing.assert_equal(idxes, np.array([4]))
      # Top 2
      modified_data, idxes = filtering.filter_top_k(data, 2)
      modified_data = modified_data.data.numpy()
      idxes = idxes.data.numpy()
      np.testing.assert_equal(
          modified_data, np.array([3.4, 1.5], dtype=np.float32)
      )
      np.testing.assert_equal(idxes, np.array([4, 5]))
  
      # ============== Without replace value, ascending
      # Top 1
      modified_data, idxes = filtering.filter_top_k(
          data, 1, ascending=True
      )
      modified_data = modified_data.data.numpy()
      idxes = idxes.data.numpy()
      np.testing.assert_equal(
          modified_data, np.array([3.4], dtype=np.float32)
      )
      np.testing.assert_equal(idxes, np.array([4]))
      # Top 2
      modified_data, idxes = filtering.filter_top_k(
          data, 2, ascending=True
      )
      modified_data = modified_data.data.numpy()
      idxes = idxes.data.numpy()
      np.testing.assert_equal(
          modified_data, np.array([1.5, 3.4], dtype=np.float32)
      )
      np.testing.assert_equal(idxes, np.array([5, 4]))
  
      # ============== With replace value
      # Top 1
      modified_data, idxes = filtering.filter_top_k(
          data, 1, replace=-99
      )
      modified_data = modified_data.data.numpy()
      idxes = idxes.data.numpy()
      np.testing.assert_equal(
          modified_data,
          np.array(
              [-99.0, -99.0, -99.0, -99.0, 3.4, -99.0], dtype=np.float32
          ),
      )
      np.testing.assert_equal(idxes, np.array([4]))
      # Top 2
      modified_data, idxes = filtering.filter_top_k(
          data, 2, replace=-99
      )
      modified_data = modified_data.data.numpy()
      idxes = idxes.data.numpy()
      np.testing.assert_equal(
          modified_data,
          np.array([-99, -99, -99, -99, 3.4, 1.5], dtype=np.float32),
      )
      np.testing.assert_equal(idxes, np.array([4, 5]))
  
file_path: nlpaug/test/util/selection/test_filtering.py
imports: import unittest
  import numpy
  import nlpaug.util.selection.filtering
label_desc: Use image node_id 4 for calling the TestFiltering obj's underlying member method code with example usage: obj.test_top_n_pytorch() without return types