<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _addNoise(self, pattern, noiseLevel, inputSize):
 """ Adds noise to the given pattern and returns the new one. A noiseLevel of 0.1 means that 10% of the ON bits will be replaced by other randomly chosen ON bits. The returned SDR will still contain the same number of bits. """

    if pattern is None:
      return None

    # Bits that could be noise. These can't be from the original set.
    candidateBits = list(set(range(inputSize)) - set(pattern))
    random.shuffle(candidateBits)

    newBits = set()
    for bit in pattern:
      if random.random() < noiseLevel:
        newBits.add(candidateBits.pop())
      else:
        newBits.add(bit)

    return newBits