<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_name(atomic_fractions):
 """ Generates a name from the composition. The name is generated on the basis of a classical chemical formula. """

    if not atomic_fractions:
        return ''

    if len(atomic_fractions) == 1:
        z = list(atomic_fractions.keys())[0]
        return pyxray.element_symbol(z)

    symbols = []
    fractions = []
    for z in sorted(atomic_fractions.keys(), reverse=True):
        symbols.append(pyxray.element_symbol(z))
        fractions.append(Fraction(atomic_fractions[z]).limit_denominator())

    # Find gcd of the fractions
    gcds = []
    for a, b in itertools.combinations(fractions, 2):
        gcds.append(math.gcd(a.denominator, b.denominator))
    smallest_gcd = min(gcds)

    # Write formula
    name = ''
    for symbol, fraction in zip(symbols, fractions):
        mole_fraction = int(fraction * smallest_gcd)
        if mole_fraction == 0:
            continue
        elif mole_fraction == 1:
            name += "%s" % symbol
        else:
            name += '%s%i' % (symbol, mole_fraction)

    return name