code: def _pairwise_linear_similarity_update(
      x: Tensor,
      y: Optional[Tensor] = None,
      zero_diagonal: Optional[bool] = None,
  ) -> Tensor:
      """Calculate the pairwise linear similarity 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)
  
      distance = _safe_matmul(x, y)
      if zero_diagonal:
          distance.fill_diagonal_(0)
      return distance
  
imports: from typing import Optional
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.functional.pairwise.helpers import _check_input, _reduce_distance_matrix
  from torchmetrics.utilities.compute import _safe_matmul
label_desc: Use image node_id 1 for calling a global function with example usage: _pairwise_linear_similarity_update(x, y, zero_diagonal) and returns: distance