code: def decode_object_ref_if_needed(object_ref: str) -> bytes:
      """Decode objectRef bytes string.
  
      gRPC reply contains an objectRef that is encodded by Base64.
      This function is used to decode the objectRef.
      Note that there are times that objectRef is already decoded as
      a hex string. In this case, just convert it to a binary number.
      """
      if object_ref.endswith("="):
          # If the object ref ends with =, that means it is base64 encoded.
          # Object refs will always have = as a padding
          # when it is base64 encoded because objectRef is always 20B.
          return base64.standard_b64decode(object_ref)
      else:
          return ray._private.utils.hex_to_binary(object_ref)
  
imports: import base64
  import logging
  from collections import defaultdict
  from enum import Enum
  from typing import List
  import ray
  from ray._private.internal_api import node_stats
  from ray._raylet import ActorID, JobID, TaskID
label_desc: Use image node_id 1 for calling a global function with example usage: decode_object_ref_if_needed(object_ref) and returns: base64, ray