code: def _gen_permutations(spk_num: int, device: torch.device) -> Tensor:
      key = str(spk_num) + str(device)
      if key not in _ps_dict:
          # ps: all the permutations, shape [perm_num, spk_num]
          # ps: In i-th permutation, the predcition corresponds to the j-th target is ps[j,i]
          ps = torch.tensor(
              list(permutations(range(spk_num))), device=device
          )
          _ps_dict[key] = ps
      else:
          ps = _ps_dict[
              key
          ]  # all the permutations, shape [perm_num, spk_num]
      return ps
  
file_path: torchmetrics/src/torchmetrics/functional/audio/pit.py
imports: from itertools import permutations
  from typing import Any, Callable, Tuple
  import numpy
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.utilities import rank_zero_warn
  from torchmetrics.utilities.imports import _SCIPY_AVAILABLE
label_desc: Use image node_id 1 for calling a global function with example usage: _gen_permutations(spk_num, device) and returns: ps