<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _inherit_attr(klass, attr, default, cp):
 """Inherit the attribute from the base class Copy `attr` from base class (otherwise use `default`). Copying is done using the passed `cp` function. The motivation behind writing this function is to allow inheritance among Cmdln classes where base classes set 'common' options using the `@cmdln.option` decorator. To ensure this, we must not write to the base class's options when handling the derived class. """

    if attr not in klass.__dict__:
        if hasattr(klass, attr):
            value = cp(getattr(klass, attr))
        else:
            value = default
        setattr(klass, attr, value)