code: def _extract(contents):
      """Extract a replay using s2protocol."""
      replay_io = io.BytesIO()
      replay_io.write(contents)
      replay_io.seek(0)
      archive = mpyq.MPQArchive(replay_io)
      extracted = archive.extract()
      metadata = json.loads(
          bytes.decode(extracted[b"replay.gamemetadata.json"], "utf-8")
      )
      contents = archive.header["user_data_header"]["content"]
      header = s2versions.latest().decode_replay_header(contents)
      base_build = header["m_version"]["m_baseBuild"]
      protocol = s2versions.build(base_build)
      if protocol is None:
          raise ValueError(
              "Could not load protocol {} for replay".format(base_build)
          )
      return header, metadata, extracted, protocol
  
file_path: pysc2/pysc2/lib/replay/sc2_replay.py
imports: import io
  import json
  import types
  import mpyq
  from s2protocol import versions
  import tree
label_desc: Use image node_id 3 for calling a global function with example usage: _extract(contents) and returns: header,  metadata,  extracted,  protocol