code: def get_number_of_leaves_from_model(dir):
      stdout = get_command_stdout(
          "am-info {0}/final.mdl 2>/dev/null | grep -w pdfs".format(dir)
      )
      parts = stdout.split()
      # number of pdfs 7115
      assert " ".join(parts[0:3]) == "number of pdfs"
      num_leaves = int(parts[3])
      if num_leaves == 0:
          raise Exception("Number of leaves is 0")
      return num_leaves
  
imports: from __future__ import print_function
  from __future__ import division
  import argparse
  import logging
  import math
  import os
  import subprocess
  import sys
  import threading
label_desc: Use image node_id 10 for calling a global function with example usage: get_number_of_leaves_from_model(dir) and returns: num_leaves