class_docstr: DeepSpeed engine for training and inference.
class_docstr_tok: ["DeepSpeed","engine","for","training","and","inference","."]
code: def eval(self):
      if self._t_start is not None:
          latency = time.time() - self._t_start
          self._total_latency = self._total_latency + latency
          self._iters = self._iters + 1
          if not dist.is_initialized() or dist.get_rank() == 0:
              if self._total_batch_size is not None:
                  cur_samples_p_sec = f"|CurSamplesPerSec={(1 / latency * self._total_batch_size):.2f} "
                  avg_samples_p_sec = f"|AvgSamplesPerSec={(1 / (self._total_latency / self._iters) * self._total_batch_size):.2f}"
              else:
                  cur_samples_p_sec = ""
                  avg_samples_p_sec = ""
              others = latency - (
                  self._generate_latency + self._training_latency
              )
              print(
                  f"|E2E latency={(latency):.2f}s "
                  + f"|Gather latency={self._gather_latency:.2f}s ({(self._gather_latency / latency * 100):.2f}%) "
                  f"|Generate time={(self._generate_latency):.2f}s ({(self._generate_latency / latency * 100):.2f}%) "
                  + f"|Training time={(self._training_latency):.2f}s ({(self._training_latency / latency * 100):.2f}%) "
                  + f"|Others={others:.2f} ({(others / latency * 100):.2f}%)"
                  + cur_samples_p_sec
                  + avg_samples_p_sec
              )
          self._t_start = time.time()
      self._training_latency = 0
      super().eval()
      if len(self._inference_containers) > 0:
          for i, (orig_module, inference_container) in enumerate(
              zip(self._orig_modules, self._inference_containers)
          ):
              if self.Z3_enabled and not self.gather_all_layers:
                  orig_module.forward = self._zero3_forward(i)
              else:
                  orig_module.forward = (
                      inference_container.module.forward
                  )
  
              inference_container.transform_for_inference()
  
          if not self.Z3_enabled or self.gather_all_layers:
              for orig_module, inference_layer in zip(
                  self._orig_modules_others, self._other_layers
              ):
                  orig_module.forward = inference_layer.forward
      if self.Z3_enabled:
          gc.collect()
          get_accelerator().empty_cache()
      if self._t_start is None:
          self._t_start = time.time()
  
imports: import torch
  from deepspeed.inference.config import DeepSpeedInferenceConfig
  from deepspeed.module_inject.replace_policy import replace_policies
  from deepspeed.module_inject.utils import policy_to_ds_container
  from .engine import DeepSpeedEngine
  from .utils import TLinear, get_inactive_params
  from deepspeed.runtime.zero import GatheredParameters
  import time
  import gc
  import math
  from deepspeed import comm
  from deepspeed.accelerator import get_accelerator
  from torch import nn
  from deepspeed.utils import logger
  from deepspeed.ops.op_builder import InferenceBuilder
  from deepspeed.module_inject.layers import LinearLayer, Normalize, EmbeddingLayer, OPTEmbedding
label_desc: Use image node_id 15 for calling the DeepSpeedHybridEngine obj's underlying member method code with example usage: obj.eval() without return types