def cpu_format(cpu, ratio=1.0):
    """Convert number of cpu to cpu cycle.

    Args:
        cpu: Number of cpu.
        ratio: The percent that can be used.

    Returns:
        Formatted string of cpu cycle if cpu is valid, None otherwise.
    """
    try:
        cpu = float(cpu)
    except:
        return None
    else:
        return "%dm" % int(ratio * cpu * 1000)