Forwards the given message(s) to the specified entity.

        Args:
            entity (`entity`):
                To which entity the message(s) will be forwarded.

            messages (`list` | `int` | `Message <telethon.tl.custom.message.Message>`):
                The message(s) to forward, or their integer IDs.

            from_peer (`entity`):
                If the given messages are integer IDs and not instances
                of the ``Message`` class, this *must* be specified in
                order for the forward to work. This parameter indicates
                the entity from which the messages should be forwarded.

            silent (`bool`, optional):
                Whether the message should notify people in a broadcast
                channel or not. Defaults to ``False``, which means it will
                notify them. Set it to ``True`` to alter this behaviour.

            as_album (`bool`, optional):
                Whether several image messages should be forwarded as an
                album (grouped) or not. The default behaviour is to treat
                albums specially and send outgoing requests with
                ``as_album=True`` only for the albums if message objects
                are used. If IDs are used it will group by default.

                In short, the default should do what you expect,
                ``True`` will group always (even converting separate
                images into albums), and ``False`` will never group.

        Returns:
            The list of forwarded `telethon.tl.custom.message.Message`,
            or a single one if a list wasn't provided as input.

            Note that if all messages are invalid (i.e. deleted) the call
            will fail with ``MessageIdInvalidError``. If only some are
            invalid, the list will have ``None`` instead of those messages.

async def forward_messages(self, entity, messages, from_peer=None,
                               *, silent=None, as_album=None):
        """
        Forwards the given message(s) to the specified entity.

        Args:
            entity (`entity`):
                To which entity the message(s) will be forwarded.

            messages (`list` | `int` | `Message <telethon.tl.custom.message.Message>`):
                The message(s) to forward, or their integer IDs.

            from_peer (`entity`):
                If the given messages are integer IDs and not instances
                of the ``Message`` class, this *must* be specified in
                order for the forward to work. This parameter indicates
                the entity from which the messages should be forwarded.

            silent (`bool`, optional):
                Whether the message should notify people in a broadcast
                channel or not. Defaults to ``False``, which means it will
                notify them. Set it to ``True`` to alter this behaviour.

            as_album (`bool`, optional):
                Whether several image messages should be forwarded as an
                album (grouped) or not. The default behaviour is to treat
                albums specially and send outgoing requests with
                ``as_album=True`` only for the albums if message objects
                are used. If IDs are used it will group by default.

                In short, the default should do what you expect,
                ``True`` will group always (even converting separate
                images into albums), and ``False`` will never group.

        Returns:
            The list of forwarded `telethon.tl.custom.message.Message`,
            or a single one if a list wasn't provided as input.

            Note that if all messages are invalid (i.e. deleted) the call
            will fail with ``MessageIdInvalidError``. If only some are
            invalid, the list will have ``None`` instead of those messages.
        """
        single = not utils.is_list_like(messages)
        if single:
            messages = (messages,)

        entity = await self.get_input_entity(entity)

        if from_peer:
            from_peer = await self.get_input_entity(from_peer)
            from_peer_id = await self.get_peer_id(from_peer)
        else:
            from_peer_id = None

        def _get_key(m):
            if isinstance(m, int):
                if from_peer_id is not None:
                    return from_peer_id, None

                raise ValueError('from_peer must be given if integer IDs are used')
            elif isinstance(m, types.Message):
                return m.chat_id, m.grouped_id
            else:
                raise TypeError('Cannot forward messages of type {}'.format(type(m)))

        # We want to group outgoing chunks differently if we are "smart"
        # about sending as album.
        #
        # Why? We need separate requests for ``as_album=True/False``, so
        # if we want that behaviour, when we group messages to create the
        # chunks, we need to consider the grouped ID too. But if we don't
        # care about that, we don't need to consider it for creating the
        # chunks, so we can make less requests.
        if as_album is None:
            get_key = _get_key
        else:
            def get_key(m):
                return _get_key(m)[0]  # Ignore grouped_id

        sent = []
        for chat_id, chunk in itertools.groupby(messages, key=get_key):
            chunk = list(chunk)
            if isinstance(chunk[0], int):
                chat = from_peer
                grouped = True if as_album is None else as_album
            else:
                chat = await chunk[0].get_input_chat()
                if as_album is None:
                    grouped = any(m.grouped_id is not None for m in chunk)
                else:
                    grouped = as_album

                chunk = [m.id for m in chunk]

            req = functions.messages.ForwardMessagesRequest(
                from_peer=chat,
                id=chunk,
                to_peer=entity,
                silent=silent,
                # Trying to send a single message as grouped will cause
                # GROUPED_MEDIA_INVALID. If more than one message is forwarded
                # (even without media...), this error goes away.
                grouped=len(chunk) > 1 and grouped
            )
            result = await self(req)
            sent.extend(self._get_response_message(req, result, entity))

        return sent[0] if single else sent