code: def attribute(
      val: T, doc: Optional[str] = None, **kwargs: Any
  ) -> DatasetAttribute[HDF5Any, T, Any]:
      """Creates a dataset attribute that contains both a value and associated metadata.
  
      Args:
          val (any): the dataset attribute value
          doc (str): the docstring that describes the attribute
          **kwargs: Additional keyword arguments may be passed, which represents metadata
              which describes the attribute.
  
      Returns:
          DatasetAttribute: an attribute object
  
      .. seealso:: :class:`~.Dataset`
  
      **Example**
  
      >>> hamiltonian = qml.Hamiltonian([1., 1.], [qml.PauliZ(wires=0), qml.PauliZ(wires=1)])
      >>> eigvals, eigvecs = np.linalg.eigh(qml.matrix(hamiltonian))
      >>> dataset = qml.data.Dataset(hamiltonian = qml.data.attribute(
      ...     hamiltonian,
      ...     doc="The hamiltonian of the system"))
      >>> dataset.eigen = qml.data.attribute(
      ...     {"eigvals": eigvals, "eigvecs": eigvecs},
      ...     doc="Eigenvalues and eigenvectors of the hamiltonain")
  
      This metadata can then be accessed using the :meth:`~.Dataset.attr_info` mapping:
  
      >>> dataset.attr_info["eigen"]["doc"]
      'Eigenvalues and eigenvectors of the hamiltonain'
      """
      return match_obj_type(val)(
          val, AttributeInfo(doc=doc, py_type=type(val), **kwargs)
      )
  
imports: import typing
  import warnings
  from abc import ABC, abstractmethod
  from collections.abc import Mapping, MutableMapping, Sequence
  from functools import lru_cache
  from numbers import Number
  from types import MappingProxyType
  from typing import Any, ClassVar, Generic, Iterator, Literal, Optional, Tuple, Type, TypeVar, Union, overload
  from pennylane.data.base import hdf5
  from pennylane.data.base.hdf5 import HDF5, HDF5Any, HDF5Group
  from pennylane.data.base.typing_util import UNSET, get_type, get_type_str
label_desc: Use image node_id 1 for calling a global function with example usage: attribute(val, doc) and returns: match_obj_type