code: def _create_pod(
      pod_name: str,
      pod_labels: Dict[str, str],
      rank: str,
      world_size: int,
      driver_addr: str,
      driver_port: str,
      app_id: str,
      extra_envs: List[List[str]],
      labels: List[List[str]],
      pod_cpu: str,
      pod_memory: str,
      pod_epc_memory: str,
      image: str,
      command: str,
      use_command: bool,
      sgx_enabled: bool,
      volume_strs: List[str],
      volume_mount_strs: List[str],
      pod_file_template_str: Optional[str],
  ) -> client.V1Pod:
      api_client = client.ApiClient()
      metadata = client.V1ObjectMeta(name=pod_name, labels=pod_labels)
      envs = [
          client.V1EnvVar(name="WORLD_SIZE", value=f"{world_size}"),
          client.V1EnvVar(name="RANK", value=rank),
          client.V1EnvVar(name="MASTER_ADDR", value=driver_addr),
          client.V1EnvVar(name="MASTER_PORT", value=driver_port),
          client.V1EnvVar(name="APP_ID", value=app_id),
      ]
  
      if pod_file_template_str is not None:
          pod_body: client.V1Pod = _deserialize_pod_object(
              pod_file_template_str, api_client
          )
          pod_body.metadata.name = pod_name
          pod_body.metadata.labels.update(pod_labels)
          pod_body.spec.containers[0].env.extend(envs)
          pod_body.spec.restart_policy = "Never"
      else:
          for env in extra_envs:
              envs.append(
                  client.V1EnvVar(name=env[0], value=env[1]),
              )
  
          node_selector = {}
          for label in labels:
              node_selector[label[0]] = label[1]
  
          requests = {
              "cpu": pod_cpu,
              "memory": pod_memory,
          }
  
          limits = {
              "cpu": pod_cpu,
              "memory": pod_memory,
          }
          if sgx_enabled:
              requests["sgx.intel.com/epc"] = pod_epc_memory
              requests["sgx.intel.com/enclave"] = "1"
              requests["sgx.intel.com/provision"] = "1"
              limits["sgx.intel.com/enclave"] = "1"
              limits["sgx.intel.com/provision"] = "1"
              limits["sgx.intel.com/epc"] = pod_epc_memory
          resource = client.V1ResourceRequirements(
              limits=limits, requests=requests
          )
          volume_mounts = [
              _deserialize_volume_mounts_object(json_str, api_client)
              for json_str in volume_mount_strs
          ]
          if use_command:
              container = client.V1Container(
                  name="pytorch",
                  image=image,
                  env=envs,
                  command=command,
                  resources=resource,
                  volume_mounts=volume_mounts,
              )
          else:
              container = client.V1Container(
                  name="pytorch",
                  image=image,
                  env=envs,
                  args=command,
                  resources=resource,
                  volume_mounts=volume_mounts,
              )
  
          volumes = [
              _deserialize_volume_object(json_str, api_client)
              for json_str in volume_strs
          ]
  
          pod_spec = client.V1PodSpec(
              containers=[container],
              restart_policy="Never",
              volumes=volumes,
              node_selector=node_selector,
          )
          pod_body = client.V1Pod(
              api_version="v1",
              metadata=metadata,
              kind="Pod",
              spec=pod_spec,
          )
  
      return pod_body
  
imports: from uuid import uuid4
  from kubernetes import client, config
  from kubernetes.client import ApiClient
  from argparse import REMAINDER, ArgumentParser
  import functools
  from typing import Dict, List, Callable, Optional
  import yaml
  import json
  from os import path
  from bigdl.nano.utils.common import invalidInputError
label_desc: Use image node_id 7 for calling a global function with example usage: _create_pod(pod_name, pod_labels, rank, world_size, driver_addr, driver_port, app_id, extra_envs, labels, pod_cpu, pod_memory, pod_epc_memory, image, command, use_command, sgx_enabled, volume_strs, volume_mount_strs, pod_file_template_str) and returns: pod_body