class_docstr: Parent class of gradio client
  To handle automatically refreshing client if detect gradio server changed
class_docstr_tok: ["Parent","class","of","gradio","client","To","handle","automatically","refreshing","client","if","detect","gradio","server","changed"]
code: def refresh_client_if_should(self):
      if self.config is None:
          self.setup()
      # get current hash in order to update api_name -> fn_index map in case gradio server changed
      # FIXME: Could add cli api as hash
      server_hash = self.get_server_hash()
      if self.server_hash != server_hash:
          if self.verbose:
              print(
                  "server hash changed: %s %s"
                  % (self.server_hash, server_hash),
                  flush=True,
              )
          if self.server_hash is not None and self.persist:
              if self.verbose:
                  print(
                      "Failed to persist due to server hash change, only kept chat_conversation not user session hash",
                      flush=True,
                  )
          # risky to persist if hash changed
          self.refresh_client()
          self.server_hash = server_hash
  
imports: from __future__ import annotations
  import difflib
  import traceback
  import concurrent.futures
  import os
  import concurrent.futures
  import time
  import urllib.parse
  import uuid
  from concurrent.futures import Future
  from datetime import timedelta
  from enum import Enum
  from pathlib import Path
  from typing import Callable, Generator, Any, Union, List
  import ast
  from packaging import version
  from huggingface_hub import SpaceStage
  from huggingface_hub.utils import build_hf_headers
  from gradio_client import utils
  from importlib.metadata import distribution, PackageNotFoundError
  from gradio_client.client import Job, DEFAULT_TEMP_DIR, Endpoint
  from gradio_client import Client
label_desc: Use image node_id 6 for calling the GradioClient obj's underlying member method code with example usage: obj.refresh_client_if_should() without return types