code: def read_matrix_ascii(file_or_fd):
      """This function reads a matrix in kaldi matrix text format
      and stores it as a list of lists.
      The input can be a file or an opened file descriptor.
      """
      try:
          fd = open(file_or_fd, "r")
          fname = file_or_fd
      except TypeError:
          # 'file_or_fd' is opened file descriptor,
          fd = file_or_fd
          fname = file_or_fd.name
  
      first = fd.read(2)
      if first != " [" and first != b" [":
          logger.error(
              "Kaldi matrix file %s has incorrect format, "
              "only text format matrix files can be read by this script",
              fname,
          )
          if fd is not file_or_fd:
              fd.close()
          raise RuntimeError
  
      rows = []
      while True:
          line = fd.readline()
          if not line:
              logger.error(
                  "Kaldi matrix file %s has incorrect format; "
                  "got EOF before end of matrix",
                  fname,
              )
              if fd is not file_or_fd:
                  fd.close()
              raise RuntimeError
          line = line.strip()
          if len(line) == 0:
              continue  # skip empty line
          arr = line.split()
          if arr[-1] != b"]" and arr[-1] != "]":
              rows.append([float(x) for x in arr])  # not last line
          else:
              rows.append([float(x) for x in arr[:-1]])  # lastline
              if fd is not file_or_fd:
                  fd.close()
              return rows
  
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 19 for calling a global function with example usage: read_matrix_ascii(file_or_fd) and returns: rows