Can any one help me to convert this keras code to pytorch code

username: gtfartas
cooked: <pre><code class="lang-auto">############################################################################################
# SFTT Network
############################################################################################

############################################################################################
# ResNet Identity Block
############################################################################################
def residual_block(inputs, filters, block_id):
    
    f1, f2, f3 = filters
    pool = MaxPooling2D(pool_size=(2,2),name='block_' + str(block_id) + '_max_pooling')(inputs)

    x = Conv2D(f1, kernel_size=(3,3), padding='same', use_bias=False, kernel_initializer='he_normal', name='block_' + str(block_id) + '_conv_conv2d_1')(pool)
    x = BatchNormalization(name='block_' + str(block_id) + '_conv_batch_1')(x)
    x = Activation('relu', name='block_' + str(block_id) + '_expand_relu')(x)
    
    
    x = Conv2D(f2, kernel_size=(1,1), padding='same', use_bias=False, kernel_initializer='he_normal', name='block_' + str(block_id) + '_conv_conv2d_2')(x)
    x = BatchNormalization(name='block_' + str(block_id) + '_conv_batch_2')(x)
    x = Activation('relu', name='block_' + str(block_id) + '_depthwise_relu')(x)
    
    
    x = Conv2D(f3, kernel_size=(3,3), padding='same', use_bias=False, kernel_initializer='he_normal', name='block_' + str(block_id) + '_project_conv2d')(x)
    x = BatchNormalization(name='block_' + str(block_id) + '_project_batch')(x)
    

    shortcut = Conv2D(f3, kernel_size=(3,3), padding='same', strides=(1,1), use_bias=False, kernel_initializer='he_normal', name='block_' + str(block_id) + '_shortcut_conv2d')(pool)
    shortcut = BatchNormalization(name='block_' + str(block_id) + '_shortcut_batch')(shortcut)
  


    average = Average(name='block_' + str(block_id) + '_average')([shortcut,x])
  
    output = Activation('relu',name='block_' + str(block_id) + '_average_relu')(average)

    
    return output

def SFTT_model(input_shape):

    bs,map_height, map_width, feature_maps = input_shape.shape

    ######################################################
    # Convolutional
    ######################################################

    Image = Input(shape=(map_height, map_width, feature_maps), name='input')
    
    x = Conv2D(32, kernel_size=(1,1),strides=(1,1), padding='same', kernel_initializer='he_normal', name = 'conv1')(Image)

    x = BatchNormalization(name = 'batch_1')(x)

    x = Activation('relu',name='relu_1')(x)

    
    x = residual_block(x,filters = [32, 32, 128], block_id = 0)


    x = residual_block(x,filters = [64, 64, 256], block_id = 1)

    x = residual_block(x,filters = [128, 128, 512], block_id = 2)


    
    sf_output = MaxPooling2D(pool_size=(2,2),name='final_max_pooling')(x)

    sf_output = Flatten()(sf_output)
    #hadi mazal
    conv_model  = Model(inputs=Image,outputs=sf_output)
    
    
    ######################################################
    # LSTM 
    ######################################################
    input_sequences = Input(shape=(None,map_height,map_width,feature_maps))
    time_distribute = TimeDistributed(Lambda(lambda x: conv_model(x)))(input_sequences)

    lstm = LSTM(512, return_sequences = True)(time_distribute)
    lstm = LSTM(512, return_sequences = True)(lstm)
    fc1 = Dense(map_height*map_width, activation='relu')(lstm)
    final_output = Reshape((map_height, map_width), name='squeeze_output')(fc1)

    
    sftt_model = Model(inputs=[input_sequences], outputs=[final_output])
    
    return sftt_model```</code></pre>