original_docstring: 
          Returns the pairwise distances from the given IDs to each other (or all
          points to each other, if ids is None). If the metric is not provided,
          the default metric for this Embedding object is used.
          
docstring: Returns the pairwise distances from the given IDs to each other (or all
  points to each other, if ids is None). If the metric is not provided,
  the default metric for this Embedding object is used.
docstring_tokens: Returns the pairwise distances from the given IDs to each other ( or all points to each other if ids is None ) . If the metric is not provided the default metric for this Embedding object is used .
code: def distances(self, ids=None, comparison_ids=None, metric=None):
          """
          Returns the pairwise distances from the given IDs to each other (or all
          points to each other, if ids is None). If the metric is not provided,
          the default metric for this Embedding object is used.
          """
          metric = metric or self.metric
          
          if ids is None:
              indexes = np.arange(len(self))
          else:
              indexes = self.index(ids)
              
          if comparison_ids is None:
              comparison_indexes = indexes
          else:
              comparison_indexes = self.index(comparison_ids)
  
          if len(self) > 2000 and len(indexes) < 2000 and len(comparison_indexes) < 2000:
              # Just compute the requested distances
              if metric == "euclidean":
                  return euclidean_distances(self.field(Field.POSITION, indexes),
                                             self.field(Field.POSITION, comparison_indexes))
              elif metric == "cosine":
                  return cosine_distances(self.field(Field.POSITION, indexes),
                                          self.field(Field.POSITION, comparison_indexes))
              elif metric == "precomputed":
                  return self.field(Field.POSITION, indexes)
              else:
                  raise NotImplementedError("Unsupported metric for distances")
          else:
              # Cache all pairwise distances
              if metric not in self._distances:
                  locations = self.field(Field.POSITION)
                  if metric == "euclidean":
                      self._distances[metric] = euclidean_distances(locations, locations)
                  elif metric == "cosine":
                      self._distances[metric] = cosine_distances(locations, locations)
                  elif metric == "precomputed":
                      self._distances[metric] = locations
                  else:
                      raise NotImplementedError("Unsupported metric for distances")
          
              return self._distances[metric][indexes,:][:,comparison_indexes]
code_tokens: def distances ( self , ids = None , comparison_ids = None , metric = None ) : metric = metric or self . metric if ids is None : indexes = np . arange ( len ( self ) ) else : indexes = self . index ( ids ) if comparison_ids is None : comparison_indexes = indexes else : comparison_indexes = self . index ( comparison_ids ) if len ( self ) > 2000 and len ( indexes ) < 2000 and len ( comparison_indexes ) < 2000 : if metric == "euclidean" : return euclidean_distances ( self . field ( Field . POSITION , indexes ) , self . field ( Field . POSITION , comparison_indexes ) ) elif metric == "cosine" : return cosine_distances ( self . field ( Field . POSITION , indexes ) , self . field ( Field . POSITION , comparison_indexes ) ) elif metric == "precomputed" : return self . field ( Field . POSITION , indexes ) else : raise NotImplementedError ( "Unsupported metric for distances" ) else : if metric not in self . _distances : locations = self . field ( Field . POSITION ) if metric == "euclidean" : self . _distances [ metric ] = euclidean_distances ( locations , locations ) elif metric == "cosine" : self . _distances [ metric ] = cosine_distances ( locations , locations ) elif metric == "precomputed" : self . _distances [ metric ] = locations else : raise NotImplementedError ( "Unsupported metric for distances" ) return self . _distances [ metric ] [ indexes , : ] [ : , comparison_indexes ]
short_docstring: Returns the pairwise distances from the given IDs to each other (or all
  points to each other, if ids is None).
short_docstring_tokens: Returns the pairwise distances from the given IDs to each other ( or all points to each other if ids is None ) .
comment: """
          Returns the pairwise distances from the given IDs to each other (or all
          points to each other, if ids is None). If the metric is not provided,
          the default metric for this Embedding object is used.
          """$SEP$# Just compute the requested distances$SEP$# Cache all pairwise distances