code: def _get_penalties(
      input_metadata: InputMetadata,
  ) -> Tuple[List[float], List[float]]:
      # Collect the presence and frequency penalties.
      presence_penalties: List[float] = []
      frequency_penalties: List[float] = []
      for seq_group in input_metadata.seq_groups:
          seq_ids, sampling_params = seq_group
          p = sampling_params.presence_penalty
          f = sampling_params.frequency_penalty
          presence_penalties += [p] * len(seq_ids)
          frequency_penalties += [f] * len(seq_ids)
      return presence_penalties, frequency_penalties
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  from bigdl.llm.vllm.model_executor.input_metadata import InputMetadata
  from bigdl.llm.vllm.sampling_params import SamplingParams, SamplingType
  from bigdl.llm.vllm.sequence import SamplerOutput, SequenceGroupMetadata, SequenceData, SequenceOutputs
  import time
label_desc: Use image node_id 2 for calling a global function with example usage: _get_penalties(input_metadata) and returns: presence_penalties,  frequency_penalties