def decode_to_str(batch_text, max_len=512) :
    """
    Converts bytes string data to text. And truncates to max_len. 
    """
    return [ ' '.join(text.decode('utf-8').split()[:max_len]) if isinstance(text, bytes) else text[:max_len]
             for text in batch_text ]