code: def create_cnn(
      base_model: Union[str, Model],
      num_classes: int,
      drop_out=0.5,
      keras_applications: bool = True,
      pooling: str = "avg",
      weights: Union[str, None] = "imagenet",
      name: Optional[str] = None,
  ) -> Model:
      assert pooling in ("avg", "max")
  
      if keras_applications:
          if num_classes == 2:
              outputs = 1
          else:
              outputs = num_classes
      else:
          print(
              "num_classes is ignored. returning the passed model as it is."
          )
  
      if isinstance(base_model, (str, Model)) and keras_applications:
          base_model = _get_base_cnn(
              base_model, pooling=pooling, weights=weights
          )
          if "pool" not in base_model.layers[-1].name:
              raise AssertionError(
                  "base_model last layer must be a pooling layer"
              )
          model = _add_output_layers(
              base_model, outputs, drop_out=drop_out, name=name
          )
  
      elif (
          isinstance(base_model, Model) and keras_applications is False
      ):
          model = base_model
  
      elif isinstance(base_model, str) and keras_applications is False:
          model = _get_base_cnn(
              base_model, weights="imagenet", include_top=True
          )
  
      else:
          print("Invalid arguments!")
      return model
  
imports: import inspect
  from functools import partial
  from typing import Any, List, Optional, Union
  import matplotlib.cm
  import matplotlib.pyplot
  import numpy
  import tensorflow
  import tensorflow_addons
  from PIL import Image
  from tensorflow import keras
  from tensorflow.keras.models import Model
  from tf_keras_vis.gradcam import Gradcam, GradcamPlusPlus
  from tf_keras_vis.utils import normalize
  from typeguard import check_argument_types, typechecked
  from chitra.import_utils import is_installed
  from .datagenerator import Dataset
label_desc: Use image node_id 4 for calling a global function with example usage: create_cnn(base_model, num_classes, drop_out, keras_applications, pooling, weights, name) and returns: model