code: def _fowlkes_mallows_index_compute(
      contingency: Tensor, n: int
  ) -> Tensor:
      """Compute the Fowlkes-Mallows index based on the contingency matrix.
  
      Args:
          contingency: contingency matrix
          n: number of samples
  
      Returns:
          fowlkes_mallows: Fowlkes-Mallows index
  
      """
      tk = torch.sum(contingency**2) - n
      if torch.allclose(tk, tensor(0)):
          return torch.tensor(0.0, device=contingency.device)
  
      pk = torch.sum(contingency.sum(dim=0) ** 2) - n
      qk = torch.sum(contingency.sum(dim=1) ** 2) - n
  
      return torch.sqrt(tk / pk) * torch.sqrt(tk / qk)
  
imports: from typing import Tuple
  import torch
  from torch import Tensor, tensor
  from torchmetrics.functional.clustering.utils import calculate_contingency_matrix, check_cluster_labels
label_desc: Use image node_id 2 for calling a global function with example usage: _fowlkes_mallows_index_compute(contingency, n) and returns: unknown, torch