### Godot version

4.01

### System information

Windows 10

### Issue description

It seems a tiles Custom Data is cleared/not set when "Local to Scene" is enabled for the TileMap in the Resource section. At least the custom data isn't set by the time of the _ready function in the script attached to the TileMap.

### Steps to reproduce

create TileMap and tileset with custom data and attached script. in _ready method attempt to read custom data from a used cell. 

In Attached project run it. It will print_debug if it found custom data or not. "Local to Scene" is enabled so it will not find the custom data.

### Minimal reproduction project

[TileMapCustomDataLocalBugReproduce.zip](https://github.com/godotengine/godot/files/11470771/TileMapCustomDataLocalBugReproduce.zip)

}
					}
				}
			}
		}
	}
	
	for (int terrain_set = 0; terrain_set < get_terrain_sets_count(); terrain_set++) {
		for (int terrain = 0; terrain < get_terrains_count(terrain_set); terrain++) {
			Ref<Image> image;
			image.instantiate();
			if (counts[terrain_set][terrain].count > 0) {
				
				Ref<Texture2D> texture = counts[terrain_set][terrain].texture;
				Rect2i region = counts[terrain_set][terrain].region;
				image->initialize_data(region.size.x, region.size.y, false, Image::FORMAT_RGBA8);
				image->blit_rect(texture->get_image(), region, Point2i());
				image->resize(p_size.x, p_size.y, Image::INTERPOLATE_NEAREST);
			} else {
				image->initialize_data(1, 1, false, Image::FORMAT_RGBA8);
				image->set_pixel(0, 0, get_terrain_color(terrain_set, terrain));
			}
			Ref<ImageTexture> icon = ImageTexture::create_from_image(image);
			icon->set_size_override(p_size);
			output.write[terrain_set].write[terrain] = icon;
		}
	}
	return output;
}
void TileSet::_source_changed() {