code: def validate_tz_from_dtype(dtype, tz):
      
      if dtype is not None:
          if isinstance(dtype, str):
              try:
                  dtype = DatetimeTZDtype.construct_from_string(dtype)
              except TypeError:
                  # Things like `datetime64[ns]`, which is OK for the
                  # constructors, but also nonsense, which should be validated
                  # but not by us. We *do* allow non-existent tz errors to
                  # go through
                  pass
          dtz = getattr(dtype, 'tz', None)
          if dtz is not None:
              if tz is not None and not timezones.tz_compare(tz, dtz):
                  raise ValueError("cannot supply both a tz and a dtype"
                                   " with a tz")
              tz = dtz
  
          if tz is not None and is_datetime64_dtype(dtype):
              # We also need to check for the case where the user passed a
              #  tz-naive dtype (i.e. datetime64[ns])
              if tz is not None and not timezones.tz_compare(tz, dtz):
                  raise ValueError("cannot supply both a tz and a "
                                   "timezone-naive dtype (i.e. datetime64[ns])")
  
      return tz
docs: If the given dtype is a DatetimeTZDtype, extract the implied
      tzinfo object from it and check that it does not conflict with the given
      tz.
  
      Parameters
      ----------
      dtype : dtype, str
      tz : None, tzinfo
  
      Returns
      -------
      tz : consensus tzinfo
  
      Raises
      ------
      ValueError : on tzinfo mismatch