<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def source(inp, features=None, top=None, chunksize=None, **kw):
 r""" Defines trajectory data source This function defines input trajectories without loading them. You can pass the resulting object into transformers such as :func:`pyemma.coordinates.tica` or clustering algorithms such as :func:`pyemma.coordinates.cluster_kmeans`. Then, the data will be streamed instead of being loaded, thus saving memory. You can also use this function to construct the first stage of a data processing :func:`pipeline`. Parameters inp : str (file name) or ndarray or list of strings (file names) or list of ndarrays or nested list of str|ndarray (1 level) The inp file names or input data. Can be given in any of these ways: 1. File name of a single trajectory. It can have any of the molecular dynamics trajectory formats or raw data formats specified in :py:func:`load`. 2. List of trajectory file names. It can have any of the molecular dynamics trajectory formats or raw data formats specified in :py:func:`load`. 3. Molecular dynamics trajectory in memory as a numpy array of shape (T, N, 3) with T time steps, N atoms each having three (x,y,z) spatial coordinates. 4. List of molecular dynamics trajectories in memory, each given as a numpy array of shape (T_i, N, 3), where trajectory i has T_i time steps and all trajectories have shape (N, 3). 5. Trajectory of some features or order parameters in memory as a numpy array of shape (T, N) with T time steps and N dimensions. 6. List of trajectories of some features or order parameters in memory, each given as a numpy array of shape (T_i, N), where trajectory i has T_i time steps and all trajectories have N dimensions. 7. List of NumPy array files (.npy) of shape (T, N). Note these arrays are not being loaded completely, but mapped into memory (read-only). 8. List of tabulated ASCII files of shape (T, N). 9. Nested lists (1 level) like), eg.: the grouped fragments will be treated as a joint trajectory. features : MDFeaturizer, optional, default = None a featurizer object specifying how molecular dynamics files should be read (e.g. intramolecular distances, angles, dihedrals, etc). This parameter only makes sense if the input comes in the form of molecular dynamics trajectories or data, and will otherwise create a warning and have no effect. top : str, mdtraj.Trajectory or mdtraj.Topology, optional, default = None A topology file name. This is needed when molecular dynamics trajectories are given and no featurizer is given. In this case, only the Cartesian coordinates will be read. You can also pass an already loaded mdtraj.Topology object. If it is an mdtraj.Trajectory object, the topology will be extracted from it. chunksize: int, default=None Number of data frames to process at once. Choose a higher value here, to optimize thread usage and gain processing speed. If None is passed, use the default value of the underlying reader/data source. Choose zero to disable chunking at all. Returns ------- reader : :class:`DataSource <pyemma.coordinates.data._base.datasource.DataSource>` object See also -------- :func:`pyemma.coordinates.load` If your memory is big enough to load all features into memory, don't bother using source - working in memory is faster! :func:`pyemma.coordinates.pipeline` The data input is the first stage for your pipeline. Add other stages to it and build a pipeline to analyze big data in streaming mode. Examples -------- Create a reader for NumPy files: Create a reader for trajectory files and select some distance as feature: create a reader for a csv file: Create a reader for huge NumPy in-memory arrays to process them in huge chunks to avoid memory issues: Returns ------- reader : a reader instance .. autoclass:: pyemma.coordinates.data.interface.ReaderInterface :members: :undoc-members: .. rubric:: Methods .. autoautosummary:: pyemma.coordinates.data.interface.ReaderInterface :methods: .. rubric:: Attributes .. autoautosummary:: pyemma.coordinates.data.interface.ReaderInterface :attributes: """

    from pyemma.coordinates.data._base.iterable import Iterable
    from pyemma.coordinates.data.util.reader_utils import create_file_reader

    from pyemma.util.reflection import get_default_args
    cs = _check_old_chunksize_arg(chunksize, get_default_args(source)['chunksize'], **kw)

    # CASE 1: input is a string or list of strings
    # check: if single string create a one-element list
    if isinstance(inp, _string_types) or (
            isinstance(inp, (list, tuple))
            and (any(isinstance(item, (list, tuple, _string_types)) for item in inp) or len(inp) is 0)):
        reader = create_file_reader(inp, top, features, chunksize=cs, **kw)

    elif isinstance(inp, _np.ndarray) or (isinstance(inp, (list, tuple))
                                          and (any(isinstance(item, _np.ndarray) for item in inp) or len(inp) is 0)):
        # CASE 2: input is a (T, N, 3) array or list of (T_i, N, 3) arrays
        # check: if single array, create a one-element list
        # check: do all arrays have compatible dimensions (*, N, 3)? If not: raise ValueError.
        # check: if single array, create a one-element list
        # check: do all arrays have compatible dimensions (*, N)? If not: raise ValueError.
        # create MemoryReader
        from pyemma.coordinates.data.data_in_memory import DataInMemory as _DataInMemory
        reader = _DataInMemory(inp, chunksize=cs, **kw)
    elif isinstance(inp, Iterable):
        inp.chunksize = cs
        return inp
    else:
        raise ValueError('unsupported type (%s) of input' % type(inp))

    return reader