class_docstr: Automatically dispatch to the proper `Client` based on the organization.
class_docstr_tok: ["Automatically","dispatch","to","the","proper","`","Client","`","based","on","the","organization","."]
docstr: Return a client based on the tokenizer, creating it if necessary.
docstr_tok: ["Return","a","client","based","on","the","tokenizer",",","creating","it","if","necessary","."]
code: def _get_tokenizer_client(self, tokenizer: str) -> Client:
      """Return a client based on the tokenizer, creating it if necessary."""
      organization: str = tokenizer.split("/")[0]
      client: Optional[Client] = self.tokenizer_clients.get(tokenizer)
  
      if client is None:
          cache_config: CacheConfig = self._build_cache_config(
              organization
          )
          if get_huggingface_model_config(tokenizer):
              client = HuggingFaceClient(cache_config=cache_config)
          elif organization in [
              "bigscience",
              "bigcode",
              "EleutherAI",
              "facebook",
              "google",
              "gooseai",
              "huggingface",
              "microsoft",
              "Writer",
          ]:
              client = HuggingFaceClient(cache_config=cache_config)
          elif organization == "openai":
              client = OpenAIClient(
                  cache_config=cache_config,
              )
          elif organization == "AlephAlpha":
              client = AlephAlphaClient(
                  api_key=self.credentials["alephAlphaKey"],
                  cache_config=cache_config,
              )
          elif organization == "anthropic":
              client = AnthropicClient(
                  api_key=self.credentials.get("anthropicApiKey", None),
                  cache_config=cache_config,
              )
          elif organization == "TsinghuaKEG":
              client = ICETokenizerClient(cache_config=cache_config)
          elif organization == "Yandex":
              client = YaLMTokenizerClient(cache_config=cache_config)
          elif organization == "ai21":
              client = AI21Client(
                  api_key=self.credentials["ai21ApiKey"],
                  cache_config=cache_config,
              )
          elif organization == "cohere":
              client = CohereClient(
                  api_key=self.credentials["cohereApiKey"],
                  cache_config=cache_config,
              )
          elif organization == "simple":
              client = SimpleClient(cache_config=cache_config)
          elif organization == "nvidia":
              client = MegatronClient(cache_config=cache_config)
          else:
              raise ValueError(
                  f"Could not find tokenizer client for model: {tokenizer}"
              )
          self.tokenizer_clients[tokenizer] = client
      return client
  
imports: import os
  from dataclasses import replace
  from typing import Dict, Optional
  from retrying import RetryError, Attempt
  from helm.common.cache import CacheConfig, MongoCacheConfig, SqliteCacheConfig
  from helm.common.hierarchical_logger import hlog
  from helm.common.request import Request, RequestResult
  from helm.common.tokenization_request import TokenizationRequest, TokenizationRequestResult, DecodeRequest, DecodeRequestResult
  from helm.proxy.retry import retry_request
  from .critique_client import CritiqueClient, RandomCritiqueClient, SurgeAICritiqueClient
  from .mechanical_turk_critique_client import MechanicalTurkCritiqueClient
  from .client import Client
  from .ai21_client import AI21Client
  from .aleph_alpha_client import AlephAlphaClient
  from .anthropic_client import AnthropicClient
  from .chat_gpt_client import ChatGPTClient
  from .cohere_client import CohereClient
  from .together_client import TogetherClient
  from .google_client import GoogleClient
  from .goose_ai_client import GooseAIClient
  from .huggingface_client import HuggingFaceClient
  from .ice_tokenizer_client import ICETokenizerClient
  from .megatron_client import MegatronClient
  from .openai_client import OpenAIClient
  from .microsoft_client import MicrosoftClient
  from .perspective_api_client import PerspectiveAPIClient
  from .palmyra_client import PalmyraClient
  from .yalm_tokenizer_client import YaLMTokenizerClient
  from .simple_client import SimpleClient
  from helm.proxy.clients.huggingface_model_registry import get_huggingface_model_config
label_desc: Use image node_id 5 for calling the AutoClient obj's underlying member method code with example usage: obj._get_tokenizer_client(tokenizer) and returns: client