<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_nanopubs(fn: str) -> Iterable[Mapping[str, Any]]: """Read file and generate nanopubs If filename has *.gz, will read as a gzip file If filename has *.jsonl*, will parsed as a JSONLines file IF filename has *.json*, will be parsed as a JSON file If filename has *.yaml* or *.yml*, will be parsed as a YAML file Args: filename (str):
 filename to read nanopubs from Returns: Generator[Mapping[str, Any]]: generator of nanopubs in nanopub_bel JSON Schema format """


    jsonl_flag, json_flag, yaml_flag = False, False, False
    if fn == "-" or "jsonl" in fn:
        jsonl_flag = True
    elif "json" in fn:
        json_flag = True
    elif re.search("ya?ml", fn):
        yaml_flag = True
    else:
        log.error("Do not recognize nanopub file format - neither json nor jsonl format.")
        return {}

    try:
        if re.search("gz$", fn):
            f = gzip.open(fn, "rt")
        else:
            try:
                f = click.open_file(fn, mode="rt")
            except Exception as e:
                log.info(f"Can not open file {fn}  Error: {e}")
                quit()

        if jsonl_flag:
            for line in f:
                yield json.loads(line)
        elif json_flag:
            nanopubs = json.load(f)
            for nanopub in nanopubs:
                yield nanopub
        elif yaml_flag:
            nanopubs = yaml.load(f, Loader=yaml.SafeLoader)
            for nanopub in nanopubs:
                yield nanopub

    except Exception as e:
        log.error(f"Could not open file: {fn}")