code: def compute_max_candidates(p_m0: Tensor, p_m1: Tensor) -> Tensor:
      """Compute the max candidates of all pairs within a batch.
  
      Args:
          p_m0, p_m1 (torch.Tensor): padded masks
      """
      h0s, w0s = p_m0.sum(1).max(-1)[0], p_m0.sum(-1).max(-1)[0]
      h1s, w1s = p_m1.sum(1).max(-1)[0], p_m1.sum(-1).max(-1)[0]
      max_cand = torch.sum(
          torch.min(torch.stack([h0s * w0s, h1s * w1s], -1), -1)[0]
      )
      return max_cand
  
file_path: kornia/kornia/feature/loftr/utils/coarse_matching.py
imports: from typing import Any, Dict, Optional, Union
  import torch
  import torch.nn.functional
  from torch import nn
  from kornia.core import Module, Tensor
label_desc: Use image node_id 3 for calling a global function with example usage: compute_max_candidates(p_m0, p_m1) and returns: max_cand