code: def freeNSynapses(self, numToFree, inactiveSynapseIndices, verbosity= 0):
      
      # Make sure numToFree isn't larger than the total number of syns we have
      assert (numToFree <= len(self.syns))
  
      if (verbosity >= 4):
        print "\nIn PY freeNSynapses with numToFree =", numToFree,
        print "inactiveSynapseIndices =",
        for i in inactiveSynapseIndices:
          print self.syns[i][0:2],
        print
  
      # Remove the lowest perm inactive synapses first
      if len(inactiveSynapseIndices) > 0:
        perms = numpy.array([self.syns[i][2] for i in inactiveSynapseIndices])
        candidates = numpy.array(inactiveSynapseIndices)[
            perms.argsort()[0:numToFree]]
        candidates = list(candidates)
      else:
        candidates = []
  
      # Do we need more? if so, remove the lowest perm active synapses too
      if len(candidates) < numToFree:
        activeSynIndices = [i for i in xrange(len(self.syns))
                            if i not in inactiveSynapseIndices]
        perms = numpy.array([self.syns[i][2] for i in activeSynIndices])
        moreToFree = numToFree - len(candidates)
        moreCandidates = numpy.array(activeSynIndices)[
            perms.argsort()[0:moreToFree]]
        candidates += list(moreCandidates)
  
      if verbosity >= 4:
        print "Deleting %d synapses from segment to make room for new ones:" % (
            len(candidates)), candidates
        print "BEFORE:",
        self.printSegment()
  
      # Free up all the candidates now
      synsToDelete = [self.syns[i] for i in candidates]
      for syn in synsToDelete:
        self.syns.remove(syn)
  
      if verbosity >= 4:
        print "AFTER:",
        self.printSegment()
docs: Free up some synapses in this segment. We always free up inactive
      synapses (lowest permanence freed up first) before we start to free up
      active ones.
  
      @param numToFree              number of synapses to free up
      @param inactiveSynapseIndices list of the inactive synapse indices.