# Path: tensorlog/config.py
# class Config(object):
# class ConfigHelp(object):
#     def __init__(self):
#     def pprint(self,depth=0):
#     def _explain(self,depth,key,val):
# 
# Path: tensorlog/comline.py
# def parseCommandLine(argv,extraArgConsumer=None,extraArgSpec=[],extraArgUsage=[]):
#     def usage():
#     def status(msg): logging.info('%s time %.3f sec mem %.3f Gb' % (msg,time.time()-startTime,util.memusage()))
# def isUncachefromSrc(s): return s.find("|")>=0
# def getCacheSrcPair(s): return s.split("|")
# def makeCacheSrcPair(s1,s2): return "%s|%s" % (s1,s2)
# def parseDatasetSpec(spec,db):
# def parseDBSpec(spec):
# def parseProgSpec(spec,db,proppr=False):
# 
# Path: tensorlog/dataset.py
# class Dataset(object):
#     def __init__(self,xDict,yDict):
#     def isSinglePredicate(self):
#     def extractMode(self,mode):
#     def modesToLearn(self):
#     def hasMode(self,mode):
#     def getX(self,mode):
#     def getY(self,mode):
#     def size(self):
#     def shuffle(self):
#     def minibatchIterator(self,batchSize=100,shuffleFirst=True):
#     def pprint(self):
#     def serialize(self,dir):
#     def deserialize(dir):
#     def uncacheExamples(dsetFile,db,exampleFile,proppr=True):
#     def uncacheMatrix(dsetFile,db,functorToLearn,functorInDB):
#     def loadMatrix(db,functorToLearn,functorInDB):
#     def _parseLine(line,proppr=True):
#     def loadProPPRExamples(db,fileName):
#     def loadExamples(db,fileName,proppr=False):
#         def getId(typeName,symbol):
#     def saveProPPRExamples(self,fileName,db,append=False,mode=None):
# 
# Path: tensorlog/declare.py
# def asMode(spec):
#     def __init__(self,goal):
#     def args(self):
#     def arg(self,i):
#     def getArity(self):
#     def getFunctor(self):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self,other):
#     def __init__(self,goal,strict=True):
#     def isInput(self,i):
#     def isOutput(self,i):
#     def isConst(self,i):
#     def __str__(self):
#     def __init__(self,goal):
#     def getType(self,i):
#     def typeSet(self):
# class AbstractDeclaration(object):
# class ModeDeclaration(AbstractDeclaration):
# class TypeDeclaration(AbstractDeclaration):
# 
# Path: tensorlog/masterconfig.py
# def masterConfig():
# 
# Path: tensorlog/parser.py
# def isProcessedConstant(a):
# def isProcessedVariable(a):
# def isVariableAtom(a):
#     def __init__(self,functor,args):
#     def _setArgs(self,args):
#     def __str__(self):
#     def __repr__(self):
#     def __init__(self,lhs,rhs,features=None,findall=None):
#     def variabilize(self):
#             def convertArgs(args):
#             def convertGoal(g):
#     def __str__(self):
#     def asString(self,syntax=None):
#     def __init__(self,syntax=None):
#     def _key(self,g):
#     def add(self,r):
#     def size(self):
#     def rulesFor(self,g):
#     def mapRules(self,mapfun):
#     def listing(self):
#     def __iter__(self):
#     def equals(self,other):
#   def __init__(self,syntax=None):
#   def setSyntax(self,syntax):
#   def _convertGoal(self,ptree):
#   def _convertRule(self,ptree):
#   def parseGoal(self,s):
#   def parseGoalList(self,s):
#   def parseRule(self,s):
#   def parseQuery(self,s):
#   def parseFile(self,filename,rules=None):
#   def parseStream(self,fileLike,rules=None):
# class Goal(object):
# class Rule(object):
# class RuleCollection(object):
# class Parser(object):
# 
# Path: tensorlog/version.py
# VERSION = '1.3.6'


import sys
import logging
import collections
from tensorlog import config
from tensorlog import comline
from tensorlog import dataset
from tensorlog import declare
from tensorlog import masterconfig
from tensorlog import parser
from tensorlog import version
  from tensorlog import debug
        result = self.prog.db.rowAsSymbolDict(tmp,typeName=outputType)
        if (self.numTopEcho):
            top = sorted([(key_val[1],key_val[0]) for key_val in list(result.items())], reverse=True)
            for rank in range(min(len(top),self.numTopEcho)):
                print('%d\t%g\t%s' % (rank+1,top[rank][0],top[rank][1]))
        return result

    def debug(self,modeSpec,sym):
      if not DEBUGGER_AVAILABLE:
        logging.warn('debugger is not available in this environment')
        return
      mode = declare.asMode(modeSpec)
      assert self.db.isTypeless(),'cannot debug a db with declared types'
      X = self.db.onehot(sym)
      dset = dataset.Dataset({mode:X},{mode:self.db.zeros()})
      debug.Debugger(self.prog,mode,dset,gradient=False).mainloop()

    def helpConfig(self):
      self.conf.pprint()
      print("To set any option above, use something like: ti.conf.funs.trace = True")

    def debugDset(self,modeSpec,test=False):
      if not DEBUGGER_AVAILABLE:
        logging.warn('debugger is not available in this environment')
        return
      assert self.db.isTypeless(),'cannot debug a db with declared types'
      fullDataset = self.testData if test else self.trainData
      if fullDataset==None:
        print('train/test dataset is not specified on command line?')
      else:

