def riemann_metric( Y, laplacian, n_dim=None, invert_h=False, mode_inv = '<STR_LIT>'):
n_samples = laplacian.shape[<NUM_LIT:0>]<EOL>h_dual_metric = np.zeros((n_samples, n_dim, n_dim ))<EOL>for i in np.arange(n_dim ):<EOL><INDENT>for j in np.arange(i,n_dim ):<EOL><INDENT>yij = Y[:,i]*Y[:,j]<EOL>h_dual_metric[ :, i, j] = <NUM_LIT:0.5>*(laplacian.dot(yij)-Y[:,j]*laplacian.dot(Y[:,i])-Y[:,i]*laplacian.dot(Y[:,j]))<EOL><DEDENT><DEDENT>for j in np.arange(n_dim-<NUM_LIT:1>):<EOL><INDENT>for i in np.arange(j+<NUM_LIT:1>,n_dim):<EOL><INDENT>h_dual_metric[ :,i,j] = h_dual_metric[:,j,i]<EOL><DEDENT><DEDENT>if( invert_h ):<EOL><INDENT>riemann_metric, Hvv, Hsvals, Gsvals = compute_G_from_H( h_dual_metric )<EOL><DEDENT>else:<EOL><INDENT>riemann_metric = Hvv = Hsvals = Gsvals = None<EOL><DEDENT>return h_dual_metric, riemann_metric, Hvv, Hsvals, Gsvals<EOL>
Parameters
----------
Y: array-like, shape = (n_samples, mdimY )
    The embedding coordinates of the points
laplacian: array-like, shape = (n_samples, n_samples)
    The Laplacian of the data. It is recommended to use the "geometric"
    Laplacian (default) option from geometry.graph_laplacian()
n_dim : integer, optional
    Use only the first n_dim <= mdimY dimensions.All dimensions
    n_dim:mdimY are ignored.
invert_h: boolean, optional
    if False, only the "dual Riemannian metric" is computed
    if True, the dual metric matrices are inverted to obtain the
    Riemannian metric G.
mode_inv: string, optional
   How to compute the inverses of h_dual_metric, if invert_h
    "inv", use numpy.inv()
    "svd" (default), use numpy.linalg.svd(), then invert the eigenvalues
    (possibly a more numerically stable method with H is symmetric and
    ill conditioned)

Returns
-------
h_dual_metric : array, shape=(n_samples, n_dim, n_dim)
Optionally :
g_riemann_metric : array, shape=(n_samples, n_dim, n_dim )
Hvv : singular vectors of H, transposed, shape = ( n_samples, n_dim, n_dim )
Hsvals : singular values of H, shape = ( n_samples, n_dim )
Gsvals : singular values of G, shape = ( n_samples, n_dim )

Notes
-----
References
----------
"Non-linear dimensionality reduction: Riemannian metric estimation and
the problem of geometric discovery",
Dominique Perraul-Joncas, Marina Meila, arXiv:1305.7255