SMOTE is an oversampling method to generate data by drawing a distance between a point and a random neighbor. It is used to grow the size of a minority class.
Note: the first part (until line 6) is the algorithm preliminaries. It allows to define what part of the minority class is going to be used for the new data generation.