class_docstr: Model wrapper around HuggingFace AutoModel models.
  
  Args:
      path: The path to a HuggingFace model.
      model_max_length: The maximum sequence length of the model.
      tokenizer_path: The path to the tokenizer.
      tokenizer_kwargs: Keyword arguments for the tokenizer.
      peft_path: The name or path to the HuggingFace's PEFT model.
      model_kwargs: Keyword arguments for the model.
      prompt_template: The model's prompt template.
      batch_size: Batch size for inference.
      logger: Logger for the model.
      shard_config: Shard config for tensor parallel.
class_docstr_tok: ["Model","wrapper","around","HuggingFace","AutoModel","models",".","Args",":","path",":","The","path","to","a","HuggingFace","model",".","model_max_length",":","The","maximum","sequence","length","of","the","model",".","tokenizer_path",":","The","path","to","the","tokenizer",".","tokenizer_kwargs",":","Keyword","arguments","for","the","tokenizer",".","peft_path",":","The","name","or","path","to","the","HuggingFace","'s","PEFT","model",".","model_kwargs",":","Keyword","arguments","for","the","model",".","prompt_template",":","The","model","'s","prompt","template",".","batch_size",":","Batch","size","for","inference",".","logger",":","Logger","for","the","model",".","shard_config",":","Shard","config","for","tensor","parallel","."]
docstr: Get indices for each choice
  
  Some tokenizer will insert BOS if you don't specify add_special_tokens=False such as Llama-2.
  The indices for choices may be different given the context. For example, for Llama-2 tokenizer, for Chinese context like "答案：{choice}", indices for choices A, B, C and D are 29909, 29933, 29907 and 29928, for English context like "Answer: {choice}", indices for choices A, B, C and D are 319, 350, 315 and 360.
  print(self.tokenizer("答案：A")) to see
  print(self.tokenizer("Answer: A")) to see
docstr_tok: ["Get","indices","for","each","choice","Some","tokenizer","will","insert","BOS","if","you","do","n't","specify","add_special_tokens=False","such","as","Llama-2",".","The","indices","for","choices","may","be","different","given","the","context",".","For","example",",","for","Llama-2","tokenizer",",","for","Chinese","context","like","``","\u7b54\u6848\uff1a","{","choice","}","''",",","indices","for","choices","A",",","B",",","C","and","D","are","29909",",","29933",",","29907","and","29928",",","for","English","context","like","``","Answer",":","{","choice","}","''",",","indices","for","choices","A",",","B",",","C","and","D","are","319",",","350",",","315","and","360.","print","(","self.tokenizer","(","``","\u7b54\u6848\uff1aA","''",")",")","to","see","print","(","self.tokenizer","(","``","Answer",":","A","''",")",")","to","see"]
code: def _get_choices_indices(self, language: str):
      """
      Get indices for each choice
  
      Some tokenizer will insert BOS if you don't specify add_special_tokens=False such as Llama-2.
      The indices for choices may be different given the context. For example, for Llama-2 tokenizer, for Chinese context like "答案：{choice}", indices for choices A, B, C and D are 29909, 29933, 29907 and 29928, for English context like "Answer: {choice}", indices for choices A, B, C and D are 319, 350, 315 and 360.
      print(self.tokenizer("答案：A")) to see
      print(self.tokenizer("Answer: A")) to see
  
      """
  
      # A trick for get "all" tokens ids related to given choices.
      self.indices_for_choices = [[] for _ in range(2)]
      for choice in self.choices:
          self.indices_for_choices[0].append(
              self.tokenizer(
                  f"Answer: {choice}", add_special_tokens=False
              ).input_ids[-1]
          )
          self.indices_for_choices[1].append(
              self.tokenizer(
                  f"答案：{choice}", add_special_tokens=False
              ).input_ids[-1]
          )
  
imports: import copy
  import math
  from typing import Any, Dict, List, Optional, Tuple
  import numpy
  import torch
  from colossal_eval.utils import Conversation, get_batch_prompt, is_rank_0
  from peft import PeftModel
  from tqdm import tqdm
  from transformers import AutoConfig, AutoModel, AutoModelForCausalLM, AutoTokenizer
  from colossalai.logging import DistributedLogger
  from colossalai.shardformer import ShardConfig, ShardFormer
  from .base import BaseModel
label_desc: Use image node_id 2 for calling the HuggingFaceModel obj's underlying member method code with example usage: obj._get_choices_indices(language) without return types