code: def primary_metric_from_pb(
      pm_pb: pb.PrimaryMetric,
  ) -> Optional[PrimaryMetric]:
      if not pm_pb.name:
          return None
      if pm_pb.goal == pb.PrimaryMetric.Goal.MAXIMIZE:
          goal = "maximize"
      else:
          goal = "minimize"
  
      return PrimaryMetric(
          name=pm_pb.name,
          goal=goal,
      )
  
imports: import datetime
  import json
  from typing import List, Dict, Any, Optional, MutableMapping
  from google.protobuf import timestamp_pb2
  from .servicepb import keepsake_pb2
  from .experiment import Experiment
  from .checkpoint import Checkpoint, PrimaryMetric, CheckpointList
label_desc: Use image node_id 9 for calling a global function with example usage: primary_metric_from_pb(pm_pb) and returns: PrimaryMetric, None