<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_optional_arg_from_config(cp, section, arg, dtype=str):
 """Convenience function to retrieve an optional argument from a config file. Parameters cp : ConfigParser Open config parser to retrieve the argument from. section : str Name of the section to retrieve from. arg : str Name of the argument to retrieve. dtype : datatype, optional Cast the retrieved value (if it exists) to the given datatype. Default is ``str``. Returns ------- val : None or str If the argument is present, the value. Otherwise, None. """

    if cp.has_option(section, arg):
        val = dtype(cp.get(section, arg))
    else:
        val = None
    return val