code: def read_contents(contents_file, check_for_missing=True):
      """Read contents file
  
      A contents file is a list of filenames within the directory,
      with comments marked by '#' in the normal way.
  
      Parameters
      ----------
      contents_file : str
          location of the contents file
  
      Returns
      -------
      L : list
          list of filenames from the contents
      """
      if not os.path.exists(contents_file):
          warnings.warn(
              "Contents file not found in {}. "
              "Skipping directory".format(contents_file)
          )
          return []
  
      if check_for_missing:
          contents_dir = os.path.split(contents_file)[0]
          files = os.listdir(contents_dir)
      else:
          contents_dir = None
          files = None
  
      L = []
      for line in open(contents_file):
          filename = line.split("#")[0].strip()
          if len(filename) == 0:
              continue
  
          if check_for_missing and (filename not in files):
              raise ValueError(
                  "Fatal: file %s not found in %s"
                  % (filename, contents_dir)
              )
  
          L.append(filename)
  
      return L
  
imports: import sys
  import os
  import traceback
  import token
  import tokenize
  import gc
  import shutil
  import glob
  import warnings
  import matplotlib
  from matplotlib import image
  from matplotlib import pyplot
label_desc: Use image node_id 2 for calling a global function with example usage: read_contents(contents_file, check_for_missing) and returns: L, list