import torch.nn as nn


# Template design pattern
class Switchboard(nn.Module):

    def __init__(self):
        super(Switchboard, self).__init__()
        self.switchboard_modules = []
        self.post_init()

    @property
    def probas(self):
        raise NotImplementedError()

    @property
    def inputs(self):
        raise NotImplementedError()

    @property
    def outputs(self):
        raise NotImplementedError()

    def post_init(self):
        """Collects all Switchboards that are part of this switchboard"""
        self.switchboard_modules = [
            module for module in self.children()
            if isinstance(module, Switchboard)
        ]

    def flip(self, reward, batch_y=None):
        if not self.switchboard_modules:
            raise AttributeError("No submodules (did you call post_init)?")
        for module in self.switchboard_modules:
            module.flip(reward, batch_y=batch_y)

    def post_ep_hook(self):
        [module.post_ep_hook() for module in self.switchboard_modules]

6863911601b71ef1d13aa91bb4c0485b045d08ed
<mask token>


class Switchboard(nn.Module):

    def __init__(self):
        super(Switchboard, self).__init__()
        self.switchboard_modules = []
        self.post_init()

    @property
    def probas(self):
        raise NotImplementedError()
    <mask token>
    <mask token>
    <mask token>

    def flip(self, reward, batch_y=None):
        if not self.switchboard_modules:
            raise AttributeError('No submodules (did you call post_init)?')
        for module in self.switchboard_modules:
            module.flip(reward, batch_y=batch_y)
    <mask token>

<mask token>


class Switchboard(nn.Module):

    def __init__(self):
        super(Switchboard, self).__init__()
        self.switchboard_modules = []
        self.post_init()

    @property
    def probas(self):
        raise NotImplementedError()
    <mask token>
    <mask token>

    def post_init(self):
        """Collects all Switchboards that are part of this switchboard"""
        self.switchboard_modules = [module for module in self.children() if
            isinstance(module, Switchboard)]

    def flip(self, reward, batch_y=None):
        if not self.switchboard_modules:
            raise AttributeError('No submodules (did you call post_init)?')
        for module in self.switchboard_modules:
            module.flip(reward, batch_y=batch_y)
    <mask token>

<mask token>


class Switchboard(nn.Module):

    def __init__(self):
        super(Switchboard, self).__init__()
        self.switchboard_modules = []
        self.post_init()

    @property
    def probas(self):
        raise NotImplementedError()

    @property
    def inputs(self):
        raise NotImplementedError()
    <mask token>

    def post_init(self):
        """Collects all Switchboards that are part of this switchboard"""
        self.switchboard_modules = [module for module in self.children() if
            isinstance(module, Switchboard)]

    def flip(self, reward, batch_y=None):
        if not self.switchboard_modules:
            raise AttributeError('No submodules (did you call post_init)?')
        for module in self.switchboard_modules:
            module.flip(reward, batch_y=batch_y)

    def post_ep_hook(self):
        [module.post_ep_hook() for module in self.switchboard_modules]

<mask token>


class Switchboard(nn.Module):

    def __init__(self):
        super(Switchboard, self).__init__()
        self.switchboard_modules = []
        self.post_init()

    @property
    def probas(self):
        raise NotImplementedError()

    @property
    def inputs(self):
        raise NotImplementedError()

    @property
    def outputs(self):
        raise NotImplementedError()

    def post_init(self):
        """Collects all Switchboards that are part of this switchboard"""
        self.switchboard_modules = [module for module in self.children() if
            isinstance(module, Switchboard)]

    def flip(self, reward, batch_y=None):
        if not self.switchboard_modules:
            raise AttributeError('No submodules (did you call post_init)?')
        for module in self.switchboard_modules:
            module.flip(reward, batch_y=batch_y)

    def post_ep_hook(self):
        [module.post_ep_hook() for module in self.switchboard_modules]

import torch.nn as nn


# Template design pattern
class Switchboard(nn.Module):

    def __init__(self):
        super(Switchboard, self).__init__()
        self.switchboard_modules = []
        self.post_init()

    @property
    def probas(self):
        raise NotImplementedError()

    @property
    def inputs(self):
        raise NotImplementedError()

    @property
    def outputs(self):
        raise NotImplementedError()

    def post_init(self):
        """Collects all Switchboards that are part of this switchboard"""
        self.switchboard_modules = [
            module for module in self.children()
            if isinstance(module, Switchboard)
        ]

    def flip(self, reward, batch_y=None):
        if not self.switchboard_modules:
            raise AttributeError("No submodules (did you call post_init)?")
        for module in self.switchboard_modules:
            module.flip(reward, batch_y=batch_y)

    def post_ep_hook(self):
        [module.post_ep_hook() for module in self.switchboard_modules]
