def prepare(samples_list, given_target=None, detach=True, gpu=False):
        """
        Build inp and target
        :param samples_list: list of tensors, [label_0, label_1, ..., label_k]
        :param given_target: given a target, len(samples_list) = 1
        :param detach: if detach input
        :param gpu: if use cuda
        :returns inp, target:
            - inp: sentences
            - target: label index, 0-label_0, 1-label_1, ..., k-label_k
        """
        if len(samples_list) == 1 and given_target is not None:
            inp = samples_list[0]
            if detach:
                inp = inp.detach()
            target = torch.LongTensor([given_target] * inp.size(0))
            if len(inp.size()) == 2:  # samples token, else samples onehot
                inp = inp.long()
        else:
            inp = torch.cat(samples_list, dim=0)  # !!!need .detach()
            if detach:
                inp = inp.detach()
            target = torch.zeros(inp.size(0)).long()
            if len(inp.size()) == 2:  # samples token, else samples onehot
                inp = inp.long()
            for idx in range(1, len(samples_list)):
                start = sum([samples_list[i].size(0) for i in range(idx)])
                target[start: start + samples_list[idx].size(0)] = idx

        # shuffle
        perm = torch.randperm(inp.size(0))
        inp = inp[perm]
        target = target[perm]

        if gpu:
            return inp.cuda(), target.cuda()
        return inp, target

        Build inp and target
        :param samples_list: list of tensors, [label_0, label_1, ..., label_k]
        :param given_target: given a target, len(samples_list) = 1
        :param detach: if detach input
        :param gpu: if use cuda
        :returns inp, target:
            - inp: sentences
            - target: label index, 0-label_0, 1-label_1, ..., k-label_k
        
utils/cat_data_loader.py