code: def _learn(# mutated args
               permanences, rng,
  
               # activity
               activeCells, activeInput, growthCandidateInput,
  
               # configuration
               sampleSize, initialPermanence, permanenceIncrement,
               permanenceDecrement, connectedPermanence):
      
  
      permanences.incrementNonZerosOnOuter(
        activeCells, activeInput, permanenceIncrement)
      permanences.incrementNonZerosOnRowsExcludingCols(
        activeCells, activeInput, -permanenceDecrement)
      permanences.clipRowsBelowAndAbove(
        activeCells, 0.0, 1.0)
      if sampleSize == -1:
        permanences.setZerosOnOuter(
          activeCells, activeInput, initialPermanence)
      else:
        existingSynapseCounts = permanences.nNonZerosPerRowOnCols(
          activeCells, activeInput)
  
        maxNewByCell = numpy.empty(len(activeCells), dtype="int32")
        numpy.subtract(sampleSize, existingSynapseCounts, out=maxNewByCell)
  
        permanences.setRandomZerosOnOuter(
          activeCells, growthCandidateInput, maxNewByCell, initialPermanence, rng)
docs: For each active cell, reinforce active synapses, punish inactive synapses,
      and grow new synapses to a subset of the active input bits that the cell
      isn't already connected to.
  
      Parameters:
      ----------------------------
      @param  permanences (SparseMatrix)
              Matrix of permanences, with cells as rows and inputs as columns
  
      @param  rng (Random)
              Random number generator
  
      @param  activeCells (sorted sequence)
              Sorted list of the cells that are learning
  
      @param  activeInput (sorted sequence)
              Sorted list of active bits in the input
  
      @param  growthCandidateInput (sorted sequence)
              Sorted list of active bits in the input that the activeCells may
              grow new synapses to
  
      For remaining parameters, see the __init__ docstring.