from textwrap import dedent


def smart_dedent(text):
  """Like dedent, but dedents the first line separately from the rest of the string."""
  lines = text.split('\n')
  if len(lines) <= 1:
    return dedent(text)
  return '{}\n{}'.format(dedent(lines[0]), dedent('\n'.join(lines[1:])))