class_docstr: Legacy client for the Anthropic models (https://arxiv.org/abs/2204.05862).
  This was used before they officially released their API on March 17, 2023.
  They used their own version of the GPT-2 tokenizer.
  
  The Anthropic API is not production-ready and currently does not support:
  - Top k per token
  - Multiple completions
  - Echo prompt
  - Log probabilities
docstr: Get the token log probs and top candidates for a given text using the endpoint: topk_logprobs.
docstr_tok: ["Get","the","token","log","probs","and","top","candidates","for","a","given","text","using","the","endpoint",":","topk_logprobs","."]
code: def make_logprobs_request(
      self, text: str, top_k_per_token: int, model_engine: str
  ) -> Dict[str, List[Any]]:
      """
      Get the token log probs and top candidates for a given text using the endpoint: topk_logprobs.
      """
      # Sending an empty string results in 'non cancel Cannot evaluate top logprobs of empty string' error
      if len(text) == 0:
          return AnthropicLegacyClient.EMPTY_LOGPROBS_RESPONSE
  
      raw_response: str
  
      try:
          logprobs_response = requests.request(
              method="POST",
              url=f"https://{AnthropicLegacyClient.BASE_ENDPOINT}/model/{model_engine}/"
              f"{AnthropicLegacyClient.TOP_K_LOGPROBS_ENDPOINT}",
              headers={
                  "Authorization": f"BEARER {self.api_key}",
                  "Content-Type": "application/json",
              },
              data=json.dumps(
                  {
                      "q": text,
                      "k": top_k_per_token,
                      "is_replicated": True,
                  }
              ),
          )
          raw_response = logprobs_response.text
      except requests.exceptions.RequestException as error:
          hlog(str(error))
          raise AnthropicRequestError(
              f"Anthropic {AnthropicLegacyClient.TOP_K_LOGPROBS_ENDPOINT} error: {str(error)}"
          )
  
      if not AnthropicLegacyClient.is_valid_logprobs_response(
          raw_response
      ):
          raise AnthropicRequestError(
              f"Invalid logprobs response: {raw_response}"
          )
      return json.loads(raw_response)
  
imports: from typing import Any, Dict, List, Optional
  import json
  import requests
  import time
  import urllib.parse
  import websocket
  import anthropic
  from helm.common.cache import Cache, CacheConfig
  from helm.common.hierarchical_logger import htrack_block, hlog
  from helm.common.request import EMBEDDING_UNAVAILABLE_REQUEST_RESULT, Request, RequestResult, Sequence, Token, ErrorFlags
  from helm.common.tokenization_request import TokenizationRequest, TokenizationRequestResult, DecodeRequest, DecodeRequestResult, TokenizationToken
  from .client import Client, wrap_request_time, truncate_sequence
  from transformers import PreTrainedTokenizerBase, PreTrainedTokenizerFast
  from dataclasses import asdict
label_desc: Use image node_id 4 for calling the AnthropicLegacyClient obj's underlying member method code with example usage: obj.make_logprobs_request(text, top_k_per_token, model_engine) and returns: json, AnthropicLegacyClient