code: def _find_cluster_extremes_shared(cluster, jaccard_threshold):
      """Find a reduced cluster such that each code in the origin cluster is similar to at least one code in the reduced cluster.
      Two codes are similar if their Jaccard similarity is above the threshold.
  
      Args:
          cluster (List[dict]):
             cluster is a list of dict, each dict contains the following keys:
                  - base_index
                  - repo_name
                  - path
              This is a typical output of DuplicationIndex.get_duplicate_clusters()
          jaccard_threshold (float):
              threshold for Jaccard similarity.
              Two codes are similar if their Jaccard similarity is above the threshold.
  
      Returns:
          extremes (List[dict]):
              A reduced representation of the cluster. The field copies is added to each dict.
              The copies field indicates the number of similar codes in the cluster for a extreme.
      """
      extremes = []
      for element1 in cluster:
          code1 = _shared_dataset[element1["base_index"]]["content"]
          for element2 in extremes:
              code2 = _shared_dataset[element2["base_index"]]["content"]
              if jaccard_similarity(code1, code2) >= jaccard_threshold:
                  element2["copies"] += 1
                  break
          else:
              element1["copies"] = 1
              extremes.append(element1)
      return extremes
  
imports: import json
  import multiprocessing
  import re
  from collections import defaultdict
  from functools import partial
  from typing import Dict, List, Optional, Set, Tuple, Type
  from datasets import Dataset
  from datasketch import MinHash, MinHashLSH
  from dpu_utils.utils.iterators import ThreadedIterator
  from tqdm import tqdm
label_desc: Use image node_id 7 for calling a global function with example usage: _find_cluster_extremes_shared(cluster, jaccard_threshold) and returns: extremes