<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_projects(uid, include_shared_projects=True, projects_ids_list_filter=None, **kwargs):
 """ Get all the projects owned by the specified user. These include projects created by the user, but also ones shared with the user. For shared projects, only include networks in those projects which are accessible to the user. the include_shared_projects flag indicates whether to include projects which have been shared with the user, or to only return projects created directly by this user. """

    req_user_id = kwargs.get('user_id')

    ##Don't load the project's networks. Load them separately, as the networks
    #must be checked individually for ownership
    projects_qry = db.DBSession.query(Project)

    log.info("Getting projects for %s", uid)

    if include_shared_projects is True:
        projects_qry = projects_qry.join(ProjectOwner).filter(Project.status=='A',
                                                        or_(ProjectOwner.user_id==uid,
                                                           Project.created_by==uid))
    else:
        projects_qry = projects_qry.join(ProjectOwner).filter(Project.created_by==uid)

    if projects_ids_list_filter is not None:
        # Filtering the search of project id
        if isinstance(projects_ids_list_filter, str):
            # Trying to read a csv string
            projects_ids_list_filter = eval(projects_ids_list_filter)
            if type(projects_ids_list_filter) is int:
                projects_qry = projects_qry.filter(Project.id==projects_ids_list_filter)
            else:
                projects_qry = projects_qry.filter(Project.id.in_(projects_ids_list_filter))



    projects_qry = projects_qry.options(noload('networks')).order_by('id')

    projects_i = projects_qry.all()

    log.info("Project query done for user %s. %s projects found", uid, len(projects_i))

    user = db.DBSession.query(User).filter(User.id==req_user_id).one()
    isadmin = user.is_admin()

    #Load each
    projects_j = []
    for project_i in projects_i:
        #Ensure the requesting user is allowed to see the project
        project_i.check_read_permission(req_user_id)
        #lazy load owners
        project_i.owners

        network_qry = db.DBSession.query(Network)\
                                .filter(Network.project_id==project_i.id,\
                                        Network.status=='A')
        if not isadmin:
            network_qry.outerjoin(NetworkOwner)\
            .filter(or_(
                and_(NetworkOwner.user_id != None,
                     NetworkOwner.view == 'Y'),
                Network.created_by == uid
            ))

        networks_i = network_qry.all()

        networks_j = []
        for network_i in networks_i:
            network_i.owners
            net_j = JSONObject(network_i)
            if net_j.layout is not None:
                net_j.layout = JSONObject(net_j.layout)
            else:
                net_j.layout = JSONObject({})
            networks_j.append(net_j)

        project_j = JSONObject(project_i)
        project_j.networks = networks_j
        projects_j.append(project_j)

    log.info("Networks loaded projects for user %s", uid)

    return projects_j