class_docstr: A dataset for loading image files specified by a list of entries.
  
  like::
  
      # if written to text file *.lst
      0       0       root/car/0001.jpg
      1       0       root/car/xxxa.jpg
      2       0       root/car/yyyb.jpg
      3       1       root/bus/123.jpg
      4       1       root/bus/023.jpg
      5       1       root/bus/wwww.jpg
  
      # if as a pure list, each item is a list [imagelabel: float or list of float, imgpath]
      [[0, root/car/0001.jpg]
       [0, root/car/xxxa.jpg]
       [0, root/car/yyyb.jpg]
       [1, root/bus/123.jpg]
       [1, root/bus/023.jpg]
       [1, root/bus/wwww.jpg]]
  
  Parameters
  ----------
  root : str
      Path to root directory.
  imglist : str or list
      Specify the path of imglist file or a list directly
  flag : {0, 1}, default 1
      If 0, always convert loaded images to greyscale (1 channel).
      If 1, always convert loaded images to colored (3 channels).
  
  Attributes
  ----------
  items : list of tuples
      List of all images in (filename, label) pairs.
class_docstr_tok: ["A","dataset","for","loading","image","files","specified","by","a","list","of","entries",".","like",":",":","#","if","written","to","text","file","*",".lst","0","0","root\/car\/0001.jpg","1","0","root\/car\/xxxa.jpg","2","0","root\/car\/yyyb.jpg","3","1","root\/bus\/123.jpg","4","1","root\/bus\/023.jpg","5","1","root\/bus\/wwww.jpg","#","if","as","a","pure","list",",","each","item","is","a","list","[","imagelabel",":","float","or","list","of","float",",","imgpath","]","[","[","0",",","root\/car\/0001.jpg","]","[","0",",","root\/car\/xxxa.jpg","]","[","0",",","root\/car\/yyyb.jpg","]","[","1",",","root\/bus\/123.jpg","]","[","1",",","root\/bus\/023.jpg","]","[","1",",","root\/bus\/wwww.jpg","]","]","Parameters","--","--","--","--","--","root",":","str","Path","to","root","directory",".","imglist",":","str","or","list","Specify","the","path","of","imglist","file","or","a","list","directly","flag",":","{","0",",","1","}",",","default","1","If","0",",","always","convert","loaded","images","to","greyscale","(","1","channel",")",".","If","1",",","always","convert","loaded","images","to","colored","(","3","channels",")",".","Attributes","--","--","--","--","--","items",":","list","of","tuples","List","of","all","images","in","(","filename",",","label",")","pairs","."]
code: def __init__(self, root=".", imglist=None, flag=1):
      self._root = os.path.expanduser(root)
      self._flag = flag
      self._imglist = {}
      self._imgkeys = []
      self._handle = None
      array_fn = _mx_np.array if is_np_array() else nd.array
      if isinstance(imglist, str):
          # read from file
          fname = os.path.join(self._root, imglist)
          with open(fname, "rt") as fin:
              for line in iter(fin.readline, ""):
                  line = line.strip().split("\t")
                  label = array_fn(line[1:-1])
                  key = int(line[0])
                  self._imglist[key] = (
                      label,
                      os.path.join(self._root, line[-1]),
                  )
                  self._imgkeys.append(key)
      elif isinstance(imglist, list):
          index = 1
          for img in imglist:
              key = str(index)
              index += 1
              if len(img) > 2:
                  label = array_fn(img[:-1])
              elif isinstance(img[0], numeric_types):
                  label = array_fn([img[0]])
              else:
                  label = array_fn(img[0])
              assert isinstance(img[-1], str)
              self._imglist[key] = (
                  label,
                  os.path.join(self._root, img[-1]),
              )
              self._imgkeys.append(key)
      else:
          raise ValueError(
              "imglist must be filename or list of valid entries, given {}".format(
                  type(imglist)
              )
          )
  
imports: import os
  import gzip
  import tarfile
  import struct
  import warnings
  import numpy
  from ..None import dataset
  from ...utils import download, check_sha1, _get_repo_file_url
  from ....None import ndarray, image, recordio, base
  from ....None import numpy
  from ....util import is_np_array, default_array
  from ....base import numeric_types
label_desc: Use image node_id 1 to create a new ImageListDataset object from inherited base classes: dataset with example: obj = ImageListDataset(root, imglist, flag)