def __call__(self, sample):
sample_length = len(sample)<EOL>if sample_length >= self._length:<EOL><INDENT>if self._clip and sample_length > self._length:<EOL><INDENT>return sample[:self._length]<EOL><DEDENT>else:<EOL><INDENT>return sample<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(sample, mx.nd.NDArray):<EOL><INDENT>new_sample_shape = (self._length,) + sample.shape[<NUM_LIT:1>:]<EOL>ret = mx.nd.full(shape=new_sample_shape, val=self._pad_val, ctx=sample.context,<EOL>dtype=sample.dtype)<EOL>ret[:sample_length] = sample<EOL>return ret<EOL><DEDENT>elif isinstance(sample, np.ndarray):<EOL><INDENT>pad_width = [(<NUM_LIT:0>, self._length - sample_length)] +[(<NUM_LIT:0>, <NUM_LIT:0>) for _ in range(sample.ndim - <NUM_LIT:1>)]<EOL>return np.pad(sample, mode='<STR_LIT>', constant_values=self._pad_val,<EOL>pad_width=pad_width)<EOL><DEDENT>elif isinstance(sample, list):<EOL><INDENT>return sample + [self._pad_val for _ in range(self._length - sample_length)]<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError('<STR_LIT>'<EOL>'<STR_LIT>' % str(type(sample)))<EOL><DEDENT><DEDENT>
Parameters
----------
sample : list of number or mx.nd.NDArray or np.ndarray

Returns
-------
ret : list of number or mx.nd.NDArray or np.ndarray