# Path: tensorlog/config.py
# class Config(object):
# class ConfigHelp(object):
#     def __init__(self):
#     def pprint(self,depth=0):
#     def _explain(self,depth,key,val):
# 
# Path: tensorlog/comline.py
# def parseCommandLine(argv,extraArgConsumer=None,extraArgSpec=[],extraArgUsage=[]):
#     def usage():
#     def status(msg): logging.info('%s time %.3f sec mem %.3f Gb' % (msg,time.time()-startTime,util.memusage()))
# def isUncachefromSrc(s): return s.find("|")>=0
# def getCacheSrcPair(s): return s.split("|")
# def makeCacheSrcPair(s1,s2): return "%s|%s" % (s1,s2)
# def parseDatasetSpec(spec,db):
# def parseDBSpec(spec):
# def parseProgSpec(spec,db,proppr=False):
# 
# Path: tensorlog/dataset.py
# class Dataset(object):
#     def __init__(self,xDict,yDict):
#     def isSinglePredicate(self):
#     def extractMode(self,mode):
#     def modesToLearn(self):
#     def hasMode(self,mode):
#     def getX(self,mode):
#     def getY(self,mode):
#     def size(self):
#     def shuffle(self):
#     def minibatchIterator(self,batchSize=100,shuffleFirst=True):
#     def pprint(self):
#     def serialize(self,dir):
#     def deserialize(dir):
#     def uncacheExamples(dsetFile,db,exampleFile,proppr=True):
#     def uncacheMatrix(dsetFile,db,functorToLearn,functorInDB):
#     def loadMatrix(db,functorToLearn,functorInDB):
#     def _parseLine(line,proppr=True):
#     def loadProPPRExamples(db,fileName):
#     def loadExamples(db,fileName,proppr=False):
#         def getId(typeName,symbol):
#     def saveProPPRExamples(self,fileName,db,append=False,mode=None):
# 
# Path: tensorlog/declare.py
# def asMode(spec):
#     def __init__(self,goal):
#     def args(self):
#     def arg(self,i):
#     def getArity(self):
#     def getFunctor(self):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self,other):
#     def __init__(self,goal,strict=True):
#     def isInput(self,i):
#     def isOutput(self,i):
#     def isConst(self,i):
#     def __str__(self):
#     def __init__(self,goal):
#     def getType(self,i):
#     def typeSet(self):
# class AbstractDeclaration(object):
# class ModeDeclaration(AbstractDeclaration):
# class TypeDeclaration(AbstractDeclaration):
# 
# Path: tensorlog/masterconfig.py
# def masterConfig():
# 
# Path: tensorlog/parser.py
# def isProcessedConstant(a):
# def isProcessedVariable(a):
# def isVariableAtom(a):
#     def __init__(self,functor,args):
#     def _setArgs(self,args):
#     def __str__(self):
#     def __repr__(self):
#     def __init__(self,lhs,rhs,features=None,findall=None):
#     def variabilize(self):
#             def convertArgs(args):
#             def convertGoal(g):
#     def __str__(self):
#     def asString(self,syntax=None):
#     def __init__(self,syntax=None):
#     def _key(self,g):
#     def add(self,r):
#     def size(self):
#     def rulesFor(self,g):
#     def mapRules(self,mapfun):
#     def listing(self):
#     def __iter__(self):
#     def equals(self,other):
#   def __init__(self,syntax=None):
#   def setSyntax(self,syntax):
#   def _convertGoal(self,ptree):
#   def _convertRule(self,ptree):
#   def parseGoal(self,s):
#   def parseGoalList(self,s):
#   def parseRule(self,s):
#   def parseQuery(self,s):
#   def parseFile(self,filename,rules=None):
#   def parseStream(self,fileLike,rules=None):
# class Goal(object):
# class Rule(object):
# class RuleCollection(object):
# class Parser(object):
# 
# Path: tensorlog/version.py
# VERSION = '1.3.6'


# Path: tensorlog/interp.py
import sys
import logging
import collections
from tensorlog import config
from tensorlog import comline
from tensorlog import dataset
from tensorlog import declare
from tensorlog import masterconfig
from tensorlog import parser
from tensorlog import version
  from tensorlog import debug

        result = self.prog.db.rowAsSymbolDict(tmp,typeName=outputType)
        if (self.numTopEcho):
            top = sorted([(key_val[1],key_val[0]) for key_val in list(result.items())], reverse=True)
            for rank in range(min(len(top),self.numTopEcho)):
                print('%d\t%g\t%s' % (rank+1,top[rank][0],top[rank][1]))
        return result

    def debug(self,modeSpec,sym):
      if not DEBUGGER_AVAILABLE:
        logging.warn('debugger is not available in this environment')
        return
      mode = declare.asMode(modeSpec)
      assert self.db.isTypeless(),'cannot debug a db with declared types'
      X = self.db.onehot(sym)
      dset = dataset.Dataset({mode:X},{mode:self.db.zeros()})
      debug.Debugger(self.prog,mode,dset,gradient=False).mainloop()

    def helpConfig(self):
      self.conf.pprint()
      print("To set any option above, use something like: ti.conf.funs.trace = True")

    def debugDset(self,modeSpec,test=False):
      if not DEBUGGER_AVAILABLE:
        logging.warn('debugger is not available in this environment')
        return
      assert self.db.isTypeless(),'cannot debug a db with declared types'
      fullDataset = self.testData if test else self.trainData
      if fullDataset==None:
        print('train/test dataset is not specified on command line?')
      else:

        mode = declare.asMode(modeSpec)