'Wrapper function that converts tensors to unicode and slices
them until the EOS token is found.'

def _py_func(self, hypotheses, references):

    if (hypotheses.dtype.kind == np.dtype(u'U')):
        hypotheses = np.char.encode(hypotheses, u'utf-8')
    if (references.dtype.kind == np.dtype(u'U')):
        references = np.char.encode(references, u'utf-8')
    hypotheses = [_.decode(u'utf-8') for _ in hypotheses]
    references = [_.decode(u'utf-8') for _ in references]
    sliced_hypotheses = [postproc.slice_text(_, self._eos_token, self._sos_token) for _ in hypotheses]
    sliced_references = [postproc.slice_text(_, self._eos_token, self._sos_token) for _ in references]
    if self._postproc_fn:
        sliced_hypotheses = [self._postproc_fn(_) for _ in sliced_hypotheses]
        sliced_references = [self._postproc_fn(_) for _ in sliced_references]
    return self.metric_fn(sliced_hypotheses, sliced_references)
