code: def _trim_and_decode(ids, subtokenizer):
    
    try:
      index = list(ids).index(tokenizer.EOS_ID)
      return subtokenizer.decode(ids[:index])
    except ValueError:  # No EOS found in sequence
      return subtokenizer.decode(ids)
docs: Trim EOS and PAD tokens from ids, and decode to return a string.