<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def nlmsg_inherit(hdr=None):
 """Allocate a new Netlink message and inherit Netlink message header. https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L322 Allocates a new Netlink message and inherits the original message header. If `hdr` is not None it will be used as a template for the Netlink message header, otherwise the header is left blank. Keyword arguments: hdr -- Netlink message header template (nlmsghdr class instance). Returns: Newly allocated Netlink message (nl_msg class instance). """

    nm = nlmsg_alloc()
    if hdr:
        new = nm.nm_nlh
        new.nlmsg_type = hdr.nlmsg_type
        new.nlmsg_flags = hdr.nlmsg_flags
        new.nlmsg_seq = hdr.nlmsg_seq
        new.nlmsg_pid = hdr.nlmsg_pid
    return nm