from torch import nn
from src.retrieval_core.models.pooling.GeM import GeM


class PoolFactory(nn.Module):

    def __init__(self, pool='max'):
        super(PoolFactory, self).__init__()
        pool_type = {'avg': nn.AdaptiveAvgPool2d(1), 'max': nn.
            AdaptiveMaxPool2d(1), 'gem': GeM()}
        if pool not in pool_type.keys():
            raise ValueError('Unknown pooling methods for {}'.format(pool))
        else:
            self.pool = pool_type[pool]

    def forward(self, x):
        return self.pool(x)

7782e2d207fff835f259ca5b3306ce3962aa24ad
<mask token>


class PoolFactory(nn.Module):
    <mask token>
    <mask token>

<mask token>


class PoolFactory(nn.Module):
    <mask token>

    def forward(self, x):
        return self.pool(x)

<mask token>


class PoolFactory(nn.Module):

    def __init__(self, pool='max'):
        super(PoolFactory, self).__init__()
        pool_type = {'avg': nn.AdaptiveAvgPool2d(1), 'max': nn.
            AdaptiveMaxPool2d(1), 'gem': GeM()}
        if pool not in pool_type.keys():
            raise ValueError('Unknown pooling methods for {}'.format(pool))
        else:
            self.pool = pool_type[pool]

    def forward(self, x):
        return self.pool(x)

from torch import nn
from src.retrieval_core.models.pooling.GeM import GeM


class PoolFactory(nn.Module):

    def __init__(self, pool='max'):
        super(PoolFactory, self).__init__()
        pool_type = {'avg': nn.AdaptiveAvgPool2d(1), 'max': nn.
            AdaptiveMaxPool2d(1), 'gem': GeM()}
        if pool not in pool_type.keys():
            raise ValueError('Unknown pooling methods for {}'.format(pool))
        else:
            self.pool = pool_type[pool]

    def forward(self, x):
        return self.pool(x)
