code: def write_kaldi_matrix(output_file, matrix):
      """This function writes the matrix stored as a list of lists
      into 'output_file' in kaldi matrix text format.
      """
      with open(output_file, "w") as f:
          f.write("[ ")
          num_rows = len(matrix)
          if num_rows == 0:
              raise Exception("Matrix is empty")
          num_cols = len(matrix[0])
  
          for row_index in range(len(matrix)):
              if num_cols != len(matrix[row_index]):
                  raise Exception(
                      "All the rows of a matrix are expected to "
                      "have the same length"
                  )
              f.write(" ".join([str(x) for x in matrix[row_index]]))
              if row_index != num_rows - 1:
                  f.write("\n")
          f.write(" ]")
  
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 17 for calling a global function with example usage: write_kaldi_matrix(output_file, matrix) without return types