def get_featurize_fn()

in baseline.py [0:0]


def get_featurize_fn(ret, method):
    def featurize(fn):
        rep = replayer.load(fn)
        map = rep.getMap()
        map_size = map['walkability'].shape

        batch = []
        for i in range(0, len(rep), args.skip_frames):
            frames = [rep.getFrame(k) for k in
                      range(i, min(i + args.combine_frames, len(rep)))]
            batch.append(frames)

        if method == 'prev':
            return [
                featurizer.featurize(batch, map_size, perspective=0),
                featurizer.featurize(batch, map_size, perspective=1),
                featurizer.featurize(batch, map_size, perspective=0, full=True),
                featurizer.featurize(batch, map_size, perspective=1, full=True),
            ]

        elif method == 'stat':
            features = featurizer.featurize(batch, map_size, full=True)
            map_hash = hash_map(map)
            '''
            Two players with the same info is considered to be the same 'game'
            for this baseline: All ZvT mu that start at the same location
            should be hashed to a single info. Should be irrespective of p1
            or p2, so we sort.
            '''
            info_hash = tuple(sorted(get_info(rep)))

            if ret:
                return (map_hash, info_hash, features)

            key = (map_hash, info_hash)
            with global_lock:
                if key in all_data:
                    data_tup = all_data[key]
                else:
                    all_data[key] = [np.zeros(features.shape), 0]
                    locks[key] = Lock()
            with locks[key]:
                data_tup = all_data[key]
                acc = data_tup[0]
                if acc.shape[0] < features.shape[0]:
                    acc = np.pad(
                        acc,
                        ((0, features.shape[0] - acc.shape[0]), (0,0), (0,0), (0,0)),
                        mode='constant',
                        constant_values=0)
                view = acc[tuple(slice(0, int(axis)) for axis in features.shape)]
                view += features
                view += features
                data_tup[0] = acc
                data_tup[1] += 1
                all_data[key] = data_tup

            return True
        else:
            raise RuntimeError("No such way to calculate a baseline. "
                               "Check your --method")
    return featurize