def METHOD_NAME(self):
    for type, group in self.node_group_resources.items():
        resource = group.node_resource
        resource.cpu = _limit_cpu(resource.cpu)
        resource.memory = _limit_memory(resource.memory)
        if type == NodeType.WORKER:
            group.count = min(
                group.count, NodeResourceLimit.MAX_WORKER_NUM
            )
            if group.count > 0:
                resource.cpu = (
                    resource.cpu
                    if resource.cpu
                    else DefaultNodeResource.WORKER_CPU
                )
                resource.memory = (
                    resource.memory
                    if resource.memory
                    else DefaultNodeResource.WORKER_MEMORY
                )
        elif type == NodeType.PS:
            group.count = min(group.count, NodeResourceLimit.MAX_PS_NUM)
            if group.count > 0:
                resource.cpu = (
                    resource.cpu
                    if resource.cpu
                    else DefaultNodeResource.PS_CPU
                )
                resource.memory = (
                    resource.memory
                    if resource.memory
                    else DefaultNodeResource.PS_MEMORY
                )
        for _, resource in self.node_resources.items():
            resource.cpu = _limit_cpu(resource.cpu)
            resource.memory = _limit_memory(resource.memory)