code: def _list_to_dict(
      list_of_elements: list[Any],
  ) -> Union[dict[str, Any], np.ndarray]:
      """Converts a list of elements to a dict of elements with the same struct."""
      if not list_of_elements:
          return {}
      first = list_of_elements[0]
      if isinstance(first, dict):
          return {
              k: np.asarray([v[k] for v in list_of_elements])
              for k in first
          }
      else:
          return np.asarray(list_of_elements)
  
file_path: datasets/tensorflow_datasets/core/utils/np_utils.py
imports: from typing import Any, Callable, Tuple, Union
  import numpy
  from tensorflow_datasets.core.utils import py_utils
  from tensorflow_datasets.core.utils import type_utils
  import tree
label_desc: Use image node_id 3 for calling a global function with example usage: _list_to_dict(list_of_elements) and returns: dict, unknown, np