def METHOD_NAME(self, cache_key):
    self._base_graph._print(
        0,
        0,
        self._base_graph._shallow_repr()
        + f" is creating a graph cache with key {cache_key}.",
    )
    cur_is_base = False
    if self._cache.is_empty():
        # Has no graph yet
        cur_is_base = True
        graph = self._base_graph
    else:
        # Create new graph from base
        graph = self._base_graph.__class__(
            *self._base_graph._cached_init_args,
            **self._base_graph._cached_init_kwargs,
        )
        graph._run_with_cache = False
        graph._dynamic_input_graph_cache = None
        graph._cached_init_args = None
        graph._cached_init_kwargs = None
    if self._enable_shared is True:
        if cur_is_base:
            graph.enable_shared()
        else:
            graph.share_from(self._base_graph)
    new_key, old_key = self._cache.set(cache_key, graph)
    if old_key is not None:
        self._base_graph._print(
            0,
            0,
            self._base_graph._shallow_repr()
            + f" cache is full(cache size {self._cache_size}), has deleted an old graph cache with key {old_key}.",
        )
    assert new_key is not None
    return graph