class_docstr: TCTS Model
  
  Parameters
  ----------
  d_feat : int
      input dimension for each time step
  metric: str
      the evaluation metric used in early stop
  optimizer : str
      optimizer name
  GPU : str
      the GPU ID(s) used for training
class_docstr_tok: ["TCTS","Model","Parameters","--","--","--","--","--","d_feat",":","int","input","dimension","for","each","time","step","metric",":","str","the","evaluation","metric","used","in","early","stop","optimizer",":","str","optimizer","name","GPU",":","str","the","GPU","ID","(","s",")","used","for","training"]
code: def loss_fn(self, pred, label, weight):
      if self.mode == "hard":
          loc = torch.argmax(weight, 1)
          loss = (pred - label[np.arange(weight.shape[0]), loc]) ** 2
          return torch.mean(loss)
  
      elif self.mode == "soft":
          loss = (pred - label.transpose(0, 1)) ** 2
          return torch.mean(loss * weight.transpose(0, 1))
  
      else:
          raise NotImplementedError(
              "mode {} is not supported!".format(self.mode)
          )
  
imports: from __future__ import division
  from __future__ import print_function
  import numpy
  import pandas
  import copy
  import random
  from ...utils import get_or_create_path
  from ...log import get_module_logger
  import torch
  import torch.nn
  import torch.optim
  from ...model.base import Model
  from ...data.dataset import DatasetH
  from ...data.dataset.handler import DataHandlerLP
label_desc: Use image node_id 2 for calling the TCTS obj's underlying member method code with example usage: obj.loss_fn(pred, label, weight) and returns: torch, torch