code: def hf_hub_url(
      repo_id: str,
      filename: str,
      *,
      subfolder: Optional[str] = None,
      repo_type: Optional[str] = None,
      revision: Optional[str] = None,
      endpoint: Optional[str] = None,
  ) -> str:
      """Construct the URL of a file from the given information.
  
      The resolved address can either be a huggingface.co-hosted url, or a link to
      Cloudfront (a Content Delivery Network, or CDN) for large files which are
      more than a few MBs.
  
      Args:
          repo_id (`str`):
              A namespace (user or an organization) name and a repo name separated
              by a `/`.
          filename (`str`):
              The name of the file in the repo.
          subfolder (`str`, *optional*):
              An optional value corresponding to a folder inside the repo.
          repo_type (`str`, *optional*):
              Set to `"dataset"` or `"space"` if downloading from a dataset or space,
              `None` or `"model"` if downloading from a model. Default is `None`.
          revision (`str`, *optional*):
              An optional Git revision id which can be a branch name, a tag, or a
              commit hash.
  
      Example:
  
      ```python
      >>> from huggingface_hub import hf_hub_url
  
      >>> hf_hub_url(
      ...     repo_id="julien-c/EsperBERTo-small", filename="pytorch_model.bin"
      ... )
      'https://huggingface.co/julien-c/EsperBERTo-small/resolve/main/pytorch_model.bin'
      ```
  
      <Tip>
  
      Notes:
  
          Cloudfront is replicated over the globe so downloads are way faster for
          the end user (and it also lowers our bandwidth costs).
  
          Cloudfront aggressively caches files by default (default TTL is 24
          hours), however this is not an issue here because we implement a
          git-based versioning system on huggingface.co, which means that we store
          the files on S3/Cloudfront in a content-addressable way (i.e., the file
          name is its hash). Using content-addressable filenames means cache can't
          ever be stale.
  
          In terms of client-side caching from this library, we base our caching
          on the objects' entity tag (`ETag`), which is an identifier of a
          specific version of a resource [1]_. An object's ETag is: its git-sha1
          if stored in git, or its sha256 if stored in git-lfs.
  
      </Tip>
  
      References:
  
      -  [1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
      """
      if subfolder == "":
          subfolder = None
      if subfolder is not None:
          filename = f"{subfolder}/{filename}"
  
      if repo_type not in REPO_TYPES:
          raise ValueError("Invalid repo type")
  
      if repo_type in REPO_TYPES_URL_PREFIXES:
          repo_id = REPO_TYPES_URL_PREFIXES[repo_type] + repo_id
  
      if revision is None:
          revision = DEFAULT_REVISION
      url = HUGGINGFACE_CO_URL_TEMPLATE.format(
          repo_id=repo_id,
          revision=quote(revision, safe=""),
          filename=quote(filename),
      )
      # Update endpoint if provided
      if endpoint is not None and url.startswith(ENDPOINT):
          url = endpoint + url[len(ENDPOINT) :]
      return url
  
imports: import copy
  import fnmatch
  import inspect
  import io
  import json
  import os
  import re
  import shutil
  import stat
  import tempfile
  import time
  import uuid
  import warnings
  from contextlib import contextmanager
  from dataclasses import dataclass
  from functools import partial
  from pathlib import Path
  from typing import Any, BinaryIO, Dict, Generator, Literal, Optional, Tuple, Union
  from urllib.parse import quote, urlparse
  import requests
  from filelock import FileLock
  from huggingface_hub import constants
  from .None import __version__
  from .constants import DEFAULT_ETAG_TIMEOUT, DEFAULT_REQUEST_TIMEOUT, DEFAULT_REVISION, DOWNLOAD_CHUNK_SIZE, ENDPOINT, HF_HUB_CACHE, HF_HUB_DISABLE_SYMLINKS_WARNING, HF_HUB_DOWNLOAD_TIMEOUT, HF_HUB_ENABLE_HF_TRANSFER, HF_HUB_ETAG_TIMEOUT, HF_TRANSFER_CONCURRENCY, HUGGINGFACE_CO_URL_TEMPLATE, HUGGINGFACE_HEADER_X_LINKED_ETAG, HUGGINGFACE_HEADER_X_LINKED_SIZE, HUGGINGFACE_HEADER_X_REPO_COMMIT, HUGGINGFACE_HUB_CACHE, REPO_ID_SEPARATOR, REPO_TYPES, REPO_TYPES_URL_PREFIXES
  from .utils import EntryNotFoundError, FileMetadataError, GatedRepoError, LocalEntryNotFoundError, OfflineModeIsEnabled, RepositoryNotFoundError, RevisionNotFoundError, SoftTemporaryDirectory, build_hf_headers, get_fastai_version, get_fastcore_version, get_graphviz_version, get_jinja_version, get_pydot_version, get_session, get_tf_version, get_torch_version, hf_raise_for_status, is_fastai_available, is_fastcore_available, is_graphviz_available, is_jinja_available, is_pydot_available, is_tf_available, is_torch_available, logging, reset_sessions, tqdm, validate_hf_hub_args
  from .utils._deprecation import _deprecate_method
  from .utils._headers import _http_user_agent
  from .utils._runtime import _PY_VERSION
  from .utils._typing import HTTP_METHOD_T
  from .utils.insecure_hashlib import sha256
label_desc: Use image node_id 2 for calling a global function with example usage: hf_hub_url(repo_id, filename) and returns: url