<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cylinder(radius=1.0, height=1.0, sections=32, segment=None, transform=None, **kwargs):
 """ Create a mesh of a cylinder along Z centered at the origin. Parameters radius : float The radius of the cylinder height : float The height of the cylinder sections : int How many pie wedges should the cylinder have segment : (2, 3) float Endpoints of axis, overrides transform and height transform : (4, 4) float Transform to apply **kwargs: passed to Trimesh to create cylinder Returns cylinder: trimesh.Trimesh Resulting mesh of a cylinder """


    if segment is not None:
        segment = np.asanyarray(segment, dtype=np.float64)
        if segment.shape != (2, 3):
            raise ValueError('segment must be 2 3D points!')
        vector = segment[1] - segment[0]
        # override height with segment length
        height = np.linalg.norm(vector)
        # point in middle of line
        midpoint = segment[0] + (vector * 0.5)
        # align Z with our desired direction
        rotation = align_vectors([0, 0, 1], vector)
        # translate to midpoint of segment
        translation = transformations.translation_matrix(midpoint)
        # compound the rotation and translation
        transform = np.dot(translation, rotation)

    # create a 2D pie out of wedges
    theta = np.linspace(0, np.pi * 2, sections)
    vertices = np.column_stack((np.sin(theta),
                                np.cos(theta))) * radius
    # the single vertex at the center of the circle
    # we're overwriting the duplicated start/end vertex
    vertices[0] = [0, 0]

    # whangle indexes into a triangulation of the pie wedges
    index = np.arange(1, len(vertices) + 1).reshape((-1, 1))
    index[-1] = 1
    faces = np.tile(index, (1, 2)).reshape(-1)[1:-1].reshape((-1, 2))
    faces = np.column_stack((np.zeros(len(faces), dtype=np.int), faces))

    # extrude the 2D triangulation into a Trimesh object
    cylinder = extrude_triangulation(vertices=vertices,
                                     faces=faces,
                                     height=height,
                                     **kwargs)
    # the extrusion was along +Z, so move the cylinder
    # center of mass back to the origin
    cylinder.vertices[:, 2] -= height * .5
    if transform is not None:
        # apply a transform here before any cache stuff is generated
        # and would have to be dumped after the transform is applied
        cylinder.apply_transform(transform)

    return cylinder