def get_image_to_video_latent(validation_image_start, validation_image_end, num_frames, sample_size):
    """
    Generate latent representations for video from start and end images. Inputs can be PIL.Image, numpy.ndarray, or
    torch.Tensor.
    """
    input_video = None
    input_video_mask = None

    if validation_image_start is not None:
        # Preprocess the starting image(s)
        if isinstance(validation_image_start, list):
            image_start = [preprocess_image(img, sample_size) for img in validation_image_start]
        else:
            image_start = preprocess_image(validation_image_start, sample_size)

        # Create video tensor from the starting image(s)
        if isinstance(image_start, list):
            start_video = torch.cat(
                [img.unsqueeze(1).unsqueeze(0) for img in image_start],
                dim=2,
            )
            input_video = torch.tile(start_video[:, :, :1], [1, 1, num_frames, 1, 1])
            input_video[:, :, : len(image_start)] = start_video
        else:
            input_video = torch.tile(
                image_start.unsqueeze(1).unsqueeze(0),
                [1, 1, num_frames, 1, 1],
            )

        # Normalize input video (already normalized in preprocess_image)

        # Create mask for the input video
        input_video_mask = torch.zeros_like(input_video[:, :1])
        if isinstance(image_start, list):
            input_video_mask[:, :, len(image_start) :] = 255
        else:
            input_video_mask[:, :, 1:] = 255

        # Handle ending image(s) if provided
        if validation_image_end is not None:
            if isinstance(validation_image_end, list):
                image_end = [preprocess_image(img, sample_size) for img in validation_image_end]
                end_video = torch.cat(
                    [img.unsqueeze(1).unsqueeze(0) for img in image_end],
                    dim=2,
                )
                input_video[:, :, -len(end_video) :] = end_video
                input_video_mask[:, :, -len(image_end) :] = 0
            else:
                image_end = preprocess_image(validation_image_end, sample_size)
                input_video[:, :, -1:] = image_end.unsqueeze(1).unsqueeze(0)
                input_video_mask[:, :, -1:] = 0

    elif validation_image_start is None:
        # If no starting image is provided, initialize empty tensors
        input_video = torch.zeros([1, 3, num_frames, sample_size[0], sample_size[1]])
        input_video_mask = torch.ones([1, 1, num_frames, sample_size[0], sample_size[1]]) * 255

    return input_video, input_video_mask

    Generate latent representations for video from start and end images. Inputs can be PIL.Image, numpy.ndarray, or
    torch.Tensor.
    
src/diffusers/pipelines/easyanimate/pipeline_easyanimate_inpaint.py