def METHOD_NAME(self, text: str, truncation: bool = False, max_length: Optional[int] = None) -> EncodeResult:
    """
    Encodes the input text to tokens.
    """
    if max_length is None:
        max_length = self.max_request_length
    response: TokenizationRequestResult
    tokens: List[TokenizationToken] = []
    if truncation or len(text) <= CohereClient.TOKENIZE_API_MAX_TEXT_LENGTH:
        response = self.service.tokenize(
            TokenizationRequest(
                text,
                tokenizer=self.tokenizer_name,
                # The Cohere API does not support decoding, so set `encode` to False to get the value of tokens
                # as strings so we can simply concatenate them when we need to decode.
                METHOD_NAME=False,
                truncation=truncation,
                max_length=max_length,
            )
        )
        tokens = response.tokens
    else:
        # Perform chunk encoding: Cohere doesn't support long sequences, so break it up into chunks
        # and make a request for each chunk.
        # This can potentially break up valid tokens at the end of the chunk, but the chunk size
        # is large enough that this happens infrequently.
        chunk_size: int = CohereClient.TOKENIZE_API_MAX_TEXT_LENGTH
        for i in range(0, len(text), chunk_size):
            chunk: str = text[i : chunk_size + i]
            response = self.service.tokenize(
                TokenizationRequest(chunk, tokenizer=self.tokenizer_name, METHOD_NAME=False, truncation=False)
            )
            tokens.extend(response.tokens)
    return EncodeResult(text=text, tokens=tokens)