parameters: (x, diag)
return_statement: return cov
docstring: Defines the covariance operation of a matrix.
  
    Args:
      x: a matrix Tensor. Dimension 0 should contain the number of examples.
      diag: if True, it computes the diagonal covariance.
  
    Returns:
      A Tensor representing the covariance of x. In the case of
    diagonal matrix just the diagonal is returned.
docstring_summary: Defines the covariance operation of a matrix.
docstring_tokens: Defines the covariance operation of a matrix .
function: def _covariance(x, diag):
    """Defines the covariance operation of a matrix.
  
    Args:
      x: a matrix Tensor. Dimension 0 should contain the number of examples.
      diag: if True, it computes the diagonal covariance.
  
    Returns:
      A Tensor representing the covariance of x. In the case of
    diagonal matrix just the diagonal is returned.
    """
    num_points = tf.to_float(tf.shape(x)[0])
    x -= tf.reduce_mean(x, 0, keep_dims=True)
    if diag:
      cov = tf.reduce_sum(
          tf.square(x), 0, keep_dims=True) / (num_points - 1)
    else:
      cov = tf.matmul(x, x, transpose_a=True)  / (num_points - 1)
    return cov
function_tokens: def _covariance ( x , diag ) : num_points = tf . to_float ( tf . shape ( x ) [ 0 ] ) x -= tf . reduce_mean ( x , 0 , keep_dims = True ) if diag : cov = tf . reduce_sum ( tf . square ( x ) , 0 , keep_dims = True ) / ( num_points - 1 ) else : cov = tf . matmul ( x , x , transpose_a = True ) / ( num_points - 1 ) return cov