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).
docstr: :param proto: capnp TwoGramModelProto message builder
docstr_tok: [":","param","proto",":","capnp","TwoGramModelProto","message","builder"]
code: def write(self, proto):
      """
      :param proto: capnp TwoGramModelProto message builder
      """
      super(TwoGramModel, self).writeBaseToProto(proto.modelBase)
  
      proto.reset = self._reset
      proto.learningEnabled = self._learningEnabled
      proto.prevValues = self._prevValues
      self._encoder.write(proto.encoder)
      proto.hashToValueDict = [
          {"hash": h, "value": v}
          for h, v in self._hashToValueDict.items()
      ]
  
      twoGramDicts = []
      for items in self._twoGramDicts:
          twoGramArr = []
          for prev, values in items.iteritems():
              buckets = [
                  {"index": index, "count": count}
                  for index, count in values.iteritems()
              ]
              if prev is None:
                  prev = -1
              twoGramArr.append({"value": prev, "buckets": buckets})
  
          twoGramDicts.append(twoGramArr)
  
      proto.twoGramDicts = twoGramDicts
  
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 11 for calling the TwoGramModel obj's underlying member method code with example usage: obj.write(proto) without return types