code: def margin_loss(self, input, target):
      batch_s = target.size(0)
      one_hot_vec = torch.zeros(batch_s, 10).to(self.device)
      for i in range(batch_s):
          one_hot_vec[i, target[i]] = 1.0
      batch_size = input.size(0)
      v_c = torch.sqrt((input**2).sum(dim=2, keepdim=True))
      zero = torch.zeros(1).to(self.device)
      m_plus = 0.9
      m_minus = 0.1
      loss_lambda = 0.5
      max_left = torch.max(m_plus - v_c, zero).view(batch_size, -1) ** 2
      max_right = (
          torch.max(v_c - m_minus, zero).view(batch_size, -1) ** 2
      )
      t_c = one_hot_vec
      l_c = t_c * max_left + loss_lambda * (1.0 - t_c) * max_right
      l_c = l_c.sum(dim=1)
      return l_c.mean()
  
file_path: dgl/examples/pytorch/capsule/model.py
imports: import torch
  from DGLDigitCapsule import DGLDigitCapsuleLayer
  from DGLRoutingLayer import squash
  from torch import nn
label_desc: Use image node_id 3 for calling the Net obj's underlying member method code with example usage: obj.margin_loss(input, target) and returns: l_c