class_docstr: Backend worker to handle Model Server's python service code
code: def __init__(
      self,
      s_type: Optional[str] = None,
      s_name: Optional[str] = None,
      host_addr: Optional[str] = None,
      port_num: Optional[int] = None,
      metrics_config: Optional[str] = None,
  ):
      self.sock_type = s_type
  
      if s_type == "unix":
          if s_name is None:
              raise ValueError(
                  "Wrong arguments passed. No socket name given."
              )
          s_name_parts = s_name.rsplit(".", 1)
          logging.info(
              "s_name_part0=%s, s_name_part1=%s, pid=%d",
              s_name_parts[0],
              s_name_parts[1],
              os.getpid(),
          )
          s_name_new = (
              s_name_parts[0]
              + "."
              + str(int(s_name_parts[1]) + LOCAL_RANK)
          )
          self.sock_name, self.port = s_name_new, -1
          try:
              os.remove(s_name_new)
          except OSError as e:
              if os.path.exists(s_name_new):
                  raise RuntimeError(
                      "socket already in use: {}.".format(s_name_new)
                  ) from e
          logging.info("Listening on port: %s", s_name_new)
      elif s_type == "tcp":
          self.sock_name = (
              host_addr if host_addr is not None else "127.0.0.1"
          )
          if port_num is None:
              raise ValueError(
                  "Wrong arguments passed. No socket port given."
              )
          self.port = int(port_num) + LOCAL_RANK
          logging.info(
              "Listening on addr:port: %s:%d", self.sock_name, self.port
          )
      else:
          raise ValueError("Incomplete data provided")
  
      socket_family = (
          socket.AF_INET if s_type == "tcp" else socket.AF_UNIX
      )
      self.sock = socket.socket(socket_family, socket.SOCK_STREAM)
      self.metrics_cache = MetricsCacheYamlImpl(
          config_file_path=metrics_config
      )
      if self.metrics_cache:
          self.metrics_cache.initialize_cache()
      else:
          raise RuntimeError(
              f"Failed to initialize metrics from file {metrics_config}"
          )
  
file_path: serve/ts/model_service_worker.py
imports: import logging
  import os
  import platform
  import socket
  import sys
  from typing import Optional
  from ts.arg_parser import ArgParser
  from ts.metrics.metric_cache_yaml_impl import MetricsCacheYamlImpl
  from ts.model_loader import ModelLoaderFactory
  from ts.protocol.otf_message_handler import create_load_model_response, retrieve_msg
label_desc: Use image node_id 1 to create a new TorchModelServiceWorker object from inherited base classes: object with example: obj = TorchModelServiceWorker(s_type, s_name, host_addr, port_num, metrics_config)