code: def tokenize(
      self, request: TokenizationRequest
  ) -> TokenizationRequestResult:
      text: str = request.text
      assert (
          1 <= len(text) <= CohereClient.TOKENIZE_API_MAX_TEXT_LENGTH
      ), f"Invalid text length: {len(text)}. Valid length: [1..{CohereClient.TOKENIZE_API_MAX_TEXT_LENGTH:,d}]"
      raw_request: Dict[str, str] = {"text": text}
  
      try:
  
          def do_it():
              """
              Send the request to the Cohere Tokenize API.
  
              From https://docs.cohere.ai/tokenize-reference, for text "tokenize me! :D", the response will be:
  
              {
                  "tokens": [34160, 974, 514, 34, 1420, 69]
                  "token_strings": ["token", "ize", " me", "!", " :", "D"]
              }
              """
              response = requests.request(
                  method="POST",
                  url=CohereClient.get_url(
                      CohereClient.TOKENIZE_ENDPOINT
                  ),
                  headers={
                      "Authorization": f"BEARER {self.api_key}",
                      "Content-Type": "application/json",
                      "Cohere-Version": CohereClient.DEFAULT_API_VERSION,
                  },
                  data=json.dumps(raw_request),
              )
              result = json.loads(response.text)
              assert (
                  "message" not in result.keys()
              ), f"Request failed with error {result['message']}"
              assert (
                  "tokens" in result and "token_strings" in result
              ), f"Invalid response: {result}"
              return result
  
          response, cached = self.cache.get(
              raw_request, wrap_request_time(do_it)
          )
      except (
          requests.exceptions.RequestException,
          AssertionError,
      ) as e:
          error: str = f"CohereClient error: {e}"
          return TokenizationRequestResult(
              error=error,
              success=False,
              cached=False,
              text="",
              tokens=[],
          )
  
      tokens = response["tokens" if request.encode else "token_strings"]
      if request.truncation:
          tokens = tokens[: request.max_length]
  
      return TokenizationRequestResult(
          success=True,
          cached=cached,
          tokens=[TokenizationToken(value) for value in tokens],
          text=text,
          request_time=response["request_time"],
      )
  
file_path: H2O/h2o_hf/helm/src/helm/proxy/clients/cohere_client.py
imports: import json
  import requests
  from typing import List, Dict
  from urllib.parse import urljoin
  from helm.common.cache import Cache, CacheConfig
  from helm.common.request import EMBEDDING_UNAVAILABLE_REQUEST_RESULT, Request, RequestResult, Sequence, Token
  from helm.common.tokenization_request import TokenizationRequest, TokenizationRequestResult, DecodeRequest, DecodeRequestResult, TokenizationToken
  from helm.proxy.models import get_models_by_organization
  from .client import Client, wrap_request_time, truncate_sequence
label_desc: Use image node_id 4 for calling the CohereClient obj's underlying member method code with example usage: obj.tokenize(request) and returns: TokenizationRequestResult, result, TokenizationRequestResult