code: def ToByteArray(self):
          
          ms = StreamManager.GetStream()
          writer = BinaryWriter(ms)
          self.Serialize(writer)
  
          retval = ms.ToArray()
          StreamManager.ReleaseStream(ms)
  
          return retval
docs: Serialize self and get the byte stream.
  
          Returns:
              bytes: serialized object.