code: def crop_and_deduplicate_names(names):
      """Crops and de-duplicates the passed names.
  
      SC2 gets confused in a multi-agent game when agents have the same
      name. We check for name duplication to avoid this, but - SC2 also
      crops player names to a hard character limit, which can again lead
      to duplicate names. To avoid this we unique-ify names if they are
      equivalent after cropping. Ideally SC2 would handle duplicate names,
      making this unnecessary.
  
      TODO(b/121092563): Fix this in the SC2 binary.
  
      Args:
        names: List of names.
  
      Returns:
        De-duplicated names cropped to 32 characters.
      """
      max_name_length = 32
  
      # Crop.
      cropped = [n[:max_name_length] for n in names]
  
      # De-duplicate.
      deduplicated = []
      name_counts = collections.Counter(n for n in cropped)
      name_index = collections.defaultdict(lambda: 1)
      for n in cropped:
          if name_counts[n] == 1:
              deduplicated.append(n)
          else:
              deduplicated.append("({}) {}".format(name_index[n], n))
              name_index[n] += 1
  
      # Crop again.
      recropped = [n[:max_name_length] for n in deduplicated]
      if len(set(recropped)) != len(recropped):
          raise ValueError("Failed to de-duplicate names")
  
      return recropped
  
imports: import collections
  import copy
  import random
  import time
  from absl import logging
  from pysc2 import maps
  from pysc2 import run_configs
  from pysc2.env import enums
  from pysc2.env import environment
  from pysc2.lib import actions
  from pysc2.lib import features
  from pysc2.lib import metrics
  from pysc2.lib import portspicker
  from pysc2.lib import renderer_human
  from pysc2.lib import run_parallel
  from pysc2.lib import stopwatch
  from s2clientprotocol import sc2api_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: crop_and_deduplicate_names(names) and returns: recropped