class_docstr: Just like contextlib.contextmanager, but will cache the yield value for the same
  arguments. When all instances of the same contextmanager exits, the cache value will
  be dropped.
  
  Example Usage: (To reuse the container based on the same image)
  
  .. code-block:: python
  
      @cached_contextmanager("{docker_image.id}")
      def start_docker_container_from_image(docker_image, timeout=60):
          container = ...
          yield container
          container.stop()
class_docstr_tok: ["Just","like","contextlib.contextmanager",",","but","will","cache","the","yield","value","for","the","same","arguments",".","When","all","instances","of","the","same","contextmanager","exits",",","the","cache","value","will","be","dropped",".","Example","Usage",":","(","To","reuse","the","container","based","on","the","same","image",")","..","code-block",":",":","python","@","cached_contextmanager","(","``","{","docker_image.id","}","''",")","def","start_docker_container_from_image","(","docker_image",",","timeout=60",")",":","container","=","...","yield","container","container.stop","(",")"]
code: def __init__(self, cache_key_template: t.Optional[str] = None):
      self._cache_key_template = cache_key_template
      self._cache: t.Dict[t.Any, t.Any] = {}
  
imports: from __future__ import annotations
  import asyncio
  import contextlib
  import functools
  import inspect
  import logging
  import os
  import random
  import re
  import socket
  import typing
  from datetime import date
  from datetime import datetime
  from datetime import time
  from datetime import timedelta
  from pathlib import Path
  from reprlib import recursive_repr
  from typing import TYPE_CHECKING
  from typing import overload
  import attr
  import fs
  import fs.copy
  from rich.console import Console
  from ..types import LazyType
  from .cattr import bentoml_cattr
  from .lazy_loader import LazyLoader
  from .uri import encode_path_for_uri
label_desc: Use image node_id 1 to create a new cached_contextmanager object  with example: obj = cached_contextmanager(cache_key_template)