def add_embedding(self, tag, embedding, labels=None, images=None, global_step=None):
embedding_shape = embedding.shape<EOL>if len(embedding_shape) != <NUM_LIT:2>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % len(embedding_shape))<EOL><DEDENT>data_dir = _get_embedding_dir(tag, global_step)<EOL>save_path = os.path.join(self.get_logdir(), data_dir)<EOL>try:<EOL><INDENT>os.makedirs(save_path)<EOL><DEDENT>except OSError:<EOL><INDENT>logging.warning('<STR_LIT>',<EOL>save_path)<EOL><DEDENT>if labels is not None:<EOL><INDENT>if (embedding_shape[<NUM_LIT:0>] != len(labels) and<EOL>(not _is_2D_matrix(labels) or len(labels) != embedding_shape[<NUM_LIT:0>] + <NUM_LIT:1>)):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (embedding_shape[<NUM_LIT:0>], len(labels)))<EOL><DEDENT>if self._logger is not None:<EOL><INDENT>self._logger.info('<STR_LIT>', save_path)<EOL><DEDENT>_make_metadata_tsv(labels, save_path)<EOL><DEDENT>if images is not None:<EOL><INDENT>img_labels_shape = images.shape<EOL>if embedding_shape[<NUM_LIT:0>] != img_labels_shape[<NUM_LIT:0>]:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % (embedding_shape[<NUM_LIT:0>],<EOL>img_labels_shape[<NUM_LIT:0>]))<EOL><DEDENT>if self._logger is not None:<EOL><INDENT>self._logger.info('<STR_LIT>', save_path)<EOL><DEDENT>_make_sprite_image(images, save_path)<EOL><DEDENT>if self._logger is not None:<EOL><INDENT>self._logger.info('<STR_LIT>', save_path)<EOL><DEDENT>_save_embedding_tsv(embedding, save_path)<EOL>_add_embedding_config(self.get_logdir(), data_dir, labels is not None,<EOL>images.shape if images is not None else None)<EOL>
Adds embedding projector data to the event file. It will also create a config file
        used by the embedding projector in TensorBoard. The folder containing the embedding
        data is named using the formula:
        If global_step is not None, the folder name is `tag + '_' + str(global_step).zfill(6)`;
        else, the folder name is `tag`.
        For example, tag = 'mnist', global_step = 12, the folder's name is 'mnist_000012';
        when global_step = None, the folder's name is 'mnist'.
        See the following reference for the meanings of labels and images.
        Ref: https://www.tensorflow.org/versions/r1.2/get_started/embedding_viz

        Note: This function internally calls `asnumpy()` for MXNet `NDArray` inputs.
        Since `asnumpy()` is a blocking function call, this function would block the main
        thread till it returns. It may consequently affect the performance of async execution
        of the MXNet engine.

        Parameters
        ----------
            tag : str
                Name for the `embedding`.
            embedding : MXNet `NDArray` or  `numpy.ndarray`
                A matrix whose each row is the feature vector of a data point.
            labels : MXNet `NDArray` or `numpy.ndarray` or a list of elements convertible to str.
                Labels corresponding to the data points in the `embedding`. If the labels are 2D
                the first row is considered the column names.
            images : MXNet `NDArray` or `numpy.ndarray`
                Images of format NCHW corresponding to the data points in the `embedding`.
            global_step : int
                Global step value to record. If not set, default to zero.