<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setPermanences(self, segments, presynapticCellsBySource, permanence):
 """ Set the permanence of a specific set of synapses. Any synapses that don't exist will be initialized. Any existing synapses will be overwritten. Conceptually, this method takes a list of [segment, presynapticCell] pairs and initializes their permanence. For each segment, one synapse is added (although one might be added for each "source"). To add multiple synapses to a segment, include it in the list multiple times. The total number of affected synapses is len(segments)*number_of_sources*1. @param segments (numpy array) One segment for each synapse that should be added @param presynapticCellsBySource (dict of numpy arrays) One presynaptic cell for each segment. Example: {"customInputName1": np.array([42, 69])} @param permanence (float) The permanence to assign the synapse """

    permanences = np.repeat(np.float32(permanence), len(segments))

    for source, connections in self.connectionsBySource.iteritems():
      if source in presynapticCellsBySource:
        connections.matrix.setElements(segments, presynapticCellsBySource[source],
                                       permanences)