def deploy(self, initial_instance_count, instance_type, accelerator_type=None, endpoint_name=None,
               update_endpoint=False, tags=None, kms_key=None):
        """Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``.

        Create a SageMaker ``Model`` and ``EndpointConfig``, and deploy an ``Endpoint`` from this ``Model``.
        If ``self.predictor_cls`` is not None, this method returns a the result of invoking
        ``self.predictor_cls`` on the created endpoint name.

        The name of the created model is accessible in the ``name`` field of this ``Model`` after deploy returns

        The name of the created endpoint is accessible in the ``endpoint_name``
        field of this ``Model`` after deploy returns.

        Args:
            instance_type (str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge'.
            initial_instance_count (int): The initial number of instances to run in the
                ``Endpoint`` created from this ``Model``.
            accelerator_type (str): Type of Elastic Inference accelerator to deploy this model for model loading
                and inference, for example, 'ml.eia1.medium'. If not specified, no Elastic Inference accelerator
                will be attached to the endpoint.
                For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html
            endpoint_name (str): The name of the endpoint to create (default: None).
                If not specified, a unique endpoint name will be created.
            update_endpoint (bool): Flag to update the model in an existing Amazon SageMaker endpoint.
                If True, this will deploy a new EndpointConfig to an already existing endpoint and delete resources
                corresponding to the previous EndpointConfig. If False, a new endpoint will be created. Default: False
            tags(List[dict[str, str]]): The list of tags to attach to this specific endpoint.
            kms_key (str): The ARN of the KMS key that is used to encrypt the data on the
                storage volume attached to the instance hosting the endpoint.

        Returns:
            callable[string, sagemaker.session.Session] or None: Invocation of ``self.predictor_cls`` on
                the created endpoint name, if ``self.predictor_cls`` is not None. Otherwise, return None.
        """
        if not self.sagemaker_session:
            if instance_type in ('local', 'local_gpu'):
                self.sagemaker_session = local.LocalSession()
            else:
                self.sagemaker_session = session.Session()

        if self.role is None:
            raise ValueError("Role can not be null for deploying a model")

        compiled_model_suffix = '-'.join(instance_type.split('.')[:-1])
        if self._is_compiled_model:
            self.name += compiled_model_suffix

        self._create_sagemaker_model(instance_type, accelerator_type, tags)
        production_variant = sagemaker.production_variant(self.name, instance_type, initial_instance_count,
                                                          accelerator_type=accelerator_type)
        if endpoint_name:
            self.endpoint_name = endpoint_name
        else:
            self.endpoint_name = self.name
            if self._is_compiled_model and not self.endpoint_name.endswith(compiled_model_suffix):
                self.endpoint_name += compiled_model_suffix

        if update_endpoint:
            endpoint_config_name = self.sagemaker_session.create_endpoint_config(
                name=self.name,
                model_name=self.name,
                initial_instance_count=initial_instance_count,
                instance_type=instance_type,
                accelerator_type=accelerator_type,
                tags=tags,
                kms_key=kms_key)
            self.sagemaker_session.update_endpoint(self.endpoint_name, endpoint_config_name)
        else:
            self.sagemaker_session.endpoint_from_production_variants(self.endpoint_name, [production_variant],
                                                                     tags, kms_key)

        if self.predictor_cls:
            return self.predictor_cls(self.endpoint_name, self.sagemaker_session)