<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_reduce(self, map_function, data, function_kwargs=None, chunk_size=None, data_length=None):
 """ This method contains the core functionality of the DistributorBaseClass class. It maps the map_function to each element of the data and reduces the results to return a flattened list. How the jobs are calculated, is determined by the classes :func:`tsfresh.utilities.distribution.DistributorBaseClass.distribute` method, which can distribute the jobs in multiple threads, across multiple processing units etc. To not transport each element of the data individually, the data is split into chunks, according to the chunk size (or an empirical guess if none is given). By this, worker processes not tiny but adequate sized parts of the data. :param map_function: a function to apply to each data item. :type map_function: callable :param data: the data to use in the calculation :type data: iterable :param function_kwargs: parameters for the map function :type function_kwargs: dict of string to parameter :param chunk_size: If given, chunk the data according to this size. If not given, use an empirical value. :type chunk_size: int :param data_length: If the data is a generator, you have to set the length here. If it is none, the length is deduced from the len of the data. :type data_length: int :return: the calculated results :rtype: list """

        if data_length is None:
            data_length = len(data)

        if not chunk_size:
            chunk_size = self.calculate_best_chunk_size(data_length)

        chunk_generator = self.partition(data, chunk_size=chunk_size)

        map_kwargs = {"map_function": map_function, "kwargs": function_kwargs}

        if hasattr(self, "progressbar_title"):
            total_number_of_expected_results = math.ceil(data_length / chunk_size)
            result = tqdm(self.distribute(_function_with_partly_reduce, chunk_generator, map_kwargs),
                          total=total_number_of_expected_results,
                          desc=self.progressbar_title, disable=self.disable_progressbar)
        else:
            result = self.distribute(_function_with_partly_reduce, chunk_generator, map_kwargs),

        result = list(itertools.chain.from_iterable(result))

        return result