def get_teacher_predictions(
    model_path: str,
    examples: List[str],
    class_names: List[str],
    hypothesis_template: str,
    batch_size: int,
    temperature: float,
    multi_label: bool,
    use_fast_tokenizer: bool,
    no_cuda: bool,
    fp16: bool,
):
    """
    Gets predictions by the same method as the zero-shot pipeline but with DataParallel & more efficient batching
    """
    model = AutoModelForSequenceClassification.from_pretrained(model_path)
    model_config = model.config
    if not no_cuda and torch.cuda.is_available():
        model = nn.DataParallel(model.cuda())
        batch_size *= len(model.device_ids)
    tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=use_fast_tokenizer)

    premises, hypotheses = get_premise_hypothesis_pairs(examples, class_names, hypothesis_template)
    logits = []

    for i in tqdm(range(0, len(premises), batch_size)):
        batch_premises = premises[i : i + batch_size]
        batch_hypotheses = hypotheses[i : i + batch_size]

        encodings = tokenizer(
            batch_premises,
            batch_hypotheses,
            padding=True,
            truncation="only_first",
            return_tensors="pt",
        )

        with torch.cuda.amp.autocast(enabled=fp16):
            with torch.no_grad():
                outputs = model(**encodings)
        logits.append(outputs.logits.detach().cpu().float())

    entail_id = get_entailment_id(model_config)
    contr_id = -1 if entail_id == 0 else 0
    logits = torch.cat(logits, dim=0)  # N*K x 3
    nli_logits = logits.reshape(len(examples), len(class_names), -1)[..., [contr_id, entail_id]]  # N x K x 2

    if multi_label:
        # softmax over (contr, entail) logits for each class independently
        nli_prob = (nli_logits / temperature).softmax(-1)
    else:
        # softmax over entail logits across classes s.t. class probabilities sum to 1.
        nli_prob = (nli_logits / temperature).softmax(1)

    return nli_prob[..., 1]  # N x K

    Gets predictions by the same method as the zero-shot pipeline but with DataParallel & more efficient batching
    
dpkd/transformers/examples/research_projects/zero-shot-distillation/distill_classifier.py