code: def _pairwise_euclidean_distance_update(
      x: Tensor,
      y: Optional[Tensor] = None,
      zero_diagonal: Optional[bool] = None,
  ) -> Tensor:
      """Calculate the pairwise euclidean distance matrix.
  
      Args:
          x: tensor of shape ``[N,d]``
          y: tensor of shape ``[M,d]``
          zero_diagonal: determines if the diagonal of the distance matrix should be set to zero
  
      """
      x, y, zero_diagonal = _check_input(x, y, zero_diagonal)
      # upcast to float64 to prevent precision issues
      _orig_dtype = x.dtype
      x = x.to(torch.float64)
      y = y.to(torch.float64)
      x_norm = (x * x).sum(dim=1, keepdim=True)
      y_norm = (y * y).sum(dim=1)
      distance = (x_norm + y_norm - 2 * x.mm(y.T)).to(_orig_dtype)
      if zero_diagonal:
          distance.fill_diagonal_(0)
      return distance.sqrt()
  
imports: from typing import Optional
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.functional.pairwise.helpers import _check_input, _reduce_distance_matrix
label_desc: Use image node_id 1 for calling a global function with example usage: _pairwise_euclidean_distance_update(x, y, zero_diagonal) and returns: distance