def __call__(self, text_a, text_b=None):
    if ((text_b is not None) and (len(text_a) != len(text_b))):
        raise ValueError(('text_b %d has different size than text_a %d' % (text_b, text_a)))
    text_a = [(i.encode('utf8') if isinstance(i, six.string_types) else i) for i in text_a]
    if (text_b is not None):
        text_b = [(i.encode('utf8') if isinstance(i, six.string_types) else i) for i in text_b]
    ids_a = map(self.txt_2_id, text_a)
    if (text_b is not None):
        ids_b = map(self.txt_2_id, text_b)
        ret = [util.data.build_2_pair(a, b, self.max_seqlen, self.cls_id, self.sep_id) for (a, b) in zip(ids_a, ids_b)]
    else:
        ret = [util.data.build_1_pair(a, self.max_seqlen, self.cls_id, self.sep_id) for a in ids_a]
    (sen_ids, token_type_ids) = zip(*ret)
    sen_ids = self.pad_and_batch(sen_ids)
    token_type_ids = self.pad_and_batch(token_type_ids)
    (ret,) = super(ErnieClient, self).__call__(sen_ids, token_type_ids)
    return ret
def __call__(self, text_a, text_b=None):
    if ((text_b is not None) and (len(text_a) != len(text_b))):
        raise ValueError(('text_b %d has different size than text_a %d' % (text_b, text_a)))
    text_a = [(i.encode('utf8') if isinstance(i, six.string_types) else i) for i in text_a]
    if (text_b is not None):
        text_b = [(i.encode('utf8') if isinstance(i, six.string_types) else i) for i in text_b]
    ids_a = map(self.txt_2_id, text_a)
    if (text_b is not None):
        ids_b = map(self.txt_2_id, text_b)
        ret = [util.data.build_2_pair(a, b, self.max_seqlen, self.cls_id, self.sep_id) for (a, b) in zip(ids_a, ids_b)]
    else:
        ret = [util.data.build_1_pair(a, self.max_seqlen, self.cls_id, self.sep_id) for a in ids_a]
    (sen_ids, token_type_ids) = zip(*ret)
    sen_ids = self.pad_and_batch(sen_ids)
    token_type_ids = self.pad_and_batch(token_type_ids)
    (ret,) = super(ErnieClient, self).__call__(sen_ids, token_type_ids)
    return ret