class_docstr: Creates `Dataset` objects from input json files.
  
  This class provides conveniences to load data from json files.
  It's possible to directly featurize data from json files using
  pandas, but this class may prove useful if you're processing
  large json files that you don't want to manipulate directly in
  memory.
  
  It is meant to load JSON files formatted as "records" in line
  delimited format, which allows for sharding.
  ``list like [{column -> value}, ... , {column -> value}]``.
  
  Examples
  --------
  Let's create the sample dataframe.
  
  >>> composition = ["LiCoO2", "MnO2"]
  >>> labels = [1.5, 2.3]
  >>> import pandas as pd
  >>> df = pd.DataFrame(list(zip(composition, labels)), columns=["composition", "task"])
  
  Dump the dataframe to the JSON file formatted as "records" in line delimited format and
  load the json file by JsonLoader.
  
  >>> import tempfile
  >>> import deepchem as dc
  >>> with dc.utils.UniversalNamedTemporaryFile(mode='w') as tmpfile:
  ...     df.to_json(tmpfile.name, orient='records', lines=True)
  ...     featurizer = dc.feat.ElementPropertyFingerprint()
  ...     loader = dc.data.JsonLoader(["task"], feature_field="composition", featurizer=featurizer)
  ...     dataset = loader.create_dataset(tmpfile.name)
  >>> len(dataset)
  2
class_docstr_tok: ["Creates","`","Dataset","`","objects","from","input","json","files",".","This","class","provides","conveniences","to","load","data","from","json","files",".","It","'s","possible","to","directly","featurize","data","from","json","files","using","pandas",",","but","this","class","may","prove","useful","if","you","'re","processing","large","json","files","that","you","do","n't","want","to","manipulate","directly","in","memory",".","It","is","meant","to","load","JSON","files","formatted","as","``","records","''","in","line","delimited","format",",","which","allows","for","sharding",".","``","list","like","[","{","column","-",">","value","}",",","...",",","{","column","-",">","value","}","]","``",".","Examples","--","--","--","--","Let","'s","create","the","sample","dataframe",".",">",">",">","composition","=","[","``","LiCoO2","''",",","``","MnO2","''","]",">",">",">","labels","=","[","1.5",",","2.3","]",">",">",">","import","pandas","as","pd",">",">",">","df","=","pd.DataFrame","(","list","(","zip","(","composition",",","labels",")",")",",","columns=","[","``","composition","''",",","``","task","''","]",")","Dump","the","dataframe","to","the","JSON","file","formatted","as","``","records","''","in","line","delimited","format","and","load","the","json","file","by","JsonLoader",".",">",">",">","import","tempfile",">",">",">","import","deepchem","as","dc",">",">",">","with","dc.utils.UniversalNamedTemporaryFile","(","mode=","'","w","'",")","as","tmpfile",":","...","df.to_json","(","tmpfile.name",",","orient='records","'",",","lines=True",")","...","featurizer","=","dc.feat.ElementPropertyFingerprint","(",")","...","loader","=","dc.data.JsonLoader","(","[","``","task","''","]",",","feature_field=","''","composition","''",",","featurizer=featurizer",")","...","dataset","=","loader.create_dataset","(","tmpfile.name",")",">",">",">","len","(","dataset",")","2"]
docstr: Creates a `Dataset` from input JSON files.
  
  Parameters
  ----------
  input_files: OneOrMany[str]
      List of JSON filenames.
  data_dir: Optional[str], default None
      Name of directory where featurized data is stored.
  shard_size: int, optional (default 8192)
      Shard size when loading data.
  
  Returns
  -------
  DiskDataset
      A `DiskDataset` object containing a featurized representation of data
      from `input_files`.
docstr_tok: ["Creates","a","`","Dataset","`","from","input","JSON","files",".","Parameters","--","--","--","--","--","input_files",":","OneOrMany","[","str","]","List","of","JSON","filenames",".","data_dir",":","Optional","[","str","]",",","default","None","Name","of","directory","where","featurized","data","is","stored",".","shard_size",":","int",",","optional","(","default","8192",")","Shard","size","when","loading","data",".","Returns","--","--","--","-","DiskDataset","A","`","DiskDataset","`","object","containing","a","featurized","representation","of","data","from","`","input_files","`","."]
code: def create_dataset(
      self,
      input_files: OneOrMany[str],
      data_dir: Optional[str] = None,
      shard_size: Optional[int] = 8192,
  ) -> DiskDataset:
      """Creates a `Dataset` from input JSON files.
  
      Parameters
      ----------
      input_files: OneOrMany[str]
          List of JSON filenames.
      data_dir: Optional[str], default None
          Name of directory where featurized data is stored.
      shard_size: int, optional (default 8192)
          Shard size when loading data.
  
      Returns
      -------
      DiskDataset
          A `DiskDataset` object containing a featurized representation of data
          from `input_files`.
      """
      if not isinstance(input_files, list):
          try:
              if isinstance(input_files, str):
                  input_files = [input_files]
              else:
                  input_files = list(input_files)
          except TypeError:
              raise ValueError(
                  "input_files is of an unrecognized form. Must be one filename or a list of filenames."
              )
  
      def shard_generator():
          """Yield X, y, w, and ids for shards."""
          for shard_num, shard in enumerate(
              self._get_shards(input_files, shard_size)
          ):
              time1 = time.time()
              X, valid_inds = self._featurize_shard(shard)
              if self.id_field:
                  ids = shard[self.id_field].values
              else:
                  ids = np.ones(len(valid_inds))
              ids = ids[valid_inds]
  
              if len(self.tasks) > 0:
                  # Featurize task results if they exist.
                  y, w = _convert_df_to_numpy(shard, self.tasks)
  
                  if self.label_field:
                      y = shard[self.label_field]
                  if self.weight_field:
                      w = shard[self.weight_field]
  
                  # Filter out examples where featurization failed.
                  y, w = (y[valid_inds], w[valid_inds])
                  assert len(X) == len(ids) == len(y) == len(w)
              else:
                  # For prospective data where results are unknown, it
                  # makes no sense to have y values or weights.
                  y, w = (None, None)
                  assert len(X) == len(ids)
  
              time2 = time.time()
              logger.info(
                  "TIMING: featurizing shard %d took %0.3f s"
                  % (shard_num, time2 - time1)
              )
              yield X, y, w, ids
  
      return DiskDataset.create_dataset(
          shard_generator(), data_dir, self.tasks
      )
  
imports: import os
  import tempfile
  import zipfile
  import time
  import logging
  import warnings
  from typing import List, Optional, Tuple, Any, Sequence, Union, Iterator
  import pandas
  import numpy
  from deepchem.utils.typing import OneOrMany
  from deepchem.utils.data_utils import load_image_files, load_csv_files, load_json_files, load_sdf_files, unzip_file
  from deepchem.feat import UserDefinedFeaturizer, Featurizer
  from deepchem.data import Dataset, DiskDataset, NumpyDataset, ImageDataset
  from deepchem.feat.molecule_featurizers import OneHotFeaturizer
  from deepchem.utils.genomics_utils import encode_bio_sequence
label_desc: Use image node_id 2 for calling the JsonLoader obj's underlying member method code with example usage: obj.create_dataset(input_files, data_dir, shard_size) and returns: DiskDataset