code: def attach(self, media: typing.Union[InputMedia, typing.Dict]):
          
          if isinstance(media, dict):
              if 'type' not in media:
                  raise ValueError(f"Invalid media!")
  
              media_type = media['type']
              if media_type == 'photo':
                  media = InputMediaPhoto(**media)
              elif media_type == 'video':
                  media = InputMediaVideo(**media)
              # elif media_type == 'document':
              #     media = InputMediaDocument(**media)
              # elif media_type == 'audio':
              #     media = InputMediaAudio(**media)
              # elif media_type == 'animation':
              #     media = InputMediaAnimation(**media)
              else:
                  raise TypeError(f"Invalid media type '{media_type}'!")
  
          elif not isinstance(media, InputMedia):
              raise TypeError(f"Media must be an instance of InputMedia or dict, not {type(media).__name__}")
  
          elif media.type in ['document', 'audio', 'animation']:
              raise ValueError(f"This type of media is not supported by media groups!")
  
          self.media.append(media)
docs: Attach media
  
          :param media: