(enc, gen, layername)
return prev_layers, layers, next_layers
Given an inverter layername, splits the generator sequence into three:
    (1) generator sequence before the layers to be inverted
    (2) sequence of generator layers to be inverted by enc[layername]
    (3) generator sequence after the layers to be inverted
Given an inverter layername, splits the generator sequence into three:
    (1) generator sequence before the layers to be inverted
    (2) sequence of generator layers to be inverted by enc[layername]
    (3) generator sequence after the layers to be inverted
Given an inverter layername splits the generator sequence into three : ( 1 ) generator sequence before the layers to be inverted ( 2 ) sequence of generator layers to be inverted by enc [ layername ] ( 3 ) generator sequence after the layers to be inverted
def split_gen_layers(enc, gen, layername):
    '''
    Given an inverter layername, splits the generator sequence into three:
    (1) generator sequence before the layers to be inverted
    (2) sequence of generator layers to be inverted by enc[layername]
    (3) generator sequence after the layers to be inverted
    '''
    info = list(enc.inverse_info().items())
    index = [i for i, (n, v) in enumerate(info) if n == layername][0]
    upto_layer = info[index - 1][1]['first_layer'] if index > 0 else None
    args = info[index][1]
    first_layer = args['first_layer']
    layers = nethook.subsequence(gen,
         first_layer=first_layer, upto_layer=upto_layer)
    prev_layers = nethook.subsequence(gen, upto_layer=first_layer)
    next_layers = (nethook.subsequence(gen, first_layer=upto_layer) if
            upto_layer else torch.nn.Sequential())
    return prev_layers, layers, next_layers
def split_gen_layers ( enc , gen , layername ) : info = list ( enc . inverse_info ( ) . items ( ) ) index = [ i for i , ( n , v ) in enumerate ( info ) if n == layername ] [ 0 ] upto_layer = info [ index - 1 ] [ 1 ] [ 'first_layer' ] if index > 0 else None args = info [ index ] [ 1 ] first_layer = args [ 'first_layer' ] layers = nethook . subsequence ( gen , first_layer = first_layer , upto_layer = upto_layer ) prev_layers = nethook . subsequence ( gen , upto_layer = first_layer ) next_layers = ( nethook . subsequence ( gen , first_layer = upto_layer ) if upto_layer else torch . nn . Sequential ( ) ) return prev_layers , layers , next_layers