class_docstr: Base class for input data adapter.
  In order to simplify the training code path, all the input data
  object will be converted to a `generator` if possible.
  The sample usage of this class is like:
  
  ```
  x = list(range(100))
  adapter_cls = [ArrayDataAdapter, ..., ListsOfScalarsDataAdapter]
  applicable_adapters = [cls for cls in adapter_cls if cls.can_handle(x)]
  if len(applicable_adapters) != 1:
    raise ValueError("Expect only one adapter class to handle the input")
  dataset = applicable_adapters[0](x).get_dataset()
  for data in dataset():
    # training
  ```
docstr: Create a DataAdapter based on data inputs.
  The caller must make sure to call `can_handle()` first before invoking this
  method. Provide unsupported data type will result into unexpected behavior.
  
  Arguments:
    x: input features.
    y: target labels. Note that y could be None in the case of prediction.
    **kwargs: Other keyword arguments for DataAdapter during the construction
      of the generator. For example:
  
        - Numpy data might have `sample_weights` which will be used for
          weighting the loss function during training.
        - Numpy data might need to have `batch_size` parameter when constructing
          the dataset and iterator.
  
      DataAdapter might choose to ignore any keyword argument if it doesn't
      use it, or raise exception if any required argument is not provide.
docstr_tok: ["Create","a","DataAdapter","based","on","data","inputs",".","The","caller","must","make","sure","to","call","`","can_handle","(",")","`","first","before","invoking","this","method",".","Provide","unsupported","data","type","will","result","into","unexpected","behavior",".","Arguments",":","x",":","input","features",".","y",":","target","labels",".","Note","that","y","could","be","None","in","the","case","of","prediction",".","*","*","kwargs",":","Other","keyword","arguments","for","DataAdapter","during","the","construction","of","the","generator",".","For","example",":","-","Numpy","data","might","have","`","sample_weights","`","which","will","be","used","for","weighting","the","loss","function","during","training",".","-","Numpy","data","might","need","to","have","`","batch_size","`","parameter","when","constructing","the","dataset","and","iterator",".","DataAdapter","might","choose","to","ignore","any","keyword","argument","if","it","doesn't","use","it",",","or","raise","exception","if","any","required","argument","is","not","provide","."]
code: def __init__(self, x, y=None, **kwargs):
      """Create a DataAdapter based on data inputs.
      The caller must make sure to call `can_handle()` first before invoking this
      method. Provide unsupported data type will result into unexpected behavior.
  
      Arguments:
        x: input features.
        y: target labels. Note that y could be None in the case of prediction.
        **kwargs: Other keyword arguments for DataAdapter during the construction
          of the generator. For example:
  
            - Numpy data might have `sample_weights` which will be used for
              weighting the loss function during training.
            - Numpy data might need to have `batch_size` parameter when constructing
              the dataset and iterator.
  
          DataAdapter might choose to ignore any keyword argument if it doesn't
          use it, or raise exception if any required argument is not provide.
      """
      if not self.can_handle(x, y):
          raise ValueError(
              "{} Cannot handle input {}, {}".format(
                  self.__class__, x, y
              )
          )
  
file_path: elegy/elegy/data/data_adapter.py
imports: import abc
  import typing
  import six
label_desc: Use image node_id 2 to create a new DataAdapter object from inherited base classes: object with example: obj = DataAdapter(x, y)