<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _file_to_abs(x, dnames, makedir=False):
 """Make a file absolute using the supplied base directory choices. """

    if x is None or os.path.isabs(x):
        return x
    elif isinstance(x, six.string_types) and objectstore.is_remote(x):
        return x
    elif isinstance(x, six.string_types) and x.lower() == "none":
        return None
    else:
        for dname in dnames:
            if dname:
                normx = os.path.normpath(os.path.join(dname, x))
                if os.path.exists(normx):
                    return normx
                elif makedir:
                    utils.safe_makedir(normx)
                    return normx
        raise ValueError("Did not find input file %s in %s" % (x, dnames))