def calculate_G2(neighborsymbols, neighborpositions, center_symbol, eta,
    cutoff, cutofffxn, Ri, normalized=True, backend=None):
    """Calculate G2 symmetry function.

    Parameters
    ----------
    neighborsymbols : list of str
        List of symbols of all neighbor atoms.
    neighborpositions : list of list of floats
        List of Cartesian atomic positions.
    center_symbol : str
        Chemical symbol of the center atom.
    eta : float
        Parameter of Gaussian symmetry functions.
    cutoff : float
        Cutoff radius.
    cutofffxn : object
        Cutoff function.
    Ri : list
        Position of the center atom. Should be fed as a list of three floats.
    normalized : bool
        Whether or not the symmetry function is normalized.
    backed : object
        A backend.

    Returns
    -------
    feature : float
        Radial feature.
    """
    feature = 0.0
    num_neighbors = len(neighborpositions)
    Rc = cutoff
    feature = 0.0
    num_neighbors = len(neighborpositions)
    if normalized:
        Rc = cutoff
    else:
        Rc = 1.0
    for count in range(num_neighbors):
        symbol = neighborsymbols[count]
        Rj = neighborpositions[count]
        if backend.name == 'torch':
            Ri = backend.from_numpy(Ri)
            Rc = backend.from_numpy(Rc)
        if symbol == center_symbol:
            Rij = backend.norm(Rj - Ri)
            feature += backend.exp(-eta * Rij ** 2.0 / Rc ** 2.0) * cutofffxn(
                Rij)
    return feature
