def pymil_broadcast_to(tensor: Var, shape: Union[Var, VARIABLE_SHAPE_TYPE], name: str) -> Var:
    """
    Similar to numpy.broadcast_to, broadcast a tensor to a new shape
    """
    if isinstance(shape, Var):
        shape_var = shape
        shape = shape_var.val
        if shape is not None:
            shape = shape.tolist()
    else:
        shape_var = mb.concat(values=shape, axis=0)

    # prepend extra dims
    rank = shape_var.shape[0]
    if rank > tensor.rank:
        new_dims = rank - tensor.rank
        tensor = mb.expand_dims(x=tensor, axes=list(range(new_dims)))

    # For symbolic shape, we can confirm if tile is necessary
    if (
        isinstance(shape, list)
        and all(not isinstance(size, Var) for size in shape)
        and not does_tile_necessary(tensor.shape, shape)
    ):
        return mb.identity(x=tensor, name=name)

    if any_symbolic(tensor.shape) or shape_var.val is None:
        tensor_shape = mb.shape(x=tensor)
        reps = mb.real_div(x=shape_var, y=tensor_shape)
        reps = mb.cast(x=reps, dtype="int32")
        res = mb.tile(x=tensor, reps=reps, name=name)
    else:
        reps = []
        for ts, ds in zip(tensor.shape, shape_var.val):
            if ts == 1 and ds > 0:
                reps.append(ds)
            else:
                reps.append(1)
        res = mb.tile(x=tensor, reps=reps, name=name)
    return res

    Similar to numpy.broadcast_to, broadcast a tensor to a new shape
    
coremltools/converters/mil/frontend/_utils.py