code: def get_client(self) -> ClientType:
      if self.process is None:
          # NOTE: if the process is None, we reset this envvar
          del os.environ[BENTOML_SERVE_FROM_SERVER_API]
          raise ServerStateException(
              "Attempted to get a client for a BentoML server that was not running! Try running 'bentoml.*Server.start()' first."
          )
      assert self.process is not None
      out_code = self.process.poll()
      if out_code == 0:
          # NOTE: if the process is None, we reset this envvar
          del os.environ[BENTOML_SERVE_FROM_SERVER_API]
          raise ServerStateException(
              "Attempted to get a client from a BentoML server that has already exited! You can run '.start()' again to restart it."
          )
      elif out_code is not None:
          # NOTE: if the process is None, we reset this envvar
          del os.environ[BENTOML_SERVE_FROM_SERVER_API]
          logs = "Attempted to get a client from a BentoML server that has already exited with an error!\nServer Output:\n"
          if (
              self.process.stdout is not None
              and not self.process.stdout.closed
          ):
              s = self.process.stdout.read()
              logs += textwrap.indent(
                  s.decode("utf-8") if isinstance(s, bytes) else s, " " * 4  # type: ignore  # may be string
              )
          if (
              self.process.stderr is not None
              and not self.process.stderr.closed
          ):
              logs += "\nServer Error:\n"
              s = self.process.stderr.read()
              logs += textwrap.indent(
                  s.decode("utf-8") if isinstance(s, bytes) else s, " " * 4  # type: ignore  # may be string
              )
          raise ServerStateException(logs)
      return self._get_client()
  
imports: from __future__ import annotations
  import logging
  import os
  import signal
  import subprocess
  import sys
  import textwrap
  import typing
  from abc import ABC
  from abc import abstractmethod
  from typing import TYPE_CHECKING
  from warnings import warn
  from simple_di import Provide
  from simple_di import inject
  from ._internal.bento import Bento
  from ._internal.client import Client
  from ._internal.client.grpc import GrpcClient
  from ._internal.client.http import HTTPClient
  from ._internal.configuration.containers import BentoMLContainer
  from ._internal.service import Service
  from ._internal.tag import Tag
  from ._internal.utils.analytics.usage_stats import BENTOML_SERVE_FROM_SERVER_API
  from .exceptions import InvalidArgument
  from .exceptions import ServerStateException
  from .exceptions import UnservableException
label_desc: Use image node_id 3 for calling the Server obj's underlying member method code with example usage: obj.get_client() and returns: self