def create_perturbable_texels(texels_map, mask_map, initial_value=0., sign_grad=True):
    """
        Creates perturbable texels using mask to define perturbable area. Will also initialize
        perturbable area to some value. If no mask is specified for texel, we treat the entire
        texel as not perturbable. Gradients of these perturbable texels will be masked and
        magnitudeless, if sign_grad=True.

        Parameters:
            texels_map (dict[str -> torch.Tensor[N, C, H, W]]): Dictionaries of texels.
            mask_map (dict[str -> torch.Tensor[M, 1, H, W]]): Dictionary of masks.
            initial_value (float or torch.Tensor): Initial value to set perturbable area, must be broadcastable to mask.
            sign_grad (bool): Whether to remove gradient magnitude for the gradient of perturable texel.

        Returns:
            dict(str -> torch.Tensor[N, C, H, W]): List of perturbable texels that require gradients.
    """
    perturbed_texels_map = {}

    for name, texels in texels_map.items():
        if name in mask_map:
            texels_rgb = texels[:3, :, :]
            mask = mask_map[name]

            perturbed_texels = texels_rgb*(1 - mask) + initial_value*mask
            perturbed_texels.requires_grad_(True)
            perturbed_texels.register_hook(lambda grad: grad*mask)
            if sign_grad:
                perturbed_texels.register_hook(lambda grad: grad.sign())
        else:
            perturbed_texels = texels

        perturbed_texels_map[name] = perturbed_texels

    return perturbed_texels_map