def scale_pinhole(pinholes, scale):
    """
        Scales the pinhole matrix for each pinhole model.
    """

    assert len(pinholes.shape) == 2 and pinholes.shape[1] == 12, pinholes.shape
    assert len(scale.shape) == 1, scale.shape

    pinholes_scaled = pinholes.clone()
    pinholes_scaled[..., :6] = pinholes[..., :6] * scale.unsqueeze(-1)

    return pinholes_scaled