class_docstr: Create index file for dataloader.
docstr: Create index file for dataloader.
code: def run(self):
      """
      Create index file for dataloader.
      """
      if os.path.exists(self.index_file):
          return
      logger.warning(
          "%s not found. Attempting to create..." % self.index_file
      )
      assert os.path.exists(self.path)
      subdirs = glob.iglob(os.path.join(self.path, "*"))
      subdirs = [x for x in subdirs if os.path.isdir(x)]
      classes = sorted([os.path.basename(x) for x in subdirs])
      class_map = {
          key: val
          for key, val in zip(classes, list(range(len(classes))))
      }
      with open(self.index_file, "w") as fd:
          fd.write("filename,label1\n")
          for subdir in subdirs:
              label = class_map[os.path.basename(subdir)]
              files = glob.iglob(os.path.join(subdir, self.pattern))
              for filename in files:
                  rel_path = os.path.join(
                      os.path.basename(subdir),
                      os.path.basename(filename),
                  )
                  fd.write(rel_path + "," + str(label) + "\n")
      logger.info("Created index file: %s" % self.index_file)
  
file_path: neon/neon/data/indexer.py
imports: from builtins import str, zip
  import os
  import glob
  import logging
  from neon import NervanaObject
label_desc: Use image node_id 2 for calling the Indexer obj's underlying member method code with example usage: obj.run() without return types