code: def _gen(self, struct, prefix=None):
      paths = []
      for name, contents in struct.items():
          path = (prefix or self) / name
  
          if isinstance(contents, dict):
              if not contents:
                  os.makedirs(path, exist_ok=True)
              else:
                  self._gen(contents, prefix=path)
          else:
              os.makedirs(path.parent, exist_ok=True)
              if isinstance(contents, bytes):
                  path.write_bytes(contents)
              else:
                  path.write_text(contents, encoding="utf-8")
          paths.append(path)
      return paths
  
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 9 for calling the TmpDir obj's underlying member method code with example usage: obj._gen(struct, prefix) and returns: paths