def findAcceptablePatterns(tm, t, whichSequence, trainingSequences, nAcceptable = <NUM_LIT:1>):
<EOL>upTo = t + <NUM_LIT:2> <EOL>if tm.doPooling:<EOL><INDENT>upTo += min(tm.segUpdateValidDuration, nAcceptable)<EOL><DEDENT>assert upTo <= len(trainingSequences[whichSequence])<EOL>acceptablePatterns = []<EOL>if len(trainingSequences) == <NUM_LIT:2> and(trainingSequences[<NUM_LIT:0>][<NUM_LIT:0>] == trainingSequences[<NUM_LIT:1>][<NUM_LIT:0>]).all():<EOL><INDENT>if (trainingSequences[<NUM_LIT:0>][t] == trainingSequences[<NUM_LIT:1>][t]).all()and (trainingSequences[<NUM_LIT:0>][t+<NUM_LIT:1>] != trainingSequences[<NUM_LIT:1>][t+<NUM_LIT:1>]).any():<EOL><INDENT>acceptablePatterns.append(trainingSequences[<NUM_LIT:0>][t+<NUM_LIT:1>])<EOL>acceptablePatterns.append(trainingSequences[<NUM_LIT:1>][t+<NUM_LIT:1>])<EOL><DEDENT><DEDENT>acceptablePatterns += [trainingSequences[whichSequence][t]for t in range(t,upTo)]<EOL>return acceptablePatterns<EOL>
Tries to infer the set of acceptable patterns for prediction at the given
time step and for the give sequence. Acceptable patterns are: the current one,
plus a certain number of patterns after timeStep, in the sequence that the TM
is currently tracking. Any other pattern is not acceptable.

TODO:
====
- Doesn't work for noise cases.
- Might run in trouble if shared subsequence at the beginning.

Parameters:
==========
tm                       the whole TM, so that we can look at its parameters
t                        the current time step
whichSequence            the sequence we are currently tracking
trainingSequences        all the training sequences
nAcceptable              the number of steps forward from the current timeStep
                         we are willing to consider acceptable. In the case of
                         pooling, it is less than or equal to the min of the
                         number of training reps and the segUpdateValidDuration
                         parameter of the TM, depending on the test case.
                         The default value is 1, because by default, the pattern
                         after the current one should always be predictable.

Return value:
============
acceptablePatterns       A list of acceptable patterns for prediction.