code: def _random_sample(
      selected_seq_groups: List[Tuple[List[int], SamplingParams]],
      is_prompts: List[bool],
      probs: torch.Tensor,
  ) -> List[Tuple[List[int], List[int]]]:
      # Find the maximum best_of value of the prompt phase requests.
      max_best_of = 1
      for seq_group, is_prompt in zip(selected_seq_groups, is_prompts):
          if is_prompt:
              seq_ids, sampling_params = seq_group
              max_best_of = max(max_best_of, sampling_params.best_of)
      random_samples = torch.multinomial(
          probs, num_samples=max_best_of, replacement=True
      ).cpu()
      sample_idx = 0
      results = []
      for seq_group, is_prompt in zip(selected_seq_groups, is_prompts):
          seq_ids, sampling_params = seq_group
          num_parent_seqs = len(seq_ids)
          if is_prompt:
              # Prompt phase.
              parent_ids = [0] * sampling_params.best_of
              next_token_ids = random_samples[
                  sample_idx, : sampling_params.best_of
              ].tolist()
          else:
              # Generation phase.
              parent_ids = list(range(num_parent_seqs))
              next_token_ids = random_samples[
                  sample_idx : sample_idx + num_parent_seqs, 0
              ].tolist()
          results.append((next_token_ids, parent_ids))
          sample_idx += num_parent_seqs
      return results
  
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 11 for calling a global function with example usage: _random_sample(selected_seq_groups, is_prompts, probs) and returns: results