def tokenize(records):
    """Create a token mapping from objects to integers.

    Parameters
    ----------
    records : array_like of iterables.
        Collection of nested arrays.

    Returns
    -------
    enum_map : dict
        Enumeration map of objects (any hashable) to tokens (int).
    """
    unique_items = set(i for row in records for i in row)
    unique_items = sorted(list(unique_items))
    return dict([(k, n) for n, k in enumerate(unique_items)])