code: def format_message(
      cls,
      rev: str,
      baseline_rev: str,
      name: Optional[str] = None,
      branch: Optional[str] = None,
  ) -> str:
      msg = cls.MESSAGE_FORMAT.format(
          rev=rev, baseline_rev=baseline_rev, name=name if name else ""
      )
      branch_msg = f":{branch}" if branch else ""
      return f"{msg}{branch_msg}"
  
imports: import re
  from contextlib import contextmanager
  from typing import Dict, Iterable, Iterator, NamedTuple, Optional
  from scmrepo.git import Stash
  from dvc.exceptions import DvcException
  from dvc.log import logger
  from dvc_objects.fs.local import localfs
  from dvc_objects.fs.utils import as_atomic
  from .refs import APPLY_HEAD, APPLY_STASH
label_desc: Use image node_id 2 for calling the ExpStash obj's underlying member method code with example usage: obj.format_message(cls, rev, baseline_rev, name, branch) and returns: msg, branch_msg