<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def map(self, func, index=None, value_shape=None, dtype=None, with_keys=False):
 """ Map an array -> array function over each record. Parameters func : function A function of a single record. index : array-like, optional, default = None If known, the index to be used following function evaluation. value_shape : int, optional, default=None Known shape of values resulting from operation. Only valid in spark mode. dtype : numpy.dtype, optional, default = None If known, the type of the data following function evaluation. with_keys : boolean, optional, default = False If true, function should be of both tuple indices and series values. """

        # if new index is given, can infer missing value_shape
        if value_shape is None and index is not None:
            value_shape = len(index)

        if isinstance(value_shape, int):
            values_shape = (value_shape, )
        new = super(Series, self).map(func, value_shape=value_shape, dtype=dtype, with_keys=with_keys)

        if index is not None:
            new.index = index
        # if series shape did not change and no index was supplied, propagate original index
        else:
            if len(new.index) == len(self.index):
                new.index = self.index

        return new