def get_neighbors(index, lattice_length, width=<NUM_LIT:0>, periodic=False):
if width == <NUM_LIT:0>:<EOL><INDENT>width = lattice_length<EOL><DEDENT>neighbors = []<EOL>coords = divmod(index, width)<EOL>if coords[<NUM_LIT:1>] < width - <NUM_LIT:1>:<EOL><INDENT>neighbors.append(index + <NUM_LIT:1>)<EOL><DEDENT>elif periodic and width > <NUM_LIT:1>:<EOL><INDENT>neighbors.append(index - width + <NUM_LIT:1>)<EOL><DEDENT>if coords[<NUM_LIT:0>] < lattice_length - <NUM_LIT:1>:<EOL><INDENT>neighbors.append(index + width)<EOL><DEDENT>elif periodic:<EOL><INDENT>neighbors.append(index - (lattice_length - <NUM_LIT:1>) * width)<EOL><DEDENT>return neighbors<EOL>
Get the forward neighbors of a site in a lattice.

    :param index: Linear index of operator.
    :type index: int.
    :param lattice_length: The size of the 2D lattice in either dimension
    :type lattice_length: int.
    :param width: Optional parameter to define width.
    :type width: int.
    :param periodic: Optional parameter to indicate periodic boundary
                     conditions.
    :type periodic: bool

    :returns: list of int -- the neighbors in linear index.