text: #!/usr/bin/env python
  # coding: utf-8
  import torch
  import torch.nn as nn
  import torch.nn.functional as F
  
  class MSC(nn.Module):
      """
      Multi-scale inputs
      """
  
      def __init__(self, base, scales=None):
          super(MSC, self).__init__()
          self.base = base
          if scales:
              self.scales = scales
          else:
              self.scales = [0.5, 0.75]
  
      def forward(self, x):
          # Original
          logits = self.base(x)
          _, _, H, W = logits.shape
          interp = lambda l: F.interpolate(
              l, size=(H, W), mode="bilinear", align_corners=False
          )
  
          # Scaled
          logits_pyramid = []
          for p in self.scales:
              h = F.interpolate(x, scale_factor=p, mode="bilinear", align_corners=False)
              logits_pyramid.append(self.base(h))
  
          # Pixel-wise max
          logits_all = [logits] + [interp(l) for l in logits_pyramid]
          logits_max = torch.max(torch.stack(logits_all), dim=0)[0]
  
          if self.training:
              return [logits] + logits_pyramid + [logits_max]
          else:
              return logits_max