<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):
 """Fit the PyNNDescent transformer to build KNN graphs with neighbors given by the dataset X. Parameters X : array-like, shape (n_samples, n_features) Sample data Returns ------- transformer : PyNNDescentTransformer The trained transformer """

        self.n_samples_fit = X.shape[0]

        if self.metric_kwds is None:
            metric_kwds = {}
        else:
            metric_kwds = self.metric_kwds

        self.pynndescent_ = NNDescent(
            X,
            self.metric,
            metric_kwds,
            self.n_neighbors,
            self.n_trees,
            self.leaf_size,
            self.pruning_level,
            self.tree_init,
            self.random_state,
            self.algorithm,
            self.max_candidates,
            self.n_iters,
            self.early_termination_value,
            self.sampling_rate,
        )

        return self