def convert_nsarg(<EOL>nsarg: str,<EOL>api_url: str = None,<EOL>namespace_targets: Mapping[str, List[str]] = None,<EOL>canonicalize: bool = False,<EOL>decanonicalize: bool = False,<EOL>) -> str:
if not api_url:<EOL><INDENT>api_url = config["<STR_LIT>"]["<STR_LIT>"]["<STR_LIT>"]<EOL>if not api_url:<EOL><INDENT>log.error("<STR_LIT>")<EOL>return None<EOL><DEDENT><DEDENT>params = None<EOL>if namespace_targets:<EOL><INDENT>namespace_targets_str = json.dumps(namespace_targets)<EOL>params = {"<STR_LIT>": namespace_targets_str}<EOL><DEDENT>if not namespace_targets:<EOL><INDENT>if canonicalize:<EOL><INDENT>api_url = api_url + "<STR_LIT>"<EOL><DEDENT>elif decanonicalize:<EOL><INDENT>api_url = api_url + "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>log.warning("<STR_LIT>")<EOL>return nsarg<EOL><DEDENT><DEDENT>else:<EOL><INDENT>api_url = (<EOL>api_url + "<STR_LIT>"<EOL>)  <EOL><DEDENT>request_url = api_url.format(url_path_param_quoting(nsarg))<EOL>r = get_url(request_url, params=params, timeout=<NUM_LIT:10>)<EOL>if r and r.status_code == <NUM_LIT:200>:<EOL><INDENT>nsarg = r.json().get("<STR_LIT>", nsarg)<EOL><DEDENT>elif not r or r.status_code == <NUM_LIT>:<EOL><INDENT>log.error(f"<STR_LIT>")<EOL><DEDENT>return nsarg<EOL>
[De]Canonicalize NSArg

    Args:
        nsarg (str): bel statement string or partial string (e.g. subject or object)
        api_url (str): BEL.bio api url to use, e.g. https://api.bel.bio/v1
        namespace_targets (Mapping[str, List[str]]): formatted as in configuration file example
        canonicalize (bool): use canonicalize endpoint/namespace targets
        decanonicalize (bool): use decanonicalize endpoint/namespace targets

    Results:
        str: converted NSArg