<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_records(cls, records, dataset=None, on=None, value=None, index=[], drop_missing=False, element=None, **kwargs):
 """ Load data from a collection of `cartopy.io.shapereader.Record` objects and optionally merge it with a dataset to assign values to each polygon and form a chloropleth. Supplying just records will return an NdOverlayof Shape Elements with a numeric index. If a dataset is supplied, a mapping between the attribute names in the records and the dimension names in the dataset must be supplied. The values assigned to each shape file can then be drawn from the dataset by supplying a ``value`` and keys the Shapes are indexed by specifying one or index dimensions. Parameters records: list of cartopy.io.shapereader.Record Iterator containing Records. dataset: holoviews.Dataset Any HoloViews Dataset type. on: str or list or dict A mapping between the attribute names in the records and the dimensions in the dataset. value: str The value dimension in the dataset the values will be drawn from. index: str or list One or more dimensions in the dataset the Shapes will be indexed by. drop_missing: boolean Whether to drop shapes which are missing from the provides dataset. Returns ------- shapes: Polygons or Path object A Polygons or Path object containing the geometries """

        if dataset is not None and not on:
            raise ValueError('To merge dataset with shapes mapping '
                             'must define attribute(s) to merge on.')

        if util.pd and isinstance(dataset, util.pd.DataFrame):
            dataset = Dataset(dataset)

        if not isinstance(on, (dict, list)):
            on = [on]
        if on and not isinstance(on, dict):
            on = {o: o for o in on}
        if not isinstance(index, list):
            index = [index]

        kdims = []
        for ind in index:
            if dataset and dataset.get_dimension(ind):
                dim = dataset.get_dimension(ind)
            else:
                dim = Dimension(ind)
            kdims.append(dim)


        ddims = []
        if dataset:
            if value:
                vdims = [dataset.get_dimension(value)]
            else:
                vdims = dataset.vdims
            ddims = dataset.dimensions()
            if None in vdims:
                raise ValueError('Value dimension %s not found '
                                 'in dataset dimensions %s' % (value, ddims) )
        else:
            vdims = []

        data = []
        for i, rec in enumerate(records):
            geom = {}
            if dataset:
                selection = {dim: rec.attributes.get(attr, None)
                             for attr, dim in on.items()}
                row = dataset.select(**selection)
                if len(row):
                    values = {k: v[0] for k, v in row.iloc[0].columns().items()}
                elif drop_missing:
                    continue
                else:
                    values = {vd.name: np.nan for vd in vdims}
                geom.update(values)

            if index:
                for kdim in kdims:
                    if kdim in ddims and len(row):
                        k = row[kdim.name][0]
                    elif kdim.name in rec.attributes:
                        k = rec.attributes[kdim.name]
                    else:
                        k = None
                    geom[kdim.name] = k
            geom['geometry'] = rec.geometry
            data.append(geom)

        if element is not None:
            pass
        elif data and data[0]:
            if isinstance(data[0]['geometry'], poly_types):
                element = Polygons
            else:
                element = Path
        else:
            element = Polygons

        return element(data, vdims=kdims+vdims, **kwargs).opts(color=value)