code: def _check_location(
      self, attribute: attr.Attribute, location: str
  ) -> None:
      """Checks if a given file can be accessed locally or remotely.
  
      Args:
          attribute: The attribute.
          location: The file location or URL to check the validity.
  
      Raises:
          FileNotFoundError: If the file should be accessible locally but the
              location is invalid.
          ValueError: If the file should be accessible remotely but the URL is
              invalid.
  
      """
      if location is not None:
          is_remote = location.startswith(
              "http://"
          ) or location.startswith("https://")
          if is_remote and not is_valid_url(location):
              raise ValueError(
                  f"'location' must be a valid URL (got {location})"
              )
          elif not is_remote:
              if not os.path.exists(location) or not os.path.isfile(
                  location
              ):
                  raise FileNotFoundError(
                      f"'location' must be a valid file (got {location})"
                  )
  
imports: import os
  import attr
  import requests
label_desc: Use image node_id 3 for calling a global function with example usage: _check_location(attribute, location) without return types