def format_serialized(serialized):
  """Formats the serialized logical form to reduce the number of tokens.

  The intent and slot labels are lower-cased and broken into words.
  Example: "[IN:SET_ALARM" --> "[IN set alarm ="

  The close brackets are also merged with the preceding token to avoid an extra
  space token after tokenization.

  Args:
    serialized: Serialized logical form string

  Returns:
    formatted logical form string.
  """
  lf_toks = []
  for tok in serialized.split():
    if tok == "]":
      lf_toks.append(tok)
    elif tok[0] == "[":
      prefix, suffix = tok[1:].split(":")
      lf_toks.append(" [" + prefix)
      lf_toks.append(" " + suffix.lower().replace("_", " "))
      lf_toks.append(" =")
    else:
      lf_toks.append(" " + tok)
  return "".join(lf_toks).strip()
Formats the serialized logical form to reduce the number of tokens.

  The intent and slot labels are lower-cased and broken into words.
  Example: "[IN:SET_ALARM" --> "[IN set alarm ="

  The close brackets are also merged with the preceding token to avoid an extra
  space token after tokenization.

  Args:
    serialized: Serialized logical form string

  Returns:
    formatted logical form string.
  
se2/src/utils/top_utils.py