async def METHOD_NAME(self):
    """
    Generate caching dictionary from a yaml file.
    """
    with open(self.diag_dir + "messages_to_bag.yaml") as f:
        messages_to_bag = yaml.safe_load(f)
    # Set bagging parameters
    self.time_step = messages_to_bag["PARAMS"]["time_step"]
    self.pre_cache_time = messages_to_bag["PARAMS"]["pre_cache_time"]
    self.post_cache_time = messages_to_bag["PARAMS"]["post_cache_time"]
    self.cache_dict = {}
    msgs = messages_to_bag["MESSAGES"]
    for msg in msgs.values():
        # Get message information
        msg_topic = msg["message_topic"]
        msg_type = msg["message_type"]
        msg_name = msg["message_name"]
        # Import the message
        exec(f"from {msg_type}.msg import {msg_name}")
        # Create subscriber and add to dictionary
        self.cache_dict[msg_topic] = self.nh.subscribe(msg_topic, eval(msg_name))
        await self.cache_dict[msg_topic]