code: def _dunn_index_update(
      data: Tensor, labels: Tensor, p: float
  ) -> Tuple[Tensor, Tensor]:
      """Update and return variables required to compute the Dunn index.
  
      Args:
          data: feature vectors of shape (n_samples, n_features)
          labels: cluster labels
          p: p-norm (distance metric)
  
      Returns:
          intercluster_distance: intercluster distances
          max_intracluster_distance: max intracluster distances
  
      """
      unique_labels, inverse_indices = labels.unique(
          return_inverse=True
      )
      clusters = [
          data[inverse_indices == label_idx]
          for label_idx in range(len(unique_labels))
      ]
      centroids = [c.mean(dim=0) for c in clusters]
  
      intercluster_distance = torch.linalg.norm(
          torch.stack(
              [a - b for a, b in combinations(centroids, 2)], dim=0
          ),
          ord=p,
          dim=1,
      )
  
      max_intracluster_distance = torch.stack(
          [
              torch.linalg.norm(ci - mu, ord=p, dim=1).max()
              for ci, mu in zip(clusters, centroids)
          ]
      )
  
      return intercluster_distance, max_intracluster_distance
  
imports: from itertools import combinations
  from typing import Tuple
  import torch
  from torch import Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: _dunn_index_update(data, labels, p) and returns: intercluster_distance,  max_intracluster_distance