<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_namespaces_str( bel_str: str, api_url: str = None, namespace_targets: Mapping[str, List[str]] = None, canonicalize: bool = False, decanonicalize: bool = False, ) -> str: """Convert namespace in string Uses a regex expression to extract all NSArgs and replace them with the updated NSArg from the BEL.bio API terms endpoint. Args: bel_str (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: bel statement with namespaces converted """


    # pattern - look for capitalized namespace followed by colon
    #           and either a quoted string or a string that
    #           can include any char other than space, comma or ')'
    matches = re.findall(r'([A-Z]+:"(?:\\.|[^"\\])*"|[A-Z]+:(?:[^\),\s]+))', bel_str)
    for nsarg in matches:
        if "DEFAULT:" in nsarg:  # skip default namespaces
            continue

        updated_nsarg = convert_nsarg(
            nsarg,
            api_url=api_url,
            namespace_targets=namespace_targets,
            canonicalize=canonicalize,
            decanonicalize=decanonicalize,
        )
        if updated_nsarg != nsarg:
            bel_str = bel_str.replace(nsarg, updated_nsarg)

    return bel_str