class_docstr: Initialize a new Inference Client.
  
  [`InferenceClient`] aims to provide a unified experience to perform inference. The client can be used
  seamlessly with either the (free) Inference API or self-hosted Inference Endpoints.
  
  Args:
      model (`str`, `optional`):
          The model to run inference with. Can be a model id hosted on the Hugging Face Hub, e.g. `bigcode/starcoder`
          or a URL to a deployed Inference Endpoint. Defaults to None, in which case a recommended model is
          automatically selected for the task.
      token (`str`, *optional*):
          Hugging Face token. Will default to the locally saved token. Pass `token=False` if you don't want to send
          your token to the server.
      timeout (`float`, `optional`):
          The maximum number of seconds to wait for a response from the server. Loading a new model in Inference
          API can take up to several minutes. Defaults to None, meaning it will loop until the server is available.
      headers (`Dict[str, str]`, `optional`):
          Additional headers to send to the server. By default only the authorization and user-agent headers are sent.
          Values in this dictionary will override the default values.
      cookies (`Dict[str, str]`, `optional`):
          Additional cookies to send to the server.
docstr: Make a POST request to the inference server.
  
  Args:
      json (`Union[str, Dict, List]`, *optional*):
          The JSON data to send in the request body, specific to each task. Defaults to None.
      data (`Union[str, Path, bytes, BinaryIO]`, *optional*):
          The content to send in the request body, specific to each task.
          It can be raw bytes, a pointer to an opened file, a local file path,
          or a URL to an online resource (image, audio file,...). If both `json` and `data` are passed,
          `data` will take precedence. At least `json` or `data` must be provided. Defaults to None.
      model (`str`, *optional*):
          The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
          Inference Endpoint. Will override the model defined at the instance level. Defaults to None.
      task (`str`, *optional*):
          The task to perform on the inference. All available tasks can be found
          [here](https://huggingface.co/tasks). Used only to default to a recommended model if `model` is not
          provided. At least `model` or `task` must be provided. Defaults to None.
      stream (`bool`, *optional*):
          Whether to iterate over streaming APIs.
  
  Returns:
      bytes: The raw bytes returned by the server.
  
  Raises:
      [`InferenceTimeoutError`]:
          If the model is unavailable or the request times out.
      `HTTPError`:
          If the request fails with an HTTP error status code other than HTTP 503.
docstr_tok: ["Make","a","POST","request","to","the","inference","server",".","Args",":","json","(","`","Union","[","str",",","Dict",",","List","]","`",",","*","optional","*",")",":","The","JSON","data","to","send","in","the","request","body",",","specific","to","each","task",".","Defaults","to","None",".","data","(","`","Union","[","str",",","Path",",","bytes",",","BinaryIO","]","`",",","*","optional","*",")",":","The","content","to","send","in","the","request","body",",","specific","to","each","task",".","It","can","be","raw","bytes",",","a","pointer","to","an","opened","file",",","a","local","file","path",",","or","a","URL","to","an","online","resource","(","image",",","audio","file",",","...",")",".","If","both","`","json","`","and","`","data","`","are","passed",",","`","data","`","will","take","precedence",".","At","least","`","json","`","or","`","data","`","must","be","provided",".","Defaults","to","None",".","model","(","`","str","`",",","*","optional","*",")",":","The","model","to","use","for","inference",".","Can","be","a","model","ID","hosted","on","the","Hugging","Face","Hub","or","a","URL","to","a","deployed","Inference","Endpoint",".","Will","override","the","model","defined","at","the","instance","level",".","Defaults","to","None",".","task","(","`","str","`",",","*","optional","*",")",":","The","task","to","perform","on","the","inference",".","All","available","tasks","can","be","found","[","here","]","(","https",":","\/\/huggingface.co\/tasks",")",".","Used","only","to","default","to","a","recommended","model","if","`","model","`","is","not","provided",".","At","least","`","model","`","or","`","task","`","must","be","provided",".","Defaults","to","None",".","stream","(","`","bool","`",",","*","optional","*",")",":","Whether","to","iterate","over","streaming","APIs",".","Returns",":","bytes",":","The","raw","bytes","returned","by","the","server",".","Raises",":","[","`","InferenceTimeoutError","`","]",":","If","the","model","is","unavailable","or","the","request","times","out",".","`","HTTPError","`",":","If","the","request","fails","with","an","HTTP","error","status","code","other","than","HTTP","503","."]
code: def post(
      self,
      *,
      json: Optional[Union[str, Dict, List]] = None,
      data: Optional[ContentT] = None,
      model: Optional[str] = None,
      task: Optional[str] = None,
      stream: bool = False,
  ) -> Union[bytes, Iterable[bytes]]:
      """
      Make a POST request to the inference server.
  
      Args:
          json (`Union[str, Dict, List]`, *optional*):
              The JSON data to send in the request body, specific to each task. Defaults to None.
          data (`Union[str, Path, bytes, BinaryIO]`, *optional*):
              The content to send in the request body, specific to each task.
              It can be raw bytes, a pointer to an opened file, a local file path,
              or a URL to an online resource (image, audio file,...). If both `json` and `data` are passed,
              `data` will take precedence. At least `json` or `data` must be provided. Defaults to None.
          model (`str`, *optional*):
              The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
              Inference Endpoint. Will override the model defined at the instance level. Defaults to None.
          task (`str`, *optional*):
              The task to perform on the inference. All available tasks can be found
              [here](https://huggingface.co/tasks). Used only to default to a recommended model if `model` is not
              provided. At least `model` or `task` must be provided. Defaults to None.
          stream (`bool`, *optional*):
              Whether to iterate over streaming APIs.
  
      Returns:
          bytes: The raw bytes returned by the server.
  
      Raises:
          [`InferenceTimeoutError`]:
              If the model is unavailable or the request times out.
          `HTTPError`:
              If the request fails with an HTTP error status code other than HTTP 503.
      """
      url = self._resolve_url(model, task)
  
      if data is not None and json is not None:
          warnings.warn(
              "Ignoring `json` as `data` is passed as binary."
          )
  
      # Set Accept header if relevant
      headers = self.headers.copy()
      if task in TASKS_EXPECTING_IMAGES and "Accept" not in headers:
          headers["Accept"] = "image/png"
  
      t0 = time.time()
      timeout = self.timeout
      while True:
          with _open_as_binary(data) as data_as_binary:
              try:
                  response = get_session().post(
                      url,
                      json=json,
                      data=data_as_binary,
                      headers=headers,
                      cookies=self.cookies,
                      timeout=self.timeout,
                      stream=stream,
                  )
              except TimeoutError as error:
                  # Convert any `TimeoutError` to a `InferenceTimeoutError`
                  raise InferenceTimeoutError(f"Inference call timed out: {url}") from error  # type: ignore
  
          try:
              hf_raise_for_status(response)
              return (
                  response.iter_lines() if stream else response.content
              )
          except HTTPError as error:
              if error.response.status_code == 422 and task is not None:
                  error.args = (
                      f"{error.args[0]}\nMake sure '{task}' task is supported by the model.",
                  ) + error.args[1:]
              if error.response.status_code == 503:
                  # If Model is unavailable, either raise a TimeoutError...
                  if timeout is not None and time.time() - t0 > timeout:
                      raise InferenceTimeoutError(
                          f"Model not loaded on the server: {url}. Please retry with a higher timeout (current:"
                          f" {self.timeout}).",
                          request=error.request,
                          response=error.response,
                      ) from error
                  # ...or wait 1s and retry
                  logger.info(
                      f"Waiting for model to be loaded on the server: {error}"
                  )
                  time.sleep(1)
                  if timeout is not None:
                      timeout = max(self.timeout - (time.time() - t0), 1)  # type: ignore
                  continue
              raise
  
imports: import logging
  import time
  import warnings
  from dataclasses import asdict
  from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Literal, Optional, Union, overload
  from requests import HTTPError
  from requests.structures import CaseInsensitiveDict
  from huggingface_hub.constants import ALL_INFERENCE_API_FRAMEWORKS, INFERENCE_ENDPOINT, MAIN_INFERENCE_API_FRAMEWORKS
  from huggingface_hub.inference._common import TASKS_EXPECTING_IMAGES, ContentT, InferenceTimeoutError, ModelStatus, _b64_encode, _b64_to_image, _bytes_to_dict, _bytes_to_image, _bytes_to_list, _fetch_recommended_models, _import_numpy, _is_tgi_server, _open_as_binary, _set_as_non_tgi, _stream_text_generation_response
  from huggingface_hub.inference._text_generation import TextGenerationParameters, TextGenerationRequest, TextGenerationResponse, TextGenerationStreamResponse, raise_text_generation_error
  from huggingface_hub.inference._types import ClassificationOutput, ConversationalOutput, FillMaskOutput, ImageSegmentationOutput, ObjectDetectionOutput, QuestionAnsweringOutput, TableQuestionAnsweringOutput, TokenClassificationOutput
  from huggingface_hub.utils import BadRequestError, build_hf_headers, get_session, hf_raise_for_status
label_desc: Use image node_id 5 for calling the InferenceClient obj's underlying member method code with example usage: obj.post() and returns: unknown