<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fit(self, X, y, model_filename=None):
 """Fit FastText according to X, y Parameters: X : list of text each item is a text y: list each item is either a label (in multi class problem) or list of labels (in multi label problem) """

        train_file = "temp.train"
        X = [x.replace("\n", " ") for x in X]
        y = [item[0] for item in y]
        y = [_.replace(" ", "-") for _ in y]
        lines = ["__label__{} , {}".format(j, i) for i, j in zip(X, y)]
        content = "\n".join(lines)
        write(train_file, content)
        if model_filename:
            self.estimator = fasttext.supervised(train_file, model_filename)
        else:
            self.estimator = fasttext.supervised(train_file)
        os.remove(train_file)