<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calculate_dimensionality_of_site(bonded_structure, site_index, inc_vertices=False):
 """ Calculates the dimensionality of the component containing the given site. Implements directly the modified breadth-first-search algorithm described in Algorithm 1 of: P. Larsem, M. Pandey, M. Strange, K. W. Jacobsen, 2018, arXiv:1808.02114 Args: bonded_structure (StructureGraph):
 A structure with bonds, represented as a pymatgen structure graph. For example, generated using the CrystalNN.get_bonded_structure() method. site_index (int):
 The index of a site in the component of interest. inc_vertices (bool, optional):
 Whether to return the vertices (site images) of the component. Returns: (int or tuple):
 If inc_vertices is False, the dimensionality of the component will be returned as an int. If inc_vertices is true, the function will return a tuple of (dimensionality, vertices), where vertices is a list of tuples. E.g. [(0, 0, 0), (1, 1, 1)]. """

    def neighbours(comp_index):
        return [(s.index, s.jimage) for s
                in bonded_structure.get_connected_sites(comp_index)]

    def rank(vertices):
        if len(vertices) == 0:
            return -1
        elif len(vertices) == 1:
            return 0
        else:
            vertices = np.array(list(vertices))
            return np.linalg.matrix_rank(vertices[1:] - vertices[0])

    connected_sites = {i: neighbours(i) for i in
                       range(bonded_structure.structure.num_sites)}

    seen_vertices = set()
    seen_comp_vertices = defaultdict(set)

    queue = [(site_index, (0, 0, 0))]
    while len(queue) > 0:
        comp_i, image_i = queue.pop(0)

        if (comp_i, image_i) in seen_vertices:
            continue
        seen_vertices.add((comp_i, image_i))

        if (rank(seen_comp_vertices[comp_i].union({image_i})) >
                rank(seen_comp_vertices[comp_i])):
            seen_comp_vertices[comp_i].add(image_i)

        for comp_j, image_j in connected_sites[comp_i]:

            image_j = tuple(np.add(image_j, image_i))

            if (comp_j, image_j) in seen_vertices:
                continue

            if (rank(seen_comp_vertices[comp_j].union({image_j})) >
                    rank(seen_comp_vertices[comp_j])):
                queue.append((comp_j, image_j))

    if inc_vertices:
        return (rank(seen_comp_vertices[site_index]),
                list(seen_comp_vertices[site_index]))
    else:
        return rank(seen_comp_vertices[site_index])