code: def unpack_if_dir(
      fs,
      path,
      props: Dict[str, str],
      onerror: Optional[Callable] = None,
  ):
      result: Dict[str, Dict] = defaultdict(dict)
      if fs.isdir(path):
          unpacked = _unpack_dir_files(fs, path, onerror=onerror)
      else:
          unpacked = {"data": [path]}
  
      if "data" in unpacked:
          for subpath in unpacked["data"]:
              result["data"].update({subpath: props})
      else:
          result.update(unpacked)
  
      return dict(result)
  
imports: import csv
  import io
  import os
  from collections import defaultdict
  from copy import deepcopy
  from functools import partial
  from multiprocessing import cpu_count
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Set, Union
  import dpath
  import dpath.options
  from funcy import first, ldistinct, project, reraise
  from dvc.exceptions import DvcException
  from dvc.log import logger
  from dvc.utils import error_handler, errored_revisions
  from dvc.utils.objects import cached_property
  from dvc.utils.serialize import PARSERS, EncodingError
  from dvc.utils.threadpool import ThreadPoolExecutor
  from dvc_render.image import ImageRenderer
label_desc: Use image node_id 17 for calling a global function with example usage: unpack_if_dir(fs, path, props, onerror) and returns: dict