code: def _tweak_ns(tag, **options):
      
      nspaces = options.get("nspaces", None)
      if nspaces is not None:
          matched = _ET_NS_RE.match(tag)
          if matched:
              (uri, tag) = matched.groups()
              prefix = nspaces.get(uri, False)
              if prefix:
                  return "%s:%s" % (prefix, tag)
  
      return tag
docs: :param tag: XML tag element
      :param nspaces: A namespaces dict, {uri: prefix}
      :param options: Extra keyword options may contain 'nspaces' keyword option
          provide a namespace dict, {uri: prefix}
  
      >>> _tweak_ns("a", nspaces={})
      'a'
      >>> _tweak_ns("a", nspaces={"http://example.com/ns/val/": "val"})
      'a'
      >>> _tweak_ns("{http://example.com/ns/val/}a",
      ...           nspaces={"http://example.com/ns/val/": "val"})
      'val:a'