tyxe/util.py
def to_pyro_module_(m, name="", recurse=True):
    """
    Same as `pyro.nn.modules.to_pyro_module_` except that it also accepts a name argument and returns the modified
    module following the convention in pytorch for inplace functions.
    """
    if not isinstance(m, torch.nn.Module):
        raise TypeError("Expected an nn.Module instance but got a {}".format(type(m)))

    if isinstance(m, pyromodule.PyroModule):
        if recurse:
            for name, value in list(m._modules.items()):
                to_pyro_module_(value)
                setattr(m, name, value)
        return

    # Change m's type in-place.
    m.__class__ = pyromodule.PyroModule[m.__class__]
    m._pyro_name = name
    m._pyro_context = pyromodule._Context()
    m._pyro_params = OrderedDict()
    m._pyro_samples = OrderedDict()

    # Reregister parameters and submodules.
    for name, value in list(m._parameters.items()):
        setattr(m, name, value)
    for name, value in list(m._modules.items()):
        if recurse:
            to_pyro_module_(value)
        setattr(m, name, value)

    return m

    Same as `pyro.nn.modules.to_pyro_module_` except that it also accepts a name argument and returns the modified
    module following the convention in pytorch for inplace functions.
    
Same as `pyro.nn.modules.to_pyro_module_` except that it also accepts a name argument and returns the modified
module following the convention in pytorch for inplace functions.
Same as ` pyro . nn . modules . to_pyro_module_ ` except that it also accepts a name argument and returns the modified module following the convention in pytorch for inplace functions .
def to_pyro_module_(m, name="", recurse=True):
    if not isinstance(m, torch.nn.Module):
        raise TypeError("Expected an nn.Module instance but got a {}".format(type(m)))
    if isinstance(m, pyromodule.PyroModule):
        if recurse:
            for name, value in list(m._modules.items()):
                to_pyro_module_(value)
                setattr(m, name, value)
        return
    m.__class__ = pyromodule.PyroModule[m.__class__]
    m._pyro_name = name
    m._pyro_context = pyromodule._Context()
    m._pyro_params = OrderedDict()
    m._pyro_samples = OrderedDict()
    for name, value in list(m._parameters.items()):
        setattr(m, name, value)
    for name, value in list(m._modules.items()):
        if recurse:
            to_pyro_module_(value)
        setattr(m, name, value)
    return m
def to_pyro_module_ ( m , name = "" , recurse = True ) : if not isinstance ( m , torch . nn . Module ) : raise TypeError ( "Expected an nn.Module instance but got a {}" . format ( type ( m ) ) ) if isinstance ( m , pyromodule . PyroModule ) : if recurse : for name , value in list ( m . _modules . items ( ) ) : to_pyro_module_ ( value ) setattr ( m , name , value ) return m . __class__ = pyromodule . PyroModule [ m . __class__ ] m . _pyro_name = name m . _pyro_context = pyromodule . _Context ( ) m . _pyro_params = OrderedDict ( ) m . _pyro_samples = OrderedDict ( ) for name , value in list ( m . _parameters . items ( ) ) : setattr ( m , name , value ) for name , value in list ( m . _modules . items ( ) ) : if recurse : to_pyro_module_ ( value ) setattr ( m , name , value ) return m
Same as `pyro.nn.modules.to_pyro_module_` except that it also accepts a name argument and returns the modified
module following the convention in pytorch for inplace functions.
Same as ` pyro . nn . modules . to_pyro_module_ ` except that it also accepts a name argument and returns the modified module following the convention in pytorch for inplace functions .
"""
    Same as `pyro.nn.modules.to_pyro_module_` except that it also accepts a name argument and returns the modified
    module following the convention in pytorch for inplace functions.
    """ # Change m's type in-place. # Reregister parameters and submodules.
m
name
recurse