def extract_metric_parameters(G):
    """
    From the shape of the Variable G, infers if it is supposed
    to be used as a fixed parameter or as a "j" variable,
    and whether it represents a scalar, a diagonal matrix
    or a full symmetric matrix.

    If G is a tuple, it can also encode an "i" variable.
    """
    if type(G) == tuple and G[0] == 'i':
        G_var = G[1]
        G_cat = 0
        G_dim = G_var.shape[1]
    elif type(G) == tuple and G[0] == 'j' or len(G.shape) == 2:
        G_var = G
        G_cat = 1
        G_dim = G.shape[1]
    elif len(G.shape) == 1:
        G_var = G
        G_cat = 2
        G_dim = G.shape[0]
    else:
        raise ValueError(
            "[KeOps] A 'metric' parameter is expected to be of dimension 1 or 2."
            )
    G_str = ['Vi', 'Vj', 'Pm'][G_cat]
    return G_var, G_dim, G_cat, G_str
