code: def create_reference_msg(msg: ForwardMsg) -> ForwardMsg:
      """Create a ForwardMsg that refers to the given message via its hash.
  
      The reference message will also get a copy of the source message's
      metadata.
  
      Parameters
      ----------
      msg : ForwardMsg
          The ForwardMsg to create the reference to.
  
      Returns
      -------
      ForwardMsg
          A new ForwardMsg that "points" to the original message via the
          ref_hash field.
  
      """
      ref_msg = ForwardMsg()
      ref_msg.ref_hash = populate_hash_if_needed(msg)
      ref_msg.metadata.CopyFrom(msg.metadata)
      return ref_msg
  
imports: import hashlib
  from typing import TYPE_CHECKING, Dict, List, MutableMapping, Optional
  from weakref import WeakKeyDictionary
  from streamlit import config, util
  from streamlit.logger import get_logger
  from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
  from streamlit.runtime.stats import CacheStat, CacheStatsProvider, group_stats
  from streamlit.util import HASHLIB_KWARGS
label_desc: Use image node_id 2 for calling a global function with example usage: create_reference_msg(msg) and returns: ref_msg