def _check_shape(arr):
            """
            return True if shape is of form
            (1,C,1,1) or (C,1,1)
            """
            rank = len(arr.shape)
            if not (rank == 3 or rank == 4):
                return False
            C = arr.shape[-3]
            if not (arr.shape == (1, C, 1, 1) or arr.shape == (C, 1, 1)):
                return False
            return True

            return True if shape is of form
            (1,C,1,1) or (C,1,1)
            
coremltools/converters/mil/mil/passes/defs/optimize_elementwise_binary.py