code: def init_batch(raw_constraints: List[Optional[RawConstraintList]],
                 beam_size: int,
                 start_id: int,
                 eos_id: int) -> List[Optional[ConstrainedHypothesis]]:
      
      constraints = [None] * (len(raw_constraints) * beam_size)  # type: List[Optional[ConstrainedHypothesis]]
      if any(raw_constraints):
          for i, raw_list in enumerate(raw_constraints):
              num_constraints = sum([len(phrase) for phrase in raw_list]) if raw_list is not None else 0
              if num_constraints > 0:
                  hyp = ConstrainedHypothesis(raw_list, eos_id)
                  idx = i * beam_size
                  constraints[idx:idx + beam_size] = [hyp.advance(start_id) for x in range(beam_size)]
  
      return constraints
docs: :param raw_constraints: The list of raw constraints (list of list of IDs).
      :param beam_size: The beam size.
      :param start_id: The target-language vocabulary ID of the SOS symbol.
      :param eos_id: The target-language vocabulary ID of the EOS symbol.
      :return: A list of ConstrainedHypothesis objects (shape: (batch_size * beam_size,)).