code: def _convert_to_kube_env(
      env: infra_validator_pb2.EnvVar,
  ) -> k8s_client.V1EnvVar:
      """Convert infra_validator_pb2.EnvVar to kubernetes.V1EnvVar."""
      if not env.name:
          raise ValueError("EnvVar.name must be specified.")
      if env.HasField("value_from"):
          if env.value_from.HasField("secret_key_ref"):
              value_source = k8s_client.V1EnvVarSource(
                  secret_key_ref=k8s_client.V1SecretKeySelector(
                      name=env.value_from.secret_key_ref.name,
                      key=env.value_from.secret_key_ref.key,
                  )
              )
              return k8s_client.V1EnvVar(
                  name=env.name, value_from=value_source
              )
          else:
              raise ValueError(f"Bad EnvVar: {env}")
      else:
          # Note that env.value can be empty.
          return k8s_client.V1EnvVar(name=env.name, value=env.value)
  
imports: import datetime
  import os
  import time
  from typing import Optional
  from absl import logging
  from apache_beam.utils import retry
  from kubernetes import client
  from kubernetes.client import rest
  from tfx.components.infra_validator import error_types
  from tfx.components.infra_validator import serving_bins
  from tfx.components.infra_validator.model_server_runners import base_runner
  from tfx.proto import infra_validator_pb2
  from tfx.utils import kube_utils
label_desc: Use image node_id 4 for calling a global function with example usage: _convert_to_kube_env(env) and returns: k8s_client, k8s_client