A year later, I've found a new solution if anyone needs it. In Godot 4.1.1 in GDScript (I could investigate in C#, C++ if anyone needs it):
# Get the SpriteFrames component of your AnimatedSprite2D node:
var sprite_frames = $AnimatedSprite2D.sprite_frames
# Get the first texture of the wanted animation (in this case, walk, you can also get the size
# in differents cases)
# If your animation frames has different sizes, use $AnimatedSprite2D.frame instead of 0
var texture = sprite_frames.get_frame_texture("walk", 0)
# Get frame size:
var texture_size = texture.get_size()
# This is not the end, you will get the texture size, not the node real size, then you need to
# multiply the texture size with the node scale
var as2d_size = texture_size * $AnimatedSprite2D.get_scale()