<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _translate_nd(self, source: mx.nd.NDArray, source_length: int, restrict_lexicon: Optional[lexicon.TopKLexicon], raw_constraints: List[Optional[constrained.RawConstraintList]], raw_avoid_list: List[Optional[constrained.RawConstraintList]], max_output_lengths: mx.nd.NDArray) -> List[Translation]: """ Translates source of source_length, given a bucket_key. :param source: Source ids. Shape: (batch_size, bucket_key, num_factors). :param source_length: Bucket key. :param restrict_lexicon: Lexicon to use for vocabulary restriction. :param raw_constraints: A list of optional constraint lists. :return: Sequence of translations. """

        return self._get_best_from_beam(*self._beam_search(source,
                                                           source_length,
                                                           restrict_lexicon,
                                                           raw_constraints,
                                                           raw_avoid_list,
                                                           max_output_lengths))