def fetch_attr(model: _torch.nn.Module, target: str) -> _Any:
    """
    Returns attribute within model that corresponds to the input target string.
    """

    target_atoms = target.split(".")
    attr_itr = model
    for i, atom in enumerate(target_atoms):
        if not hasattr(attr_itr, atom):
            raise RuntimeError(
                f"Node referenced nonexistent target {'.'.join(target_atoms[:i])}"
            )
        attr_itr = getattr(attr_itr, atom)
    return attr_itr

    Returns attribute within model that corresponds to the input target string.
    
coremltools/optimize/torch/_utils/transforms.py