def custom_getattr_mapper(node: torch.fx.Node, _: nn.Module) -> torch.fx.Node:
    """
    Custom function for mapping a call_function getattr to other ops.

    Supports:
    * getattr on a torch.Tensor with "shape", "device", or "dtype" attributes
    * getattr for accessing named tuples
    """
    # Have to use args here since getattr forces positional args.
    input_obj = node.args[0]
    attr_name = node.args[1]
    assert isinstance(input_obj, torch.fx.Node)
    input_obj_type = input_obj.meta["type"]

    # Handle named tuple access. NamedTupleMeta and the namedtuple factory function
    # create a subclass of tuple with an extra _fields attribute.
    if issubclass(input_obj_type, tuple) and hasattr(input_obj_type, "_fields"):
        idx = None
        for i, name in enumerate(input_obj_type._fields):
            if name == attr_name:
                idx = i
                break
        assert (
            idx is not None
        ), f"Named tuple type {input_obj_type} does not have field {name}"

        with node.graph.inserting_before(node):
            getitem_node = node.graph.call_function(
                getitem, kwargs={"input": input_obj, "idx": idx}
            )
            getitem_node.meta = node.meta.copy()
            return getitem_node

    assert input_obj_type in [
        torch.Tensor,
        torch.nn.parameter.Parameter,
    ], f"Expected torch.Tensor type for {input_obj_type}"
    assert (
        attr_name == "shape" or attr_name == "device" or attr_name == "dtype"
    ), f"Only supporting shape, device and dtype getattr for now, not {attr_name}"
    if attr_name == "shape":
        func = size
    elif attr_name == "device":
        func = device
    elif attr_name == "dtype":
        func = dtype
    with node.graph.inserting_before(node):
        size_node = node.graph.call_function(func, kwargs={"input": input_obj})
        size_node.meta = node.meta.copy()
        return size_node

    Custom function for mapping a call_function getattr to other ops.

    Supports:
    * getattr on a torch.Tensor with "shape", "device", or "dtype" attributes
    * getattr for accessing named tuples
    
fx2ait/fx2ait/acc_tracer/acc_ops.py