//  [python]
def inference(self, returnData=False):
        #run through the specified dataset a single time and return the outputs
        infOut = {}
        infOut['logits'] = []
        infOut['logitLengths'] = []
        infOut['decodedSeqs'] = []
        infOut['editDistances'] = []
        infOut['trueSeqLengths'] = []
        infOut['trueSeqs'] = []
        infOut['transcriptions'] = []
        infOut['seqErrorRate'] = []
        allData = []

        for datasetIdx, valProb in enumerate(self.args['dataset']['datasetProbabilityVal']):
            if valProb <= 0:
                continue

            layerIdx = self.args['dataset']['datasetToLayerMap'][datasetIdx]

            for data in self.tfValDatasets[datasetIdx]:
                out = self._valStep(data, layerIdx)

                infOut['logits'].append(out['logits'].numpy())
                if self.args['lossType'] == 'ctc':
                    infOut['editDistances'].append(out['editDistance'].numpy())
                elif self.args['lossType'] == 'ce':
                    infOut['seqErrorRate'].append(out['seqErrorRate'].numpy())
                infOut['trueSeqLengths'].append(out['nSeqElements'].numpy())
                infOut['logitLengths'].append(out['logitLengths'].numpy())
                infOut['trueSeqs'].append(out['trueSeq'].numpy()-1)

                tmp = tf.sparse.to_dense(
                    out['decodedStrings'][0], default_value=-1).numpy()
                paddedMat = np.zeros(
                    [tmp.shape[0], self.args['dataset']['maxSeqElements']]).astype(np.int32)-1
                end = min(tmp.shape[1], self.args['dataset']['maxSeqElements'])
                paddedMat[:, :end] = tmp[:, :end]
                infOut['decodedSeqs'].append(paddedMat)

                infOut['transcriptions'].append(out['transcription'].numpy())

                if returnData:
                    allData.append(data)

        # Logits have different length
        infOut['logits'] = [l for batch in infOut['logits'] for l in list(batch)]
        maxLogitLength = max([l.shape[0] for l in infOut['logits']])
        infOut['logits'] = [np.pad(l, [[0, maxLogitLength-l.shape[0]], [0, 0]]) for l in infOut['logits']]
        infOut['logits'] = np.stack(infOut['logits'], axis=0)
        infOut['logitLengths'] = np.concatenate(infOut['logitLengths'], axis=0)
        infOut['decodedSeqs'] = np.concatenate(infOut['decodedSeqs'], axis=0)
        if self.args['lossType'] == 'ctc':
            infOut['editDistances'] = np.concatenate(
                infOut['editDistances'], axis=0)
        elif self.args['lossType'] == 'ce':
            infOut['seqErrorRate'] = np.concatenate(np.array(infOut['seqErrorRate'])[tf.newaxis,:], axis=0)
        infOut['trueSeqLengths'] = np.concatenate(
            infOut['trueSeqLengths'], axis=0)
        infOut['trueSeqs'] = np.concatenate(infOut['trueSeqs'], axis=0)
        infOut['transcriptions'] = np.concatenate(
            infOut['transcriptions'], axis=0)

        if self.args['lossType'] == 'ctc':
            infOut['cer'] = np.sum(infOut['editDistances']) / float(np.sum(infOut['trueSeqLengths']))
        elif self.args['lossType'] == 'ce':
            infOut['cer'] = infOut['seqErrorRate']

        if returnData:
            return infOut, allData
        else:
            return infOut