code: def verify_egs_dir(
      egs_dir,
      feat_dim,
      ivector_dim,
      ivector_extractor_id,
      left_context,
      right_context,
      left_context_initial=-1,
      right_context_final=-1,
  ):
      try:
          egs_feat_dim = int(
              open("{0}/info/feat_dim".format(egs_dir)).readline()
          )
  
          egs_ivector_id = None
          try:
              egs_ivector_id = (
                  open("{0}/info/final.ie.id".format(egs_dir))
                  .readline()
                  .strip()
              )
              if egs_ivector_id == "":
                  egs_ivector_id = None
          except:
              # it could actually happen that the file is not there
              # for example in cases where the egs were dumped by
              # an older version of the script
              pass
  
          try:
              egs_ivector_dim = int(
                  open(
                      "{0}/info/ivector_dim".format(egs_dir)
                  ).readline()
              )
          except:
              egs_ivector_dim = 0
          egs_left_context = int(
              open("{0}/info/left_context".format(egs_dir)).readline()
          )
          egs_right_context = int(
              open("{0}/info/right_context".format(egs_dir)).readline()
          )
          try:
              egs_left_context_initial = int(
                  open(
                      "{0}/info/left_context_initial".format(egs_dir)
                  ).readline()
              )
          except:  # older scripts didn't write this, treat it as -1 in that case.
              egs_left_context_initial = -1
          try:
              egs_right_context_final = int(
                  open(
                      "{0}/info/right_context_final".format(egs_dir)
                  ).readline()
              )
          except:  # older scripts didn't write this, treat it as -1 in that case.
              egs_right_context_final = -1
  
          # if feat_dim was supplied as 0, it means the --feat-dir option was not
          # supplied to the script, so we simply don't know what the feature dim is.
          if (feat_dim != 0 and feat_dim != egs_feat_dim) or (
              ivector_dim != egs_ivector_dim
          ):
              raise Exception(
                  "There is mismatch between featdim/ivector_dim of "
                  "the current experiment and the provided "
                  "egs directory"
              )
  
          if (
              (egs_ivector_id is None)
              and (ivector_extractor_id is not None)
          ) or (
              (egs_ivector_id is not None)
              and (ivector_extractor_id is None)
          ):
              logger.warning(
                  "The ivector ids are used inconsistently. It's your "
                  "responsibility to make sure the ivector extractor "
                  "has been used consistently"
              )
              logger.warning(
                  "ivector id for egs: {0} in dir {1}".format(
                      egs_ivector_id, egs_dir
                  )
              )
              logger.warning(
                  "ivector id for extractor: {0}".format(
                      ivector_extractor_id
                  )
              )
          elif (
              (egs_ivector_dim > 0)
              and (egs_ivector_id is None)
              and (ivector_extractor_id is None)
          ):
              logger.warning(
                  "The ivector ids are not used. It's your "
                  "responsibility to make sure the ivector extractor "
                  "has been used consistently"
              )
          elif ivector_extractor_id != egs_ivector_id:
              raise Exception(
                  "The egs were generated using a different ivector "
                  "extractor. id1 = {0}, id2={1}".format(
                      ivector_extractor_id, egs_ivector_id
                  )
              )
  
          if (
              egs_left_context < left_context
              or egs_right_context < right_context
          ):
              raise Exception(
                  "The egs have insufficient (l,r) context ({0},{1}) "
                  "versus expected ({2},{3})".format(
                      egs_left_context,
                      egs_right_context,
                      left_context,
                      right_context,
                  )
              )
  
          # the condition on the initial/final context is an equality condition,
          # not an inequality condition, as there is no mechanism to 'correct' the
          # context (by subtracting context) while copying the egs, like there is
          # for the regular left-right context.  If the user is determined to use
          # previously dumped egs, they may be able to slightly adjust the
          # --egs.chunk-left-context-initial and --egs.chunk-right-context-final
          # options to make things matched up.  [note: the model l/r context gets
          # added in, so you have to correct for changes in that.]
          if (
              egs_left_context_initial != left_context_initial
              or egs_right_context_final != right_context_final
          ):
              raise Exception(
                  "The egs have incorrect initial/final (l,r) context "
                  "({0},{1}) versus expected ({2},{3}).  See code from "
                  "where this exception was raised for more info".format(
                      egs_left_context_initial,
                      egs_right_context_final,
                      left_context_initial,
                      right_context_final,
                  )
              )
  
          frames_per_eg_str = (
              open("{0}/info/frames_per_eg".format(egs_dir))
              .readline()
              .rstrip()
          )
          if not validate_chunk_width(frames_per_eg_str):
              raise Exception(
                  "Invalid frames_per_eg in directory {0}/info".format(
                      egs_dir
                  )
              )
          num_archives = int(
              open("{0}/info/num_archives".format(egs_dir)).readline()
          )
  
          return [
              egs_left_context,
              egs_right_context,
              frames_per_eg_str,
              num_archives,
          ]
      except (IOError, ValueError):
          logger.error(
              "The egs dir {0} has missing or "
              "malformed files.".format(egs_dir)
          )
          raise
  
imports: from __future__ import division
  import argparse
  import glob
  import logging
  import os
  import math
  import re
  import shutil
  import libs.common
  from libs.nnet3.train.dropout_schedule import *
  import unittest
label_desc: Use image node_id 15 for calling a global function with example usage: verify_egs_dir(egs_dir, feat_dim, ivector_dim, ivector_extractor_id, left_context, right_context, left_context_initial, right_context_final) and returns: list