class_docstr: A wrapper class for openai client.
docstr: Update the usage summary.
  
  Usage is calculated no matter filter is passed or not.
docstr_tok: ["Update","the","usage","summary",".","Usage","is","calculated","no","matter","filter","is","passed","or","not","."]
code: def _update_usage_summary(
      self, response: Union[ChatCompletion, Completion], use_cache: bool
  ) -> None:
      """Update the usage summary.
  
      Usage is calculated no matter filter is passed or not.
      """
      try:
          usage = response.usage
          assert usage is not None
          usage.prompt_tokens = (
              0 if usage.prompt_tokens is None else usage.prompt_tokens
          )
          usage.completion_tokens = (
              0
              if usage.completion_tokens is None
              else usage.completion_tokens
          )
          usage.total_tokens = (
              0 if usage.total_tokens is None else usage.total_tokens
          )
      except (AttributeError, AssertionError):
          logger.debug(
              "Usage attribute is not found in the response.",
              exc_info=True,
          )
          return
  
      def update_usage(
          usage_summary: Optional[Dict[str, Any]]
      ) -> Dict[str, Any]:
          if usage_summary is None:
              usage_summary = {"total_cost": response.cost}  # type: ignore [union-attr]
          else:
              usage_summary["total_cost"] += response.cost  # type: ignore [union-attr]
  
          usage_summary[response.model] = {
              "cost": usage_summary.get(response.model, {}).get("cost", 0) + response.cost,  # type: ignore [union-attr]
              "prompt_tokens": usage_summary.get(
                  response.model, {}
              ).get("prompt_tokens", 0)
              + usage.prompt_tokens,
              "completion_tokens": usage_summary.get(
                  response.model, {}
              ).get("completion_tokens", 0)
              + usage.completion_tokens,
              "total_tokens": usage_summary.get(response.model, {}).get(
                  "total_tokens", 0
              )
              + usage.total_tokens,
          }
          return usage_summary
  
      self.total_usage_summary = update_usage(self.total_usage_summary)
      if not use_cache:
          self.actual_usage_summary = update_usage(
              self.actual_usage_summary
          )
  
imports: from __future__ import annotations
  import os
  import sys
  from typing import Any, List, Optional, Dict, Callable, Tuple, Union
  import logging
  import inspect
  from flaml.automl.logger import logger_formatter
  from pydantic import BaseModel
  from autogen.oai import completion
  from autogen.oai.openai_utils import DEFAULT_AZURE_API_VERSION, get_key, OAI_PRICE1K
  from autogen.token_count_utils import count_token
  from autogen._pydantic import model_dump
label_desc: Use image node_id 12 for calling the OpenAIWrapper obj's underlying member method code with example usage: obj._update_usage_summary(response, use_cache) and returns: usage_summary