code: def scale_SVG(svg: str, scale: float) -> str:
      """
      Convert:
  
      <svg ... height="382pt" viewBox="0.00 0.00 344.00 382.00" width="344pt">
      <g class="graph" id="graph0" transform="scale(1 1) rotate(0) translate(4 378)">
  
      To:
  
      <svg ... height="191.0" viewBox="0.0 0.0 172.0 191.0" width="172.0">
      <g class="graph" id="graph0" transform="scale(.5 .5) rotate(0) translate(4 378)">
      """
      # Scale bounding box etc...
      w, h, viewBox = get_SVG_shape(svg)
      root = ET.fromstring(svg)
      root.set("width", str(w * scale))
      root.set("height", str(h * scale))
      viewBox[2] *= scale
      viewBox[3] *= scale
      root.set("viewBox", " ".join([str(v) for v in viewBox]))
  
      # Deal with graph scale
      ns = {"svg": "http://www.w3.org/2000/svg"}
      graph = root.find(
          ".//svg:g", ns
      )  # get first node, which is graph
      transform = graph.attrib["transform"]
      pattern = re.compile(r"scale\([0-9.]+\ [0-9.]+\)")
      scale_str = pattern.search(transform).group()
      transform = transform.replace(
          scale_str, f"scale({scale} {scale})"
      )
      graph.set("transform", transform)
  
      ET.register_namespace("", "http://www.w3.org/2000/svg")
      ET.register_namespace("xlink", "http://www.w3.org/1999/xlink")
      xml_str = ET.tostring(root).decode()
      return xml_str
  
imports: import os
  import re
  import tempfile
  import warnings
  import xml.etree.cElementTree
  from pathlib import Path
  from sys import platform
  import graphviz
  import numpy
  import pandas
  from matplotlib import patches
  from numpy import ndarray
  from numbers import Number
  from typing import Tuple, Sequence
label_desc: Use image node_id 4 for calling a global function with example usage: scale_SVG(svg, scale) and returns: xml_str