code: def _learnOnNewSegments(connections, rng, newSegmentCells, growthCandidates,
                            initialPermanence, sampleSize, maxSynapsesPerSegment):
      
  
      numNewSynapses = len(growthCandidates)
  
      if sampleSize != -1:
        numNewSynapses = min(numNewSynapses, sampleSize)
  
      if maxSynapsesPerSegment != -1:
        numNewSynapses = min(numNewSynapses, maxSynapsesPerSegment)
  
      newSegments = connections.createSegments(newSegmentCells)
      connections.growSynapsesToSample(newSegments, growthCandidates,
                                       numNewSynapses, initialPermanence,
                                       rng)
docs: Create new segments, and grow synapses on them.
  
      @param connections (SparseMatrixConnections)
      @param rng (Random)
      @param newSegmentCells (numpy array)
      @param growthCandidates (numpy array)