code: def fetch_state_dict(
      url: str,
      filepath: Union[str, os.PathLike],
      save_state_dict: bool = True,
  ) -> Tuple[dict, dict]:
      """
      Fetch the metadata and state/hyperparameter values of pre-trained detectors.
  
      Parameters
      ----------
      url
          URL to fetch detector from.
      filepath
          Local directory to save detector to.
      save_state_dict
          Whether to save the state dict locally.
  
      Returns
      -------
      Detector metadata and state.
      """
      # Check if metadata stored as dill or pickle
      try:
          url_meta = _join_url(url, "meta.dill")
          resp = requests.get(url_meta, timeout=TIMEOUT)
          resp.raise_for_status()
          suffix = ".dill"
      except RequestException:
          try:
              url_meta = _join_url(url, "meta.pickle")
              resp = requests.get(url_meta, timeout=TIMEOUT)
              resp.raise_for_status()
              suffix = ".pickle"
          except RequestException:
              logger.exception(
                  "Timed out while searching for meta.dill or meta.pickle files at %s.",
                  url,
              )
              raise
  
      # Load metadata and state_dict
      meta = dill.load(BytesIO(resp.content))
      try:
          url_state = _join_url(url, meta["name"] + suffix)
          resp = requests.get(url_state)
          resp.raise_for_status()
      except RequestException:
          logger.exception(
              "Timed out while searching for corresponding state file at %s.",
              url,
          )
          raise
      state_dict = dill.load(BytesIO(resp.content))
  
      # Save state
      if save_state_dict:
          filepath = Path(filepath)
          with open(filepath.joinpath("meta.dill"), "wb") as f:
              dill.dump(meta, f)
          with open(
              filepath.joinpath(meta["name"] + ".dill"), "wb"
          ) as f:
              dill.dump(state_dict, f)
      return meta, state_dict
  
imports: import logging
  import os
  from io import BytesIO
  from pathlib import Path
  from typing import Union, TYPE_CHECKING, Tuple
  import dill
  import requests
  from requests import RequestException
  import tensorflow
  from tensorflow.python.keras import backend
  from alibi_detect.models.tensorflow import PixelCNN
  from alibi_detect.saving import load_detector
  from alibi_detect.utils.url import _join_url
label_desc: Use image node_id 12 for calling a global function with example usage: fetch_state_dict(url, filepath, save_state_dict) and returns: meta,  state_dict