249 for w in word_offsets[sep_index + 1 :]
250 ]
251 # update again the sep_offset
252 sep_offset_value = max([w for w in word_offsets if w is not None]) + 1253 # replace first None occurrence with sep_offset, it should be the last SEP
254 sep_index = word_offsets.index(None)
255 word_offsets[sep_index] = sep_offset_value
233
234 # here we retrieve the max offset for the sample, which will be used as SEP offset
235 # and also as padding value for the offsets
236 sep_offset_value = max([w for w in word_offsets[:sep_index] if w is not None]) + 1237
238 word_offsets[sep_index] = sep_offset_value
239 # if there is a text pair, we need to adjust the offsets for the second text
Using a container in place of a generator for a calls that can accept both, slows down the performance. Consider using generators for all function calls which accept both containers and genertors.
# List comprehension is unnecessary here
set([student.name for student in student])
sum([y**2 for y in list(range(10))])
set(student.name for student in students)
sum(y**2 for y in list(range(10)))