code: def test_MIPS_exclude(device, k):
      lhs = torch.randn(10, 16, device=device)
      rhs = torch.randn(100, 16, device=device)
  
      exclude_lhs = torch.randint(0, 10, (500,), device=device)
      exclude_rhs = torch.randint(0, 100, (500,), device=device)
      exclude_links = torch.stack([exclude_lhs, exclude_rhs], dim=0)
      exclude_links = exclude_links.unique(dim=1)
  
      index = MIPSKNNIndex(rhs)
  
      out = index.search(lhs, k, exclude_links)
      assert out.score.device == device
      assert out.index.device == device
      assert out.score.size() == (10, k)
      assert out.index.size() == (10, k)
  
      # Ensure that excluded links are not present in `out.index`:
      batch = torch.arange(
          lhs.size(0), device=device
      ).repeat_interleave(k)
      knn_links = torch.stack([batch, out.index.view(-1)], dim=0)
      knn_links = knn_links[:, knn_links[1] >= 0]
  
      unique_links = torch.cat(
          [knn_links, exclude_links], dim=1
      ).unique(dim=1)
      assert unique_links.size(1) == knn_links.size(
          1
      ) + exclude_links.size(1)
  
imports: import pytest
  import torch
  from torch_geometric.nn import L2KNNIndex, MIPSKNNIndex
  from torch_geometric.testing import withCUDA, withPackage
label_desc: Use image node_id 3 for calling a global function with example usage: test_MIPS_exclude(device, k) without return types