code: def _infer_tz_from_endpoints(start, end, tz):
      
      try:
          inferred_tz = timezones.infer_tzinfo(start, end)
      except Exception:
          raise TypeError('Start and end cannot both be tz-aware with '
                          'different timezones')
  
      inferred_tz = timezones.maybe_get_tz(inferred_tz)
      tz = timezones.maybe_get_tz(tz)
  
      if tz is not None and inferred_tz is not None:
          if not timezones.tz_compare(inferred_tz, tz):
              raise AssertionError("Inferred time zone not equal to passed "
                                   "time zone")
  
      elif inferred_tz is not None:
          tz = inferred_tz
  
      return tz
docs: If a timezone is not explicitly given via `tz`, see if one can
      be inferred from the `start` and `end` endpoints.  If more than one
      of these inputs provides a timezone, require that they all agree.
  
      Parameters
      ----------
      start : Timestamp
      end : Timestamp
      tz : tzinfo or None
  
      Returns
      -------
      tz : tzinfo or None
  
      Raises
      ------
      TypeError : if start and end timezones do not agree