(self,  # type: ignore
                                 child_index: int,
                                 all_arc_indices: List[Tuple[int, int]],
                                 seq_len: int)
return (child_index, self._rng.sample(non_parents, 1)[0])
Given a child index, generate a new (child, index) pair where
        ``index`` refers to an index in the sequence that is not a parent
        of the provided child.

        Parameters
        ----------
        child_index: ``int``, required
            The index of the child to sample a negative example for.
        all_arc_indices: ``List[Tuple[int, int]]``, required
            A list of (child index, parent index) pairs that correspond to each
            dependency arc in the sentence. Indices are 0 indexed.
        seq_len: ``int``, required
            The length of the sequence.
Given a child index, generate a new (child, index) pair where
        ``index`` refers to an index in the sequence that is not a parent
        of the provided child.
Given a child index generate a new ( child index ) pair where index refers to an index in the sequence that is not a parent of the provided child .
def _sample_negative_indices(self,  # type: ignore
                                 child_index: int,
                                 all_arc_indices: List[Tuple[int, int]],
                                 seq_len: int):
        """
        Given a child index, generate a new (child, index) pair where
        ``index`` refers to an index in the sequence that is not a parent
        of the provided child.

        Parameters
        ----------
        child_index: ``int``, required
            The index of the child to sample a negative example for.
        all_arc_indices: ``List[Tuple[int, int]]``, required
            A list of (child index, parent index) pairs that correspond to each
            dependency arc in the sentence. Indices are 0 indexed.
        seq_len: ``int``, required
            The length of the sequence.
        """
        # All possible parents
        all_possible_parents = set(range(seq_len))
        # Find all the parents of the child.
        parents = {arc_indices[1] for arc_indices in all_arc_indices if
                   arc_indices[0] == child_index}
        # Get the indices that are not parents of the child or the child itself
        non_parents = all_possible_parents - parents.union({child_index})
        # If there are no indices that are not a parent.
        if not non_parents:
            return None
        return (child_index, self._rng.sample(non_parents, 1)[0])
def _sample_negative_indices ( self , # type: ignore child_index : int , all_arc_indices : List [ Tuple [ int , int ] ] , seq_len : int ) : # All possible parents all_possible_parents = set ( range ( seq_len ) ) # Find all the parents of the child. parents = { arc_indices [ 1 ] for arc_indices in all_arc_indices if arc_indices [ 0 ] == child_index } # Get the indices that are not parents of the child or the child itself non_parents = all_possible_parents - parents . union ( { child_index } ) # If there are no indices that are not a parent. if not non_parents : return None return ( child_index , self . _rng . sample ( non_parents , 1 ) [ 0 ] )