code: def calc_active(seg):
      return sum(
          b["size"]
          for b in seg["blocks"]
          if b["state"] == "active_allocated"
      )
  
imports: import pickle
  import sys
  import os
  import io
  import subprocess
  import json
  from functools import lru_cache
  from typing import Any
  from itertools import groupby
  import base64
  import warnings
label_desc: Use image node_id 12 for calling a global function with example usage: calc_active(seg) and returns: sum