code: def updateClusterSize(self, estimatedNodeCounts):
          
          newNodeCounts = defaultdict(int)
          for nodeShape, estimatedNodeCount in estimatedNodeCounts.items():
              nodeType = self.nodeShapeToType[nodeShape]
  
              newNodeCount = self.setNodeCount(nodeType=nodeType, numNodes=estimatedNodeCount, preemptable=nodeShape.preemptable)
              # If we were scaling up a preemptable node type and failed to meet
              # our target, we will attempt to compensate for the deficit while scaling
              # non-preemptable nodes of this type.
              if nodeShape.preemptable:
                  if newNodeCount < estimatedNodeCount:
                      deficit = estimatedNodeCount - newNodeCount
                      logger.debug('Preemptable scaler detected deficit of %d nodes of type %s.' % (deficit, nodeType))
                      self.preemptableNodeDeficit[nodeType] = deficit
                  else:
                      self.preemptableNodeDeficit[nodeType] = 0
              newNodeCounts[nodeShape] = newNodeCount
  
          #Attempt to terminate any nodes that we previously designated for 
          #termination, but which still had workers running.
          self._terminateIgnoredNodes()
          return newNodeCounts
docs: Given the desired and current size of the cluster, attempts to launch/remove instances to
          get to the desired size. Also attempts to remove ignored nodes that were marked for graceful
          removal.
  
          Returns the new size of the cluster.