<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _words_to_int(self, words, expected_bits=None):
 """ Given a sequence of words which each fit in the internal SPI interface's number of bits per word, returns the value obtained by concatenating each word into a single bit-string. If *expected_bits* is specified, it limits the size of the output to the specified number of bits (by masking off bits above the expected number). If unspecified, no limit will be applied. """

        if expected_bits is None:
            expected_bits = len(words) * self._spi.bits_per_word
        shifts = range(0, expected_bits, self._spi.bits_per_word)[::-1]
        mask = 2 ** expected_bits - 1
        return reduce(or_, (word << shift for word, shift in zip(words, shifts))) & mask