def get_serializer(self, *args, **kwargs):
        serializer_class = self.get_serializer_class()
        kwargs['context'] = self.get_serializer_context()
        # for single object use dedicated serializer directly
        # for many objects, `PolymorphicListSerializer` is used underneath
        if not kwargs.get('many'):
            try:
                serializer_class = serializer_class._serializers_registry[
                    args[0].__class__
                ]
            except __HOLE__:
                logger.warning('Dedicated serializer not found for {}'.format(
                    args[0].__class__
                ))
        return serializer_class(*args, **kwargs)
dataset/ETHPy150Open allegro/ralph/src/ralph/api/utils.py/PolymorphicViewSetMixin.get_serializer