def _computeTMMetric(tm=None, sequences=None, useResets=True, verbosity=<NUM_LIT:1>):
datasetScore = <NUM_LIT:0><EOL>numPredictions = <NUM_LIT:0><EOL>tm.resetStats()<EOL>for seqIdx, seq in enumerate(sequences):<EOL><INDENT>if useResets:<EOL><INDENT>tm.reset()<EOL><DEDENT>seq = numpy.array(seq, dtype='<STR_LIT>')<EOL>if verbosity > <NUM_LIT:2>:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>for i, inputPattern in enumerate(seq):<EOL><INDENT>if verbosity > <NUM_LIT:2>:<EOL><INDENT>print("<STR_LIT>" % (seqIdx, i), end='<STR_LIT:U+0020>')<EOL>print("<STR_LIT>", inputPattern)<EOL><DEDENT>y = tm.infer(inputPattern)<EOL>if verbosity > <NUM_LIT:2>:<EOL><INDENT>stats = tm.getStats()<EOL>if stats['<STR_LIT>'] > <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>", stats['<STR_LIT>'])<EOL><DEDENT><DEDENT>if verbosity > <NUM_LIT:3>:<EOL><INDENT>print("<STR_LIT>")<EOL>predOut = numpy.sum(tm.predictedState['<STR_LIT:t>'], axis=<NUM_LIT:1>)<EOL>actOut  = numpy.sum(tm.activeState['<STR_LIT:t>'], axis=<NUM_LIT:1>)<EOL>outout  = numpy.sum(y.reshape(tm.activeState['<STR_LIT:t>'].shape), axis=<NUM_LIT:1>)<EOL>print("<STR_LIT>", predOut.nonzero())<EOL>print("<STR_LIT>", actOut.nonzero())<EOL>print("<STR_LIT>", inputPattern.nonzero())<EOL>print("<STR_LIT>", outout.nonzero())<EOL><DEDENT><DEDENT><DEDENT>stats = tm.getStats()<EOL>datasetScore = stats['<STR_LIT>']<EOL>numPredictions = stats['<STR_LIT>']<EOL>print("<STR_LIT>", datasetScore, end='<STR_LIT:U+0020>')<EOL>print("<STR_LIT>", numPredictions)<EOL>return datasetScore, numPredictions<EOL>
Given a trained TM and a list of sequences, compute the temporal memory
    performance metric on those sequences.

    Parameters:
    ===========
    tm:               A trained temporal memory.
    sequences:        A list of sequences. Each sequence is a list of numpy
                      vectors.
    useResets:        If True, the TM's reset method will be called before the
                      the start of each new sequence.
    verbosity:        An integer controlling the level of printouts. The higher
                      the number the more debug printouts.

    Return value:
    ============
    The following pair is returned:  (score, numPredictions)

    score:            The average prediction score per pattern.
    numPredictions:   The total number of predictions that were made.