class_docstr: Speaker Diarization model
  
  If "attractor" is "None", SA-EEND will be used.
  Else if "attractor" is not "None", EEND-EDA will be used.
  For the details about SA-EEND and EEND-EDA, refer to the following papers:
  SA-EEND: https://arxiv.org/pdf/1909.06247.pdf
  EEND-EDA: https://arxiv.org/pdf/2005.09921.pdf, https://arxiv.org/pdf/2106.10654.pdf
code: def pit_loss(self, pred, label, lengths):
      # Note (jiatong): Credit to https://github.com/hitachi-speech/EEND
      num_output = label.size(2)
      permute_list = [
          np.array(p) for p in permutations(range(num_output))
      ]
      loss_list = []
      for p in permute_list:
          label_perm = label[:, :, p]
          loss_perm = self.pit_loss_single_permute(
              pred, label_perm, lengths
          )
          loss_list.append(loss_perm)
      loss = torch.cat(loss_list, dim=1)
      min_loss, min_idx = torch.min(loss, dim=1)
      loss = torch.sum(min_loss) / torch.sum(lengths.float())
      batch_size = len(min_idx)
      label_list = []
      for i in range(batch_size):
          label_list.append(
              label[i, :, permute_list[min_idx[i]]].data.cpu().numpy()
          )
      label_permute = torch.from_numpy(np.array(label_list)).float()
      return loss, min_idx, permute_list, label_permute
  
imports: from contextlib import contextmanager
  from itertools import permutations
  from typing import Dict, Optional, Tuple
  import numpy
  import torch
  import torch.nn.functional
  from packaging.version import parse
  from typeguard import check_argument_types
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.frontend.abs_frontend import AbsFrontend
  from espnet2.asr.specaug.abs_specaug import AbsSpecAug
  from espnet2.diar.attractor.abs_attractor import AbsAttractor
  from espnet2.diar.decoder.abs_decoder import AbsDecoder
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
  from espnet.nets.pytorch_backend.nets_utils import to_device
label_desc: Use image node_id 7 for calling the ESPnetDiarizationModel obj's underlying member method code with example usage: obj.pit_loss(pred, label, lengths) and returns: loss,  min_idx,  permute_list,  label_permute