nodes: 0, module; 1, function_definition; 2, function_name:compute; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, if_statement; 13, comment:# inference step; 14, if_statement; 15, identifier:feedforwardInput; 16, tuple; 17, identifier:lateralInputs; 18, tuple; 19, identifier:feedforwardGrowthCandidates; 20, None; 21, identifier:learn; 22, True; 23, identifier:predictedInput; 24, None; 25, comment:"""
      Runs one time step of the column pooler algorithm.
  
      @param  feedforwardInput (sequence)
              Sorted indices of active feedforward input bits
  
      @param  lateralInputs (list of sequences)
              For each lateral layer, a list of sorted indices of active lateral
              input bits
  
      @param  feedforwardGrowthCandidates (sequence or None)
              Sorted indices of feedforward input bits that active cells may grow
              new synapses to. If None, the entire feedforwardInput is used.
  
      @param  learn (bool)
              If True, we are learning a new object
  
      @param predictedInput (sequence)
             Sorted indices of predicted cells in the TM layer.
      """; 26, comparison_operator:feedforwardGrowthCandidates is None; 27, block; 28, not_operator; 29, block; 30, comment:# learning step; 31, elif_clause; 32, comment:# online learning step; 33, else_clause; 34, identifier:feedforwardGrowthCandidates; 35, None; 36, expression_statement; 37, identifier:learn; 38, expression_statement; 39, not_operator; 40, block; 41, block; 42, assignment; 43, call; 44, attribute; 45, expression_statement; 46, if_statement; 47, identifier:feedforwardGrowthCandidates; 48, identifier:feedforwardInput; 49, attribute; 50, argument_list; 51, identifier:self; 52, identifier:onlineLearning; 53, call; 54, parenthesized_expression; 55, block; 56, elif_clause; 57, else_clause; 58, identifier:self; 59, identifier:_computeInferenceMode; 60, identifier:feedforwardInput; 61, identifier:lateralInputs; 62, attribute; 63, argument_list; 64, boolean_operator; 65, expression_statement; 66, expression_statement; 67, expression_statement; 68, expression_statement; 69, not_operator; 70, comment:# If the pooler doesn't have a single representation, try to infer one,; 71, comment:# before actually attempting to learn.; 72, block; 73, comment:# If there isn't predicted input and we have a single SDR,; 74, comment:# we are extending that representation and should just learn.; 75, block; 76, identifier:self; 77, identifier:_computeLearningMode; 78, identifier:feedforwardInput; 79, identifier:lateralInputs; 80, identifier:feedforwardGrowthCandidates; 81, comparison_operator:predictedInput is not None; 82, comparison_operator:len(predictedInput) > self.predictedInhibitionThreshold; 83, assignment; 84, assignment; 85, call; 86, call; 87, comparison_operator:self.minSdrSize <= len(self.activeCells) <= self.maxSdrSize; 88, expression_statement; 89, expression_statement; 90, expression_statement; 91, identifier:predictedInput; 92, None; 93, call; 94, attribute; 95, identifier:predictedActiveInput; 96, call; 97, identifier:predictedGrowthCandidates; 98, call; 99, attribute; 100, argument_list; 101, attribute; 102, argument_list; 103, attribute; 104, call; 105, attribute; 106, call; 107, call; 108, call; 109, identifier:len; 110, argument_list; 111, identifier:self; 112, identifier:predictedInhibitionThreshold; 113, attribute; 114, argument_list; 115, attribute; 116, argument_list; 117, identifier:self; 118, identifier:_computeInferenceMode; 119, identifier:predictedActiveInput; 120, identifier:lateralInputs; 121, identifier:self; 122, identifier:_computeLearningMode; 123, identifier:predictedActiveInput; 124, identifier:lateralInputs; 125, identifier:feedforwardGrowthCandidates; 126, identifier:self; 127, identifier:minSdrSize; 128, identifier:len; 129, argument_list; 130, identifier:self; 131, identifier:maxSdrSize; 132, attribute; 133, argument_list; 134, attribute; 135, argument_list; 136, attribute; 137, argument_list; 138, identifier:predictedInput; 139, identifier:numpy; 140, identifier:intersect1d; 141, identifier:feedforwardInput; 142, identifier:predictedInput; 143, identifier:numpy; 144, identifier:intersect1d; 145, identifier:feedforwardGrowthCandidates; 146, identifier:predictedInput; 147, attribute; 148, identifier:self; 149, identifier:_computeInferenceMode; 150, identifier:feedforwardInput; 151, identifier:lateralInputs; 152, identifier:self; 153, identifier:_computeLearningMode; 154, identifier:feedforwardInput; 155, identifier:lateralInputs; 156, identifier:feedforwardGrowthCandidates; 157, identifier:self; 158, identifier:_computeLearningMode; 159, identifier:feedforwardInput; 160, identifier:lateralInputs; 161, identifier:feedforwardGrowthCandidates; 162, identifier:self; 163, identifier:activeCells
code: def compute(self, feedforwardInput=(), lateralInputs=(),
                feedforwardGrowthCandidates=None, learn=True,
                predictedInput = None,):
      """
      Runs one time step of the column pooler algorithm.
  
      @param  feedforwardInput (sequence)
              Sorted indices of active feedforward input bits
  
      @param  lateralInputs (list of sequences)
              For each lateral layer, a list of sorted indices of active lateral
              input bits
  
      @param  feedforwardGrowthCandidates (sequence or None)
              Sorted indices of feedforward input bits that active cells may grow
              new synapses to. If None, the entire feedforwardInput is used.
  
      @param  learn (bool)
              If True, we are learning a new object
  
      @param predictedInput (sequence)
             Sorted indices of predicted cells in the TM layer.
      """
  
      if feedforwardGrowthCandidates is None:
        feedforwardGrowthCandidates = feedforwardInput
  
      # inference step
      if not learn:
        self._computeInferenceMode(feedforwardInput, lateralInputs)
  
      # learning step
      elif not self.onlineLearning:
        self._computeLearningMode(feedforwardInput, lateralInputs,
                                  feedforwardGrowthCandidates)
      # online learning step
      else:
        if (predictedInput is not None and
            len(predictedInput) > self.predictedInhibitionThreshold):
          predictedActiveInput = numpy.intersect1d(feedforwardInput,
                                                   predictedInput)
          predictedGrowthCandidates = numpy.intersect1d(
              feedforwardGrowthCandidates, predictedInput)
          self._computeInferenceMode(predictedActiveInput, lateralInputs)
          self._computeLearningMode(predictedActiveInput, lateralInputs,
                                    feedforwardGrowthCandidates)
        elif not self.minSdrSize <= len(self.activeCells) <= self.maxSdrSize:
          # If the pooler doesn't have a single representation, try to infer one,
          # before actually attempting to learn.
          self._computeInferenceMode(feedforwardInput, lateralInputs)
          self._computeLearningMode(feedforwardInput, lateralInputs,
                                    feedforwardGrowthCandidates)
        else:
          # If there isn't predicted input and we have a single SDR,
          # we are extending that representation and should just learn.
          self._computeLearningMode(feedforwardInput, lateralInputs,
                                    feedforwardGrowthCandidates)