class_docstr: Flask SentenceBERT server, which helps to calculate str/token embeddings
class_docstr_tok: ["Flask","SentenceBERT","server",",","which","helps","to","calculate","str\/token","embeddings"]
code: def __init__(
      self,
      name: str,
      devices: str,
      tokenizer: TokenizerSpec,
      sentence_bert: str = "all-mpnet-base-v2",
      sentence_bert_batch: int = 4,
  ):
      self.app = Flask(__name__, static_url_path="")
  
      if devices is None or not torch.cuda.is_available():
          device_list = None
      else:
          device_list = [
              "cuda:" + str(device) for device in devices.split(",")
          ]
  
      self.bert_model = SentenceTransformer(sentence_bert)
      self.name = name
      self.tokenizer = tokenizer
      self.pool = self.bert_model.start_multi_process_pool(device_list)
      self.sentence_bert_batch = sentence_bert_batch
      api = Api(self.app)
      api.add_resource(
          SentenceBertResource,
          "/knn",
          resource_class_args=[
              self.bert_model,
              self.tokenizer,
              self.pool,
              self.sentence_bert_batch,
          ],
      )
  
file_path: NeMo/nemo/collections/nlp/modules/common/megatron/retrieval_services/bert_service.py
imports: import base64
  import pickle
  import threading
  import time
  from typing import List, Union
  import torch
  from flask import Flask, jsonify, request
  from flask_restful import Api, Resource
  from sentence_transformers import SentenceTransformer
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
label_desc: Use image node_id 1 to create a new SentenceBertServer object from inherited base classes: object with example: obj = SentenceBertServer(name, devices, tokenizer, sentence_bert, sentence_bert_batch)