def METHOD_NAME(op):
    current_device = pydev.DeviceSpec.from_string(op.device or "")
    node_def = op if isinstance(op, node_def_pb2.NodeDef) else op.node_def
    if node_def.op in ps_ops:
        ps_device_spec = pydev.DeviceSpec.from_string("/{}:{}".format(ps_device_type, ps_strategy(op)))
        ps_device_spec.merge_from(current_device)
        return ps_device_spec.to_string()
    else:
        worker_device_spec = pydev.DeviceSpec.from_string(worker_device or "")
        worker_device_spec.merge_from(current_device)
        return worker_device_spec.to_string()