class_docstr: Abstract class for text-based metrics calculated based on
  hypotheses and references. Subclasses must implement `metric_fn`.
  
  Args:
    name: A name for the metric
    separator: A separator used to join predicted tokens. Default to space.
    eos_token: A string token used to find the end of a sequence. Hypotheses
      and references will be slcied until this token is found.
class_docstr_tok: ["Abstract","class","for","text-based","metrics","calculated","based","on","hypotheses","and","references",".","Subclasses","must","implement","`","metric_fn","`",".","Args",":","name",":","A","name","for","the","metric","separator",":","A","separator","used","to","join","predicted","tokens",".","Default","to","space",".","eos_token",":","A","string","token","used","to","find","the","end","of","a","sequence",".","Hypotheses","and","references","will","be","slcied","until","this","token","is","found","."]
docstr: Wrapper function that converts tensors to unicode and slices
  them until the EOS token is found.
docstr_tok: ["Wrapper","function","that","converts","tensors","to","unicode","and","slices","them","until","the","EOS","token","is","found","."]
code: def _py_func(self, hypotheses, references):
      """Wrapper function that converts tensors to unicode and slices
      them until the EOS token is found.
      """
      # Deal with byte chars
      if hypotheses.dtype.kind == np.dtype("U"):
          hypotheses = np.char.encode(hypotheses, "utf-8")
      if references.dtype.kind == np.dtype("U"):
          references = np.char.encode(references, "utf-8")
  
      # Convert back to unicode object
      hypotheses = [_.decode("utf-8") for _ in hypotheses]
      references = [_.decode("utf-8") for _ in references]
  
      # Slice all hypotheses and references up to SOS -> EOS
      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
      ]
  
      # Apply postprocessing function
      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)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from pydoc import locate
  import abc
  import numpy
  import six
  import tensorflow
  from tensorflow.contrib import metrics
  from tensorflow.contrib.learn import MetricSpec
  from seq2seq.data import postproc
  from seq2seq.configurable import Configurable
  from seq2seq.metrics import rouge
  from seq2seq.metrics import bleu
label_desc: Use image node_id 5 for calling the TextMetricSpec obj's underlying member method code with example usage: obj._py_func(hypotheses, references) and returns: self