import torch


def generate_intrinsic_mat(fx: torch.Tensor,
                           fy: torch.Tensor,
                           skew: torch.Tensor,
                           x0: torch.Tensor,
                           y0: torch.Tensor):
    """
        | Generate the following 3x3 intrinsic matrix given the parameters.
        | fx, skew, x0
        |  0,   fy, y0
        |  0,    0,  1

        Parameters
        ==========
        fx: torch.Tensor
            Focal length at x dimension. 1D tensor with size 1.
        fy: torch.Tensor
            Focal length at y dimension. 1D tensor with size 1.
        skew: torch.Tensor
            Axis skew parameter describing shearing transform. 1D tensor with size 1.
        x0: torch.Tensor
            Principle point offset at x dimension. 1D tensor with size 1.
        y0: torch.Tensor
            Principle point offset at y dimension. 1D tensor with size 1.

        Returns
        =======
        torch.Tensor
            3x3 intrinsic matrix
    """
    z = torch.zeros_like(fx)
    o = torch.ones_like(fx)
    row0 = torch.cat([fx, skew, x0])
    row1 = torch.cat([ z,   fy, y0])
    row2 = torch.cat([ z,    z,  o])
    return torch.stack([row0, row1, row2]).contiguous()