def write_sourcemap(<EOL>mappings, sources, names, output_stream, sourcemap_stream,<EOL>normalize_paths=True, source_mapping_url=NotImplemented):
encode_sourcemap_args, output_js_map = verify_write_sourcemap_args(<EOL>mappings, sources, names, output_stream, sourcemap_stream,<EOL>normalize_paths<EOL>)<EOL>encoded_sourcemap = json.dumps(<EOL>encode_sourcemap(*encode_sourcemap_args),<EOL>sort_keys=True, ensure_ascii=False,<EOL>)<EOL>if sourcemap_stream is output_stream:<EOL><INDENT>encoding = getattr(output_stream, '<STR_LIT>', None) or default_encoding<EOL>output_stream.writelines([<EOL>'<STR_LIT>',<EOL>encoding, '<STR_LIT:U+002C>', base64.b64encode(<EOL>encoded_sourcemap.encode(encoding)).decode('<STR_LIT:ascii>'),<EOL>])<EOL><DEDENT>else:<EOL><INDENT>if source_mapping_url is not None:<EOL><INDENT>output_stream.writelines(['<STR_LIT>', (<EOL>output_js_map if source_mapping_url is NotImplemented<EOL>else source_mapping_url<EOL>), '<STR_LIT:\n>'])<EOL><DEDENT>sourcemap_stream.write(encoded_sourcemap)<EOL><DEDENT>
Write out the mappings, sources and names (generally produced by
the write function) to the provided sourcemap_stream, and write the
sourceMappingURL to the output_stream.

Arguments

mappings, sources, names
    These should be values produced by write function from this
    module.
output_stream
    The original stream object that was written to; its name will
    be used for the file target and if sourceMappingURL is resolved,
    it will be writtened to this stream also as a comment.
sourcemap_stream
    If one is provided, the sourcemap will be written out to it.

    If it is the same stream as the output_stream, the source map
    will be written as an encoded 'data:application/json;base64'
    url to the sourceMappingURL comment.  Note that an appropriate
    encoding must be available as an attribute by the output_stream
    object so that the correct character set will be used for the
    base64 encoded JSON serialized string.
normalize_paths
    If set to True, absolute paths found will be turned into
    relative paths with relation from the stream being written
    to, and the path separator used will become a '/' (forward
    slash).
source_mapping_url
    If an explicit value is set, this will be written as the
    sourceMappingURL into the output_stream.  Note that the path
    normalization will NOT use this value, so if paths have been
    manually provided, ensure that normalize_paths is set to False
    if the behavior is unwanted.