@BetaApi
  public CountTokensResponse countTokens(List<Content> contents) throws IOException {
    checkArgument(contents != null && !contents.isEmpty(), "contents can't be null or empty.");
    CountTokensRequest request =
        CountTokensRequest.newBuilder()
            .setEndpoint(resourceName)
            .setModel(resourceName)
            .addAllContents(contents)
            .build();
    return countTokensFromRequest(request);
  }
Counts tokens in a list of contents.

@param contents a list of {@link com.google.cloud.vertexai.api.Content} to count tokens
@return a {@link com.google.cloud.vertexai.api.CountTokensResponse} instance that contains the
    total tokens and total billable characters of the given list of contents
@throws IOException if an I/O error occurs while making the API call
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/GenerativeModel.java