def _get_weighted_mod_pattern(
    mod_fn: _Callable,
    example_inputs: _Tuple[_torch.Tensor, ...],
    act_fn: _Optional[_Callable] = None,
    act_in_place: bool = False,
) -> _torch.nn.Module:
    """
    Returns an aten graph corresponding to a sequence of these ops:
    input -> weighted_mod -> activation -> output

    A weighted mod is a module which has a weight and bias, such as a
    convolution module or a linear module.

    No activation is used if ``act_fn`` is ``None``.
    ``act_fn`` is an activation function from _supported_activations or
    _supported_activations_no_inplace
    """

    class Pattern(_torch.nn.Module):
        def forward(self, input, weight, bias):
            mod_out = mod_fn(input, weight, bias)
            output = mod_out
            node_dict = {
                "input": input,
                "mod": mod_out,
                "weight": weight,
                "bias": bias,
            }
            if act_fn is not None:
                # Only add output if activation function is applied to model output
                output = act_fn(output, inplace=True) if act_in_place else act_fn(output)
                node_dict["output"] = output
            return output, node_dict

    return _get_aten_graph_module(Pattern(), example_inputs)

    Returns an aten graph corresponding to a sequence of these ops:
    input -> weighted_mod -> activation -> output

    A weighted mod is a module which has a weight and bias, such as a
    convolution module or a linear module.

    No activation is used if ``act_fn`` is ``None``.
    ``act_fn`` is an activation function from _supported_activations or
    _supported_activations_no_inplace
    
coremltools/optimize/torch/quantization/_coreml_quantizer_utils.py