code: def connect_tf_serving(model_name, host, port, mode):
      logger.info(
          "Connecting to tensorflow serving",
          tf_serving_host=host,
          port=port,
          model_name=model_name,
          mode=mode,
      )
      if mode == "grpc":
          return connect_tf_serving_grpc(model_name, host, port)
      elif mode == "rest":
          return connect_tf_serving_rest(model_name, host, port)
  
imports: import abc
  import json
  import os
  from typing import Any, Dict, List, Optional, Tuple, Type
  import aiohttp
  import requests
  from structlog import get_logger
  from tenacity import Retrying, retry_if_exception, stop_after_attempt, wait_random_exponential
  from modelkit.core.model import AsyncModel, Model
  from modelkit.core.types import ItemType, ReturnType
  from modelkit.utils.serialization import safe_np_dump
label_desc: Use image node_id 6 for calling a global function with example usage: connect_tf_serving(model_name, host, port, mode) and returns: connect_tf_serving_grpc, connect_tf_serving_rest