def tile(x, multiples):
    """
    PyTorch implementation of tf.tile(). See https://stackoverflow.com/a/52259068.
    Constructs a tensor by tiling a given tensor.

    This operation creates a new tensor by replicating input multiples times.
    The output tensor's i'th dimension has input.dims(i) * multiples[i] elements, and the values of input are
    replicated multiples[i] times along the 'i'th dimension.
    For example, tiling [a b c d] by [2] produces [a b c d a b c d].
    """
    return x.repeat(multiples)