def METHOD_NAME(self, jr: JumpingRobot, step_phases: list):
    """ Create a factor graph containing collocation constraints.
        - For ground phase, only collocation on the torso link, which is
            enough to determine the constraints for the next step.
            Additional constraints may cause conflict.
        - For air phase, collocation on torso link and all joints.
        - TODO(yetong): For single leg contact, collocation on all joints
    """
    graph = NonlinearFactorGraph()
    collocation = gtd.CollocationScheme.Trapezoidal
    for time_step in range(len(step_phases)):
        phase = step_phases[time_step]
        k_prev = time_step
        k_curr = time_step + 1
        dt_key = gtd.PhaseKey(phase)
        # collocation on joint angles
        if phase == 3:
            collo_joint_names = ["hip_r", "hip_l", "knee_r", "knee_l"]
            for name in collo_joint_names:
                joint = jr.robot.joint(name)
                j = joint.id()
                q_col_cost_model = self.graph_builder.opt(
                ).q_col_cost_model
                v_col_cost_model = self.graph_builder.opt(
                ).v_col_cost_model
                graph.push_back(
                    self.graph_builder.jointMultiPhaseCollocationFactors(
                        j, k_curr, phase, collocation))
        # collocation on torso link
        link = jr.robot.link("torso")
        i = link.id()
        pose_prev_key = gtd.PoseKey(i, k_prev)
        pose_curr_key = gtd.PoseKey(i, k_curr)
        twist_prev_key = gtd.TwistKey(i, k_prev)
        twist_curr_key = gtd.TwistKey(i, k_curr)
        twistaccel_prev_key = gtd.TwistAccelKey(i, k_prev)
        twistaccel_curr_key = gtd.TwistAccelKey(i, k_curr)
        pose_col_cost_model = self.graph_builder.opt().pose_col_cost_model
        graph.add(
            gtd.TrapezoidalPoseCollocationFactor(pose_prev_key,
                                                 pose_curr_key,
                                                 twist_prev_key,
                                                 twist_curr_key, dt_key,
                                                 pose_col_cost_model))
        twist_col_cost_model = self.graph_builder.opt(
        ).twist_col_cost_model
        graph.add(
            gtd.TrapezoidalPoseCollocationFactor(
                twist_prev_key, twist_curr_key, twistaccel_prev_key,
                twistaccel_curr_key, dt_key, twist_col_cost_model))
    return graph