def to_tokens(self, indices):
to_reduce = False<EOL>if not isinstance(indices, (list, tuple)):<EOL><INDENT>indices = [indices]<EOL>to_reduce = True<EOL><DEDENT>max_idx = len(self._idx_to_token) - <NUM_LIT:1><EOL>tokens = []<EOL>for idx in indices:<EOL><INDENT>if not isinstance(idx, int) or idx > max_idx:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(idx))<EOL><DEDENT>else:<EOL><INDENT>tokens.append(self._idx_to_token[idx])<EOL><DEDENT><DEDENT>return tokens[<NUM_LIT:0>] if to_reduce else tokens<EOL>
Converts token indices to tokens according to the vocabulary.


        Parameters
        ----------
        indices : int or list of ints
            A source token index or token indices to be converted.


        Returns
        -------
        str or list of strs
            A token or a list of tokens according to the vocabulary.