Returns a sub-dict composed solely of the given keys.

    Parameters
    ----------
    dict_obj : dict
        The dict to create a sub-dict from.
    keys : list of str
        The keys to keep in the sub-dict. Keys not present in the given dict
        will be ignored.

    Returns
    -------
    dict
        A sub-dict of the given dict composed solely of the given keys.

    Example:
    --------
    >>> dict_obj = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
    >>> subdict = subdict_by_keys(dict_obj, ['b', 'd', 'e'])
    >>> print(sorted(subdict.items()))
    [('b', 2), ('d', 4)]

def subdict_by_keys(dict_obj, keys):
    """Returns a sub-dict composed solely of the given keys.

    Parameters
    ----------
    dict_obj : dict
        The dict to create a sub-dict from.
    keys : list of str
        The keys to keep in the sub-dict. Keys not present in the given dict
        will be ignored.

    Returns
    -------
    dict
        A sub-dict of the given dict composed solely of the given keys.

    Example:
    --------
    >>> dict_obj = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
    >>> subdict = subdict_by_keys(dict_obj, ['b', 'd', 'e'])
    >>> print(sorted(subdict.items()))
    [('b', 2), ('d', 4)]
    """
    return {k: dict_obj[k] for k in set(keys).intersection(dict_obj.keys())}