from typing import Dict
from typing import Any
import torch
from typing import List


def batch_tile(objects: Dict[str, Any], dim: int, n_reps: int):
    """
    replicate torch tensor along with specified dimension.

    @param objects: dictionary of objects. it should include torch.Tensor objects.
    @param dim: dimension to be replicated.
    @param n_reps: number of replications.
    @return: dictionary of objects.
    """
    ret = {}
    for key, object in objects.items():
        if isinstance(object, torch.Tensor):
            dims = [1,]* object.ndim
            dims[dim] = n_reps
            ret[key] = torch.tile(object, dims)
        elif isinstance(object, List):
            ret[key] = [object[0],] * n_reps
        else:
            ret[key] = object
    return ret