def dict_fetch(src_dict, tgt_dict_or_keys):
    'Fetches a sub dict of :attr:`src_dict` with the keys in\n    :attr:`tgt_dict_or_keys`.\n\n    Args:\n        src_dict: A dict or instance of :class:`~texar.tf.HParams`.\n            The source dict to fetch values from.\n        tgt_dict_or_keys: A dict, instance of :class:`~texar.tf.HParams`,\n            or a list (or a dict_keys) of keys to be included in the output\n            dict.\n\n    Returns:\n        A new dict that is a subdict of :attr:`src_dict`.\n    '
    if (src_dict is None):
        return src_dict
    if isinstance(tgt_dict_or_keys, HParams):
        tgt_dict_or_keys = tgt_dict_or_keys.todict()
    if isinstance(tgt_dict_or_keys, dict):
        tgt_dict_or_keys = tgt_dict_or_keys.keys()
    keys = list(tgt_dict_or_keys)
    if isinstance(src_dict, HParams):
        src_dict = src_dict.todict()
    return {k: src_dict[k] for k in keys if (k in src_dict)}
Fetches a sub dict of :attr:`src_dict` with the keys in
:attr:`tgt_dict_or_keys`.

Args:
    src_dict: A dict or instance of :class:`~texar.tf.HParams`.
        The source dict to fetch values from.
    tgt_dict_or_keys: A dict, instance of :class:`~texar.tf.HParams`,
        or a list (or a dict_keys) of keys to be included in the output
        dict.

Returns:
    A new dict that is a subdict of :attr:`src_dict`.
def dict_fetch(src_dict, tgt_dict_or_keys):
    'Fetches a sub dict of :attr:`src_dict` with the keys in\n    :attr:`tgt_dict_or_keys`.\n\n    Args:\n        src_dict: A dict or instance of :class:`~texar.tf.HParams`.\n            The source dict to fetch values from.\n        tgt_dict_or_keys: A dict, instance of :class:`~texar.tf.HParams`,\n            or a list (or a dict_keys) of keys to be included in the output\n            dict.\n\n    Returns:\n        A new dict that is a subdict of :attr:`src_dict`.\n    '
    if (src_dict is None):
        return src_dict
    if isinstance(tgt_dict_or_keys, HParams):
        tgt_dict_or_keys = tgt_dict_or_keys.todict()
    if isinstance(tgt_dict_or_keys, dict):
        tgt_dict_or_keys = tgt_dict_or_keys.keys()
    keys = list(tgt_dict_or_keys)
    if isinstance(src_dict, HParams):
        src_dict = src_dict.todict()
    return {k: src_dict[k] for k in keys if (k in src_dict)}