What does this second part of the code mean? Python

Change spacing

    logging.info("change spacing")
    start = time.time()
    ijkToRas = vtk.vtkMatrix4x4()
    imagenode.GetIJKToRASMatrix(ijkToRas)
    for i in range(3):
        ijkToRas.SetElement(i, i, spacing[i])
    imagenode.SetIJKToRASMatrix(ijkToRas)
    end = time.time()
    logging.info(f"change spacing in {human_time(end-start)}")
    slicer.app.processEvents()

This part " ijkToRas.SetElement(i, i, spacing[i])"?

IJK to RAS transform is the mapping from voxel coordinate system (IJK) to physical space (RAS). If IJKtoRAS is a diagonal matrix then the first 3 values in the diagonal specifies the image spacing (voxel size).