class_docstr: Two-gram benchmark model.
  
  :param inferenceType: (:class:`nupic.frameworks.opf.opf_utils.InferenceType`)
  :param encoders: a dict of dicts, eventually sent to
         :meth:`~nupic.encoders.multi.MultiEncoder.addMultipleEncoders` (see
         docs of that method for param details).
code: def run(self, inputRecord):
      results = super(TwoGramModel, self).run(inputRecord)
  
      # Set up the lists of values, defaults, and encoded values.
      values = [inputRecord[k] for k in self._fieldNames]
      defaults = ["" if type(v) == str else 0 for v in values]
      inputFieldEncodings = self._encoder.encodeEachField(inputRecord)
      inputBuckets = self._encoder.getBucketIndices(inputRecord)
  
      results.sensorInput = opf_utils.SensorInput(
          dataRow=values,
          dataEncodings=inputFieldEncodings,
          sequenceReset=int(self._reset),
      )
  
      # Keep track of the last value associated with each encoded value for that
      # predictions can be returned in the original value format.
      for value, bucket in itertools.izip(values, inputBuckets):
          self._hashToValueDict[bucket] = value
  
      # Update the two-gram dict if learning is enabled.
      for bucket, prevValue, twoGramDict in itertools.izip(
          inputBuckets, self._prevValues, self._twoGramDicts
      ):
          if self._learningEnabled and not self._reset:
              if prevValue not in twoGramDict:
                  twoGramDict[prevValue] = collections.defaultdict(int)
              twoGramDict[prevValue][bucket] += 1
  
      # Populate the results.inferences dict with the predictions and encoded
      # predictions.
      predictions = []
      encodedPredictions = []
      for bucket, twoGramDict, default, fieldName in itertools.izip(
          inputBuckets, self._twoGramDicts, defaults, self._fieldNames
      ):
          if bucket in twoGramDict:
              probabilities = twoGramDict[bucket].items()
              prediction = self._hashToValueDict[
                  max(probabilities, key=lambda x: x[1])[0]
              ]
              predictions.append(prediction)
              encodedPredictions.append(
                  self._encoder.encodeField(fieldName, prediction)
              )
          else:
              predictions.append(default)
              encodedPredictions.append(
                  self._encoder.encodeField(fieldName, default)
              )
      results.inferences = dict()
      results.inferences[
          opf_utils.InferenceElement.prediction
      ] = predictions
      results.inferences[
          opf_utils.InferenceElement.encodings
      ] = encodedPredictions
  
      self._prevValues = inputBuckets
      self._reset = False
      return results
  
imports: import collections
  import itertools
  from nupic import encoders
  from nupic.data import field_meta
  from nupic.frameworks.opf import model
  from nupic.frameworks.opf import opf_utils
  from opf_utils import InferenceType
label_desc: Use image node_id 2 for calling the TwoGramModel obj's underlying member method code with example usage: obj.run(inputRecord) and returns: results