code: def _FormatMessage(template, parameters):
    
    def GetParameter(m):
      try:
        return parameters[int(m.group(0)[1:])]
      except IndexError:
        return INVALID_EXPRESSION_INDEX
  
    parts = template.split('$$')
    return '$'.join(re.sub(r'\$\d+', GetParameter, part) for part in parts)
docs: Formats the message. Unescapes '$$' with '$'.
  
    Args:
      template: message template (e.g. 'a = $0, b = $1').
      parameters: substitution parameters for the format.
  
    Returns:
      Formatted message with parameters embedded in template placeholders.