def _infer_device_name(graph_def):
    """Infer device name from a partition GraphDef."""
    device_name = None
    for node in graph_def.node:
        if node.device:
            device_name = node.device
            break
    if device_name is None:
        print(
            "Failed to infer device name from partition GraphDef: none of the "
            "nodes of the GraphDef has a non-empty device name.")
    return device_name