code: def forward(
      self, x: torch.Tensor
  ) -> Union[torch.Tensor, List[torch.Tensor]]:
      _, _, h, w = x.shape
  
      # collect encode outputs
      encode_outputs = []
      for i, m in enumerate(self.encode_modules):
          x = m(x)
          encode_outputs.append(x)
          if i != self.encode_num - 1:
              x = F.max_pool2d(
                  x, kernel_size=2, stride=2, ceil_mode=True
              )
  
      # collect decode outputs
      x = encode_outputs.pop()
      decode_outputs = [x]
      for m in self.decode_modules:
          x2 = encode_outputs.pop()
          x = F.interpolate(
              x, size=x2.shape[2:], mode="bilinear", align_corners=False
          )
          x = m(torch.concat([x, x2], dim=1))
          decode_outputs.insert(0, x)
  
      # collect side outputs
      side_outputs = []
      for m in self.side_modules:
          x = decode_outputs.pop()
          x = F.interpolate(
              m(x), size=[h, w], mode="bilinear", align_corners=False
          )
          side_outputs.insert(0, x)
  
      x = self.out_conv(torch.concat(side_outputs, dim=1))
  
      if self.training:
          # do not use torch.sigmoid for amp safe
          return [x] + side_outputs
      else:
          return torch.sigmoid(x)
  
imports: from typing import Union, List
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the U2Net obj's underlying member method code with example usage: obj.forward(x) and returns: unknown, torch