def parse_unit(name, parse_strict='<STR_LIT>', format='<STR_LIT>'):
if name is None or isinstance(name, units.UnitBase):<EOL><INDENT>return name<EOL><DEDENT>try:  <EOL><INDENT>return UNRECOGNIZED_UNITS[name]<EOL><DEDENT>except KeyError:  <EOL><INDENT>try:<EOL><INDENT>return units.Unit(name, parse_strict='<STR_LIT>')<EOL><DEDENT>except ValueError as exc:<EOL><INDENT>if (parse_strict == '<STR_LIT>' or<EOL>'<STR_LIT>' not in str(exc)):<EOL><INDENT>raise<EOL><DEDENT>GWpyFormat.warn = parse_strict != '<STR_LIT>'<EOL>return units.Unit(name, parse_strict='<STR_LIT>', format=format)<EOL><DEDENT>finally:<EOL><INDENT>GWpyFormat.warn = True<EOL><DEDENT><DEDENT>
Attempt to intelligently parse a `str` as a `~astropy.units.Unit`

    Parameters
    ----------
    name : `str`
        unit name to parse

    parse_strict : `str`
        one of 'silent', 'warn', or 'raise' depending on how pedantic
        you want the parser to be

    format : `~astropy.units.format.Base`
        the formatter class to use when parsing the unit string

    Returns
    -------
    unit : `~astropy.units.UnitBase`
        the unit parsed by `~astropy.units.Unit`

    Raises
    ------
    ValueError
        if the unit cannot be parsed and `parse_strict='raise'`