code: def replace_in_config(
      obj: Union[
          ml_collections.ConfigDict,
          Mapping[str, Any],
          Iterable[Any],
          ml_collections.FieldReference,
      ],
      field_reference_replace_map: MutableMapping[
          int, ml_collections.FieldReference
      ],
  ) -> Union[
      ml_collections.ConfigDict,
      Mapping[str, Any],
      Iterable[Any],
      ml_collections.FieldReference,
  ]:
      """Returns a copy with replaced field references."""
      if isinstance(obj, ml_collections.FieldReference):
          return field_reference_replace_map.get(id(obj), obj)
      elif isinstance(obj, ml_collections.ConfigDict):
          return type(obj)(
              {
                  k: replace_in_config(v, field_reference_replace_map)
                  for k, v in obj.items()
              },
              type_safe=obj._type_safe,  # pylint: disable=protected-access
              convert_dict=obj._convert_dict,
          )  # pylint: disable=protected-access
      elif isinstance(obj, Mapping):
          it = (
              (k, replace_in_config(v, field_reference_replace_map))
              for k, v in obj.items()
          )
          try:
              return type(obj)(it)  # pytype: disable=wrong-arg-count
          except:  # pylint: disable=bare-except
              return dict(it)
      elif isinstance(obj, Iterable) and not isinstance(
          obj, (str, bytes)
      ):
          it = (
              replace_in_config(v, field_reference_replace_map)
              for v in obj
          )
          try:
              return type(obj)(it)  # pytype: disable=wrong-arg-count
          except:  # pylint: disable=bare-except
              return list(it)
      else:
          return obj
  
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 4 for calling a global function with example usage: replace_in_config(obj, field_reference_replace_map) and returns: field_reference_replace_map, type, type, obj, dict, type, list