class_docstr: Mixin of helpers to allow upload of custom metadata.
docstr: Creates an index to lookup custom metadata by filename.
  
  Args:
      custom_metadata:
          Dictionary of custom metadata, see upload_custom_metadata for
          the required format.
  
  Returns:
      A dictionary mapping from filenames to custom metadata.
      If there are no annotations for a filename, the custom metadata
      is None instead.
  
  :meta private:  # Skip docstring generation
docstr_tok: ["Creates","an","index","to","lookup","custom","metadata","by","filename",".","Args",":","custom_metadata",":","Dictionary","of","custom","metadata",",","see","upload_custom_metadata","for","the","required","format",".","Returns",":","A","dictionary","mapping","from","filenames","to","custom","metadata",".","If","there","are","no","annotations","for","a","filename",",","the","custom","metadata","is","None","instead",".",":","meta","private",":","#","Skip","docstring","generation"]
code: def index_custom_metadata_by_filename(
      self, custom_metadata: Dict[str, Any]
  ) -> Dict[str, Union[Dict, None]]:
      """Creates an index to lookup custom metadata by filename.
  
      Args:
          custom_metadata:
              Dictionary of custom metadata, see upload_custom_metadata for
              the required format.
  
      Returns:
          A dictionary mapping from filenames to custom metadata.
          If there are no annotations for a filename, the custom metadata
          is None instead.
  
      :meta private:  # Skip docstring generation
      """
  
      # The mapping is filename -> image_id -> custom_metadata
      # This mapping is created in linear time.
      filename_to_image_id = {
          image_info[COCO_ANNOTATION_KEYS.images_filename]: image_info[
              COCO_ANNOTATION_KEYS.images_id
          ]
          for image_info in custom_metadata[COCO_ANNOTATION_KEYS.images]
      }
      image_id_to_custom_metadata = {
          metadata[
              COCO_ANNOTATION_KEYS.custom_metadata_image_id
          ]: metadata
          for metadata in custom_metadata[
              COCO_ANNOTATION_KEYS.custom_metadata
          ]
      }
      filename_to_metadata = {
          filename: image_id_to_custom_metadata.get(image_id, None)
          for (filename, image_id) in filename_to_image_id.items()
      }
      return filename_to_metadata
  
file_path: lightly/lightly/api/api_workflow_upload_metadata.py
imports: from concurrent.futures import ThreadPoolExecutor
  from typing import Any, Dict, List, Union
  from requests import Response
  from tqdm import tqdm
  from lightly.api.utils import paginate_endpoint, retry
  from lightly.openapi_generated.swagger_client.models import ConfigurationEntry, ConfigurationSetRequest, SampleDataModes, SamplePartialMode, SampleUpdateRequest
  from lightly.utils import hipify
  from lightly.utils.io import COCO_ANNOTATION_KEYS
label_desc: Use image node_id 2 for calling the _UploadCustomMetadataMixin obj's underlying member method code with example usage: obj.index_custom_metadata_by_filename(custom_metadata) and returns: filename_to_metadata