parameters: (self,
                  army,
                  num_army,
                  enemy,
                  num_enemy,
                  resource,
                  num_resource,
                  money,
                  instruction,
                  *,
                  repeat_for_each_unit=False)
return_statement: return glob
docstring: reduce padded features of different categories and combine them
  
          army/enemy/resource: [batch, padded_num_army, army_out_dim]
          num_army/enemy/resource: [batch]
  
          return glob: [batch, padded_num_army, self.glob_dim]
docstring_summary: reduce padded features of different categories and combine them
docstring_tokens: reduce padded features of different categories and combine them
function: def forward(self,
                  army,
                  num_army,
                  enemy,
                  num_enemy,
                  resource,
                  num_resource,
                  money,
                  instruction,
                  *,
                  repeat_for_each_unit=False):
          """reduce padded features of different categories and combine them
  
          army/enemy/resource: [batch, padded_num_army, army_out_dim]
          num_army/enemy/resource: [batch]
  
          return glob: [batch, padded_num_army, self.glob_dim]
          """
          pnum_army = army.size(1)
          summed_army = self._sum(army, num_army)
          summed_enemy = self._sum(enemy, num_enemy)
          summed_resource = self._sum(resource, num_resource)
          assert instruction.dim() == 2
          # money.zero_()
          # money = money + 1
          # print(money.size())
          if instruction.dim() == 2:
              glob = torch.cat([summed_army, summed_enemy, summed_resource, instruction], 1)
              # glob = torch.cat([money.detach()], 1)
              # glob = torch.cat([instruction], 1)
              # assert not repeat_for_each_unit
              if repeat_for_each_unit:
                  glob = glob.unsqueeze(1).repeat(1, pnum_army, 1)
  
          elif instruction.dim() == 3:
              assert False
  
              glob = torch.cat(
                  [summed_army, summed_enemy, summed_resource, money], 1)
              assert repeat_for_each_unit
              glob = glob.unsqueeze(1).repeat(1, pnum_army, 1)
              glob = torch.cat([glob, instruction], 2)
          else:
              assert False
  
          return glob
function_tokens: def forward ( self , army , num_army , enemy , num_enemy , resource , num_resource , money , instruction , * , repeat_for_each_unit = False ) : pnum_army = army . size ( 1 ) summed_army = self . _sum ( army , num_army ) summed_enemy = self . _sum ( enemy , num_enemy ) summed_resource = self . _sum ( resource , num_resource ) assert instruction . dim ( ) == 2 # money.zero_() # money = money + 1 # print(money.size()) if instruction . dim ( ) == 2 : glob = torch . cat ( [ summed_army , summed_enemy , summed_resource , instruction ] , 1 ) # glob = torch.cat([money.detach()], 1) # glob = torch.cat([instruction], 1) # assert not repeat_for_each_unit if repeat_for_each_unit : glob = glob . unsqueeze ( 1 ) . repeat ( 1 , pnum_army , 1 ) elif instruction . dim ( ) == 3 : assert False glob = torch . cat ( [ summed_army , summed_enemy , summed_resource , money ] , 1 ) assert repeat_for_each_unit glob = glob . unsqueeze ( 1 ) . repeat ( 1 , pnum_army , 1 ) glob = torch . cat ( [ glob , instruction ] , 2 ) else : assert False return glob