def is_cluster_dim_valid(op: "Operation", cluster_dim: int, channel_axis: int) -> bool:
    """
    Check op-dependent restrictions for cluster_dim.

    For example, the conv's weight has shape [C_out, C_in/groups], but the effective shape in each
    group is actually [C_out/groups, C_in/groups], so we need to make sure the effective dim on
    channel_axis is divisible by `cluster_dim`. Similarly, for conv_transpose the weight has shape
    [C_in, C_out/groups], but the effective shape in each group is [C_in/groups, C_out/groups].

    Returns True if the cluster_dim is valid, False otherwise.
    """
    var = op.outputs[0]
    if channel_axis < 0:
        channel_axis += var.rank

    for child_op in var.child_ops:
        if child_op.op_type in {"conv", "conv_transpose"}:
            effective_shape = list(var.shape)
            if child_op.groups.val is not None and child_op.groups.val > 1:
                effective_shape[0] //= child_op.groups.val
            if effective_shape[channel_axis] % cluster_dim != 0:
                return False
    return True

    Check op-dependent restrictions for cluster_dim.

    For example, the conv's weight has shape [C_out, C_in/groups], but the effective shape in each
    group is actually [C_out/groups, C_in/groups], so we need to make sure the effective dim on
    channel_axis is divisible by `cluster_dim`. Similarly, for conv_transpose the weight has shape
    [C_in, C_out/groups], but the effective shape in each group is [C_in/groups, C_out/groups].

    Returns True if the cluster_dim is valid, False otherwise.
    
coremltools/optimize/_utils.py