code: def is_diagonal(matrix: np.ndarray, *, atol: float = 1e-8) -> bool:
      
      matrix = np.copy(matrix)
      for i in range(min(matrix.shape)):
          matrix[i, i] = 0
      return tolerance.all_near_zero(matrix, atol=atol)
docs: Determines if a matrix is a approximately diagonal.
  
      A matrix is diagonal if i!=j implies m[i,j]==0.
  
      Args:
          matrix: The matrix to check.
          atol: The per-matrix-entry absolute tolerance on equality.
  
      Returns:
          Whether the matrix is diagonal within the given tolerance.