(batch, side, data_type='text')
Args:
        batch (Tensor): a batch of source or target data.
        side (str): for source or for target.
        data_type (str): type of the source input.
            Options are [text|img|audio].
    Returns:
        A sequence of src/tgt tensors with optional feature tensors
        of size (len x batch).
Args:
        batch (Tensor): a batch of source or target data.
        side (str): for source or for target.
        data_type (str): type of the source input.
            Options are [text|img|audio].
    Returns:
        A sequence of src/tgt tensors with optional feature tensors
        of size (len x batch).
Args : batch ( Tensor ) : a batch of source or target data . side ( str ) : for source or for target . data_type ( str ) : type of the source input . Options are [ text|img|audio ] . Returns : A sequence of src / tgt tensors with optional feature tensors of size ( len x batch ) .
def make_features(batch, side, data_type='text'):
    """
    Args:
        batch (Tensor): a batch of source or target data.
        side (str): for source or for target.
        data_type (str): type of the source input.
            Options are [text|img|audio].
    Returns:
        A sequence of src/tgt tensors with optional feature tensors
        of size (len x batch).
    """
    assert side in ['src', 'tgt']
    if isinstance(batch.__dict__[side], tuple):
        data = batch.__dict__[side][0]
    else:
        data = batch.__dict__[side]

    feat_start = side + "_feat_"
    keys = sorted([k for k in batch.__dict__ if feat_start in k])
    features = [batch.__dict__[k] for k in keys]
    levels = [data] + features

    if data_type == 'text':
        return torch.cat([level.unsqueeze(2) for level in levels], 2)
    else:
        return levels[0]
def make_features ( batch , side , data_type = 'text' ) : assert side in [ 'src' , 'tgt' ] if isinstance ( batch . __dict__ [ side ] , tuple ) : data = batch . __dict__ [ side ] [ 0 ] else : data = batch . __dict__ [ side ] feat_start = side + "_feat_" keys = sorted ( [ k for k in batch . __dict__ if feat_start in k ] ) features = [ batch . __dict__ [ k ] for k in keys ] levels = [ data ] + features if data_type == 'text' : return torch . cat ( [ level . unsqueeze ( 2 ) for level in levels ] , 2 ) else : return levels [ 0 ]