code: def _fetch_url(
      url: str,
      headers: Dict[str, str],
      data: Optional[Dict[str, Any]] = None,
      method: Optional[str] = None,
      reader: Callable[[Any], Any] = lambda x: x.read(),
  ) -> Any:
      token = os.environ.get("GITHUB_TOKEN")
      if token is not None and url.startswith(
          "https://api.github.com/"
      ):
          headers["Authorization"] = f"token {token}"
      data_ = json.dumps(data).encode() if data is not None else None
      try:
          with urlopen(
              Request(url, headers=headers, data=data_, method=method)
          ) as conn:
              return reader(conn)
      except HTTPError as err:
          print(err.reason)
          print(err.headers)
          if err.code == 403 and all(
              key in err.headers
              for key in ["X-RateLimit-Limit", "X-RateLimit-Used"]
          ):
              print(
                  f"Rate limit exceeded: {err.headers['X-RateLimit-Used']}/{err.headers['X-RateLimit-Limit']}"
              )
          raise
  
file_path: pytorch/tools/stats/upload_external_contrib_stats.py
imports: import argparse
  import datetime
  import json
  import os
  import time
  import urllib.parse
  from typing import Any, Callable, cast, Dict, List, Optional, Set
  from urllib.error import HTTPError
  from urllib.request import Request, urlopen
  from tools.stats.upload_stats_lib import upload_to_s3
label_desc: Use image node_id 1 for calling a global function with example usage: _fetch_url(url, headers, data, method, reader) and returns: reader