code: def forward(self, input, inst):
      outputs = self.model(input)
  
      # instance-wise average pooling
      outputs_mean = outputs.clone()
      inst_list = np.unique(inst.cpu().numpy().astype(int))
      for i in inst_list:
          for b in range(input.size()[0]):
              indices = (inst[b : b + 1] == int(i)).nonzero()  # n x 4
              for j in range(self.output_nc):
                  output_ins = outputs[
                      indices[:, 0] + b,
                      indices[:, 1] + j,
                      indices[:, 2],
                      indices[:, 3],
                  ]
                  mean_feat = torch.mean(output_ins).expand_as(
                      output_ins
                  )
                  outputs_mean[
                      indices[:, 0] + b,
                      indices[:, 1] + j,
                      indices[:, 2],
                      indices[:, 3],
                  ] = mean_feat
      return outputs_mean
  
imports: import torch
  import torch.nn
  import functools
  from torch.autograd import Variable
  import numpy
label_desc: Use image node_id 2 for calling the Encoder obj's underlying member method code with example usage: obj.forward(input, inst) and returns: outputs_mean