class_docstr: An abstract class for computing link prediction retrieval metrics.
  
  Args:
      k (int): The number of top-:math:`k` predictions to evaluate against.
class_docstr_tok: ["An","abstract","class","for","computing","link","prediction","retrieval","metrics",".","Args",":","k","(","int",")",":","The","number","of","top-",":","math",":","`","k","`","predictions","to","evaluate","against","."]
code: def __init__(self, k: int):
      super().__init__()
  
      if k <= 0:
          raise ValueError(
              f"'k' needs to be a positive integer in "
              f"'{self.__class__.__name__}' (got {k})"
          )
  
      self.k = k
  
      if WITH_TORCHMETRICS:
          self.add_state(
              "accum", torch.tensor(0.0), dist_reduce_fx="sum"
          )
          self.add_state("total", torch.tensor(0), dist_reduce_fx="sum")
      else:
          self.register_buffer("accum", torch.tensor(0.0))
          self.register_buffer("total", torch.tensor(0))
  
imports: from abc import ABC, abstractmethod
  from typing import Optional, Tuple, Union
  import torch
  from torch import Tensor
  from torch_geometric.utils import cumsum, scatter
label_desc: Use image node_id 1 to create a new LinkPredMetric object from inherited base classes: BaseMetric, ABC with example: obj = LinkPredMetric(k)