code: def safe_deepcopy_config(
      config: ml_collections.ConfigDict,
  ) -> ml_collections.ConfigDict:
      """Deep-copies a config by also substituting the usage of the field refs."""
      new_config = copy.deepcopy(config)
  
      field_reference_replace_map = {}
      _compute_field_reference_replace_map(
          config, new_config, field_reference_replace_map
      )
  
      with new_config.unlocked():
          replace_usage_of_field_references(
              new_config, field_reference_replace_map
          )
  
      return new_config
  
imports: from collections.abc import Callable
  from collections.abc import Iterable
  from collections.abc import Iterator
  from collections.abc import Mapping
  from collections.abc import MutableMapping
  from collections.abc import Sequence
  import copy
  import types
  from typing import Any
  from typing import Optional
  from typing import TypeVar
  from typing import Union
  from dmvr import tokenizers
  import jax
  import ml_collections
label_desc: Use image node_id 7 for calling a global function with example usage: safe_deepcopy_config(config) and returns: new_config