code: def branch(self, name, new=False):
      self._require("scm")
      old = self.scm.active_branch()
      try:
          self.scm.checkout(name, create_new=new)
          yield
      finally:
          self.scm.checkout(old)
  
imports: import os
  import pathlib
  import sys
  from contextlib import contextmanager
  from functools import partialmethod
  from dvc.utils import serialize
label_desc: Use image node_id 17 for calling the TmpDir obj's underlying member method code with example usage: obj.branch(name, new) without return types