code: def flatten_location(location: Dict, delim="\n", bb3_format=False):
      if bb3_format:
          location_str_parts = [
              f'Setting: {location["name"]}',
              f'Description: {location["description"]}',
          ]
      else:
          location_str_parts = [
              "__location__",
              f"{location['name']}: {location['description']}",
              "__end-location__",
          ]
  
      return delim.join(location_str_parts)
  
imports: from typing import Optional, Dict
  import random
  from parlai.core.agents import Agent
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.agents import create_agent_from_model_file
  from parlai.core.loader import load_agent_module
  from parlai.utils.logging import logging
label_desc: Use image node_id 2 for calling a global function with example usage: flatten_location(location, delim, bb3_format) and returns: delim