import copy


def normalize(beliefs):
    """
    Normalize beliefs-2d-array to ensure the sum of all given values is equal to 1.
    normalizedValue = currValue / sumOfAllValues 
    """
    normalized = copy.deepcopy(beliefs)
    allSum = 0
    for i in range(len(beliefs)):
        allSum += sum(beliefs[i])
        
    for rowIndex in range(len(beliefs)):
        for colIndex in range(len(beliefs[rowIndex])):
            normalized[rowIndex][colIndex] = beliefs[rowIndex][colIndex] / allSum
    return normalized