class_docstr: Handles loading of CSV files with user-defined features.
  
  This is a convenience class that allows for descriptors already present in a
  CSV file to be extracted without any featurization necessary.
  
  Examples
  --------
  Let's suppose we have some descriptors and labels. (Imagine that these
  descriptors have been computed by an external program.)
  
  >>> desc1 = [1, 43]
  >>> desc2 = [-2, -22]
  >>> labels = [1.5, 2.3]
  >>> ids = ["cp1", "cp2"]
  
  Let's put these in a dataframe.
  
  >>> import pandas as pd
  >>> df = pd.DataFrame(list(zip(ids, desc1, desc2, labels)), columns=["id", "desc1", "desc2", "task1"])
  
  Let's now write this to disk somewhere. We can now use `UserCSVLoader` to
  process this CSV dataset.
  
  >>> import tempfile
  >>> import deepchem as dc
  >>> featurizer = dc.feat.UserDefinedFeaturizer(["desc1", "desc2"])
  >>> with dc.utils.UniversalNamedTemporaryFile(mode='w') as tmpfile:
  ...     df.to_csv(tmpfile.name)
  ...     loader = dc.data.UserCSVLoader(["task1"], id_field="id",
  ...                              featurizer=featurizer)
  ...     dataset = loader.create_dataset(tmpfile.name)
  >>> len(dataset)
  2
  >>> dataset.X[0, 0]
  1
  
  The difference between `UserCSVLoader` and `CSVLoader` is that our
  descriptors (our features) have already been computed for us, but are spread
  across multiple columns of the CSV file.
  
  Of course in practice you should already have your data in a CSV file if
  you're using `UserCSVLoader`. If your data is already in memory, use
  `InMemoryLoader` instead.
class_docstr_tok: ["Handles","loading","of","CSV","files","with","user-defined","features",".","This","is","a","convenience","class","that","allows","for","descriptors","already","present","in","a","CSV","file","to","be","extracted","without","any","featurization","necessary",".","Examples","--","--","--","--","Let","'s","suppose","we","have","some","descriptors","and","labels",".","(","Imagine","that","these","descriptors","have","been","computed","by","an","external","program",".",")",">",">",">","desc1","=","[","1",",","43","]",">",">",">","desc2","=","[","-2",",","-22","]",">",">",">","labels","=","[","1.5",",","2.3","]",">",">",">","ids","=","[","``","cp1","''",",","``","cp2","''","]","Let","'s","put","these","in","a","dataframe",".",">",">",">","import","pandas","as","pd",">",">",">","df","=","pd.DataFrame","(","list","(","zip","(","ids",",","desc1",",","desc2",",","labels",")",")",",","columns=","[","``","id","''",",","``","desc1","''",",","``","desc2","''",",","``","task1","''","]",")","Let","'s","now","write","this","to","disk","somewhere",".","We","can","now","use","`","UserCSVLoader","`","to","process","this","CSV","dataset",".",">",">",">","import","tempfile",">",">",">","import","deepchem","as","dc",">",">",">","featurizer","=","dc.feat.UserDefinedFeaturizer","(","[","``","desc1","''",",","``","desc2","''","]",")",">",">",">","with","dc.utils.UniversalNamedTemporaryFile","(","mode=","'","w","'",")","as","tmpfile",":","...","df.to_csv","(","tmpfile.name",")","...","loader","=","dc.data.UserCSVLoader","(","[","``","task1","''","]",",","id_field=","''","id","''",",","...","featurizer=featurizer",")","...","dataset","=","loader.create_dataset","(","tmpfile.name",")",">",">",">","len","(","dataset",")","2",">",">",">","dataset.X","[","0",",","0","]","1","The","difference","between","`","UserCSVLoader","`","and","`","CSVLoader","`","is","that","our","descriptors","(","our","features",")","have","already","been","computed","for","us",",","but","are","spread","across","multiple","columns","of","the","CSV","file",".","Of","course","in","practice","you","should","already","have","your","data","in","a","CSV","file","if","you","'re","using","`","UserCSVLoader","`",".","If","your","data","is","already","in","memory",",","use","`","InMemoryLoader","`","instead","."]
docstr: Featurizes a shard of an input dataframe.
  
  Parameters
  ----------
  shard: pd.DataFrame
      DataFrame that holds a shard of the input CSV file
  
  Returns
  -------
  features: np.ndarray
      Features extracted from CSV file.
  valid_inds: np.ndarray
      Indices of rows in source CSV with valid data.
docstr_tok: ["Featurizes","a","shard","of","an","input","dataframe",".","Parameters","--","--","--","--","--","shard",":","pd.DataFrame","DataFrame","that","holds","a","shard","of","the","input","CSV","file","Returns","--","--","--","-","features",":","np.ndarray","Features","extracted","from","CSV","file",".","valid_inds",":","np.ndarray","Indices","of","rows","in","source","CSV","with","valid","data","."]
code: def _featurize_shard(
      self, shard: pd.DataFrame
  ) -> Tuple[np.ndarray, np.ndarray]:
      """Featurizes a shard of an input dataframe.
  
      Parameters
      ----------
      shard: pd.DataFrame
          DataFrame that holds a shard of the input CSV file
  
      Returns
      -------
      features: np.ndarray
          Features extracted from CSV file.
      valid_inds: np.ndarray
          Indices of rows in source CSV with valid data.
      """
      assert isinstance(self.featurizer, UserDefinedFeaturizer)
      time1 = time.time()
      feature_fields = self.featurizer.feature_fields
      shard[feature_fields] = shard[feature_fields].apply(pd.to_numeric)
      X_shard = shard[feature_fields].to_numpy()
      time2 = time.time()
      logger.info(
          "TIMING: user specified processing took %0.3f s"
          % (time2 - time1)
      )
      return (X_shard, np.ones(len(X_shard), dtype=bool))
  
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 UserCSVLoader obj's underlying member method code with example usage: obj._featurize_shard(shard) and returns: X_shard,  